From b43b156df919249bc49a54e8a5cf5fe1852130e7 Mon Sep 17 00:00:00 2001 From: Jonathan Foster Date: Fri, 14 Jul 2023 14:53:17 -0400 Subject: [PATCH 1/2] Set incompatible image subset from bounds --- glue/viewers/image/layer_artist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glue/viewers/image/layer_artist.py b/glue/viewers/image/layer_artist.py index ea2c7c452..e8eaa6c4b 100644 --- a/glue/viewers/image/layer_artist.py +++ b/glue/viewers/image/layer_artist.py @@ -238,7 +238,7 @@ def __call__(self, bounds): if (self.layer_artist is None or self.layer_state is None or self.viewer_state is None): - return np.broadcast_to(np.nan, self.shape) + return None # We should compute the mask even if the layer is not visible as we need # the layer to show up properly when it is made visible (which doesn't @@ -248,7 +248,7 @@ def __call__(self, bounds): mask = self.layer_state.get_sliced_data(bounds=bounds) except IncompatibleAttribute: self.layer_artist.disable_incompatible_subset() - return np.broadcast_to(np.nan, self.shape) + return np.broadcast_to(np.nan, (bounds[0][-1], bounds[1][-1], 4)) else: self.layer_artist.enable(redraw=False) From 5e3dc917f3d06809fd81109047f0a8bd0687a029 Mon Sep 17 00:00:00 2001 From: Jonathan Foster Date: Fri, 15 Sep 2023 13:29:12 -0400 Subject: [PATCH 2/2] Just return None and document change --- glue/viewers/image/layer_artist.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/glue/viewers/image/layer_artist.py b/glue/viewers/image/layer_artist.py index e8eaa6c4b..79bfb2f60 100644 --- a/glue/viewers/image/layer_artist.py +++ b/glue/viewers/image/layer_artist.py @@ -242,13 +242,15 @@ def __call__(self, bounds): # We should compute the mask even if the layer is not visible as we need # the layer to show up properly when it is made visible (which doesn't - # trigger __getitem__) + # trigger __getitem__). However, if the layer is disabled, then we will + # call this method when it is enabled, so in this case we just return + # an empty mask. try: mask = self.layer_state.get_sliced_data(bounds=bounds) except IncompatibleAttribute: self.layer_artist.disable_incompatible_subset() - return np.broadcast_to(np.nan, (bounds[0][-1], bounds[1][-1], 4)) + return None else: self.layer_artist.enable(redraw=False)