Skip to content

Commit

Permalink
fix for result shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed May 9, 2024
1 parent 0ac68f2 commit 9068f7a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
0.22.0 (unreleased)
-------------------

- Return nan for world to pixel transformations outside of the
bounding box. [#497]

0.21.0 (2024-03-10)
-------------------
Expand Down
5 changes: 3 additions & 2 deletions gwcs/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ def world_to_pixel_values(self, *world_arrays):
world_arrays = self._add_units_input(world_arrays, self.backward_transform, self.output_frame)

result = self.invert(*world_arrays, with_units=False)
result = self._out_of_bounding_box_to_nan(result, world_arrays)
result = self._remove_quantity_output(result, self.input_frame)

return self._out_of_bounding_box_to_nan(result, world_arrays)

return self._remove_quantity_output(result, self.input_frame)

def world_to_array_index_values(self, *world_arrays):
"""
Expand Down
5 changes: 5 additions & 0 deletions gwcs/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,11 @@ def _out_of_bounding_box_to_nan(self, coords, args):
coords,
np.nan
)

if isinstance(result, np.ndarray) and result.shape == ():
# scalar results should be floats:
result = float(result)

return result

def invert(self, *args, **kwargs):
Expand Down

0 comments on commit 9068f7a

Please sign in to comment.