Skip to content

Commit

Permalink
Merge pull request #2482 from bmorris3/transparent-out-of-bounds
Browse files Browse the repository at this point in the history
Allow transparent regions in composite images when out of bounds
  • Loading branch information
astrofrog authored Apr 17, 2024
2 parents 924d0ae + 904c1ca commit 079829f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions glue/core/fixed_resolution_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions glue/core/tests/test_fixed_resolution_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

]

Expand Down Expand Up @@ -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]]))

0 comments on commit 079829f

Please sign in to comment.