Skip to content

Commit 079829f

Browse files
authored
Merge pull request #2482 from bmorris3/transparent-out-of-bounds
Allow transparent regions in composite images when out of bounds
2 parents 924d0ae + 904c1ca commit 079829f

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

glue/core/fixed_resolution_buffer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def compute_fixed_resolution_buffer(data, bounds, target_data=None, target_cid=N
261261
# Take subset_state into account, if present
262262
if subset_state is None:
263263
array = data.get_data(target_cid, view=subregion).astype(float)
264-
invalid_value = -np.inf
264+
invalid_value = np.nan
265265
else:
266266
array = data.get_mask(subset_state, view=subregion)
267267
invalid_value = False
@@ -275,7 +275,7 @@ def compute_fixed_resolution_buffer(data, bounds, target_data=None, target_cid=N
275275
# Take subset_state into account, if present
276276
if subset_state is None:
277277
array = data.get_data(target_cid, view=translated_coords).astype(float)
278-
invalid_value = -np.inf
278+
invalid_value = np.nan
279279
else:
280280
array = data.get_mask(subset_state, view=translated_coords)
281281
invalid_value = False

glue/core/tests/test_fixed_resolution_buffer.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ def setup_method(self, method):
8989
# Bounds are outside data along some dimensions
9090
([(-5, 9, 15), (3, 5, 3), (0, 9, 10), (5, 6, 2)],
9191
np.pad(ARRAY[:, 3:6, :, 5:7], [(5, 4), (0, 0), (0, 2), (0, 0)],
92-
mode='constant', constant_values=-np.inf)),
92+
mode='constant', constant_values=np.nan)),
9393

9494
# No overlap
9595
([(2, 3, 2), (3, 3, 1), (-5, -4, 2), (0, 7, 8)],
96-
-np.inf * np.ones((2, 1, 2, 8)))
96+
np.nan * np.ones((2, 1, 2, 8)))
9797

9898
]
9999

@@ -137,22 +137,22 @@ def sub_one(x):
137137
target_data=data1,
138138
bounds=[(-1, 1, 3), (0, 3, 4), 1],
139139
target_cid=data1.main_components[0]),
140-
np.array([[-np.inf, -np.inf, -np.inf, -np.inf],
140+
np.array([[np.nan, np.nan, np.nan, np.nan],
141141
[1, 4, 7, 10],
142-
[-np.inf, -np.inf, -np.inf, -np.inf]]))
142+
[np.nan, np.nan, np.nan, np.nan]]))
143143

144144
assert_equal(compute_fixed_resolution_buffer(data2,
145145
target_data=data2,
146146
bounds=[(-1, 1, 3), (0, 3, 4), 1],
147147
target_cid=data2.main_components[0]),
148-
np.array([[-np.inf, -np.inf, -np.inf, -np.inf],
148+
np.array([[np.nan, np.nan, np.nan, np.nan],
149149
[1, 4, 7, 10],
150-
[-np.inf, -np.inf, -np.inf, -np.inf]]))
150+
[np.nan, np.nan, np.nan, np.nan]]))
151151

152152
assert_equal(compute_fixed_resolution_buffer(data1,
153153
target_data=data2,
154154
bounds=[(-1, 1, 3), (0, 3, 4), 1],
155155
target_cid=data1.main_components[0]),
156-
np.array([[-np.inf, -np.inf, -np.inf, -np.inf],
157-
[-np.inf, 2, 5, 8],
158-
[-np.inf, -np.inf, -np.inf, -np.inf]]))
156+
np.array([[np.nan, np.nan, np.nan, np.nan],
157+
[np.nan, 2, 5, 8],
158+
[np.nan, np.nan, np.nan, np.nan]]))

0 commit comments

Comments
 (0)