From 904c1caf413124ed87dcc59085297e28e76d3e90 Mon Sep 17 00:00:00 2001 From: "Brett M. Morris" Date: Tue, 16 Apr 2024 11:28:30 -0400 Subject: [PATCH] allow transparent image composite arrays out of bounds --- glue/core/fixed_resolution_buffer.py | 4 ++-- .../core/tests/test_fixed_resolution_buffer.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/glue/core/fixed_resolution_buffer.py b/glue/core/fixed_resolution_buffer.py index 76bc0c067..126d1253e 100644 --- a/glue/core/fixed_resolution_buffer.py +++ b/glue/core/fixed_resolution_buffer.py @@ -261,7 +261,7 @@ def compute_fixed_resolution_buffer(data, bounds, target_data=None, target_cid=N # Take subset_state into account, if present if subset_state is None: array = data.get_data(target_cid, view=subregion).astype(float) - invalid_value = -np.inf + invalid_value = np.nan else: array = data.get_mask(subset_state, view=subregion) invalid_value = False @@ -275,7 +275,7 @@ def compute_fixed_resolution_buffer(data, bounds, target_data=None, target_cid=N # Take subset_state into account, if present if subset_state is None: array = data.get_data(target_cid, view=translated_coords).astype(float) - invalid_value = -np.inf + invalid_value = np.nan else: array = data.get_mask(subset_state, view=translated_coords) invalid_value = False diff --git a/glue/core/tests/test_fixed_resolution_buffer.py b/glue/core/tests/test_fixed_resolution_buffer.py index 6fa2c7a2c..c5d0df027 100644 --- a/glue/core/tests/test_fixed_resolution_buffer.py +++ b/glue/core/tests/test_fixed_resolution_buffer.py @@ -89,11 +89,11 @@ def setup_method(self, method): # Bounds are outside data along some dimensions ([(-5, 9, 15), (3, 5, 3), (0, 9, 10), (5, 6, 2)], np.pad(ARRAY[:, 3:6, :, 5:7], [(5, 4), (0, 0), (0, 2), (0, 0)], - mode='constant', constant_values=-np.inf)), + mode='constant', constant_values=np.nan)), # No overlap ([(2, 3, 2), (3, 3, 1), (-5, -4, 2), (0, 7, 8)], - -np.inf * np.ones((2, 1, 2, 8))) + np.nan * np.ones((2, 1, 2, 8))) ] @@ -137,22 +137,22 @@ def sub_one(x): target_data=data1, bounds=[(-1, 1, 3), (0, 3, 4), 1], target_cid=data1.main_components[0]), - np.array([[-np.inf, -np.inf, -np.inf, -np.inf], + np.array([[np.nan, np.nan, np.nan, np.nan], [1, 4, 7, 10], - [-np.inf, -np.inf, -np.inf, -np.inf]])) + [np.nan, np.nan, np.nan, np.nan]])) assert_equal(compute_fixed_resolution_buffer(data2, target_data=data2, bounds=[(-1, 1, 3), (0, 3, 4), 1], target_cid=data2.main_components[0]), - np.array([[-np.inf, -np.inf, -np.inf, -np.inf], + np.array([[np.nan, np.nan, np.nan, np.nan], [1, 4, 7, 10], - [-np.inf, -np.inf, -np.inf, -np.inf]])) + [np.nan, np.nan, np.nan, np.nan]])) assert_equal(compute_fixed_resolution_buffer(data1, target_data=data2, bounds=[(-1, 1, 3), (0, 3, 4), 1], target_cid=data1.main_components[0]), - np.array([[-np.inf, -np.inf, -np.inf, -np.inf], - [-np.inf, 2, 5, 8], - [-np.inf, -np.inf, -np.inf, -np.inf]])) + np.array([[np.nan, np.nan, np.nan, np.nan], + [np.nan, 2, 5, 8], + [np.nan, np.nan, np.nan, np.nan]]))