From db681359af68ca2459f22925a5d6403a737f5078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Mon, 22 Aug 2022 21:02:41 +0200 Subject: [PATCH] BUG: fix crash in image normalization for RGBA image arrays --- yt/visualization/_handlers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/yt/visualization/_handlers.py b/yt/visualization/_handlers.py index 78bca696f9e..e0935db6c77 100644 --- a/yt/visualization/_handlers.py +++ b/yt/visualization/_handlers.py @@ -321,7 +321,11 @@ def get_norm(self, data: np.ndarray, *args, **kw) -> Normalize: dvmax = 1 * getattr(data, "units", 1) kw.setdefault("vmax", dvmax) - if self.norm_type is not None: + if data.ndim == 3: + assert data.shape[-1] == 4 + # this is an RGBA array, only linear normalization makes sense here + norm_type = Normalize + elif self.norm_type is not None: # this is a convenience mechanism for backward compat, # allowing to toggle between lin and log scaling without detailed user input norm_type = self.norm_type