Skip to content

Commit

Permalink
Add integer rounding to match APE 14 (#525)
Browse files Browse the repository at this point in the history
Co-authored-by: Nadia Dencheva <[email protected]>
  • Loading branch information
WilliamJamieson and nden authored Dec 2, 2024
1 parent 9f23a66 commit c01c6d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@

- Force ``bounding_box`` to always be returned as a ``F`` ordered box. [#522]

- Adjust ``world_to_array_index_values`` to round to integer coordinates as specified by APE 14. [#525]

- Add warning filter to asdf extension to prevent the ``bounding_box`` order warning for gwcs
objects originating from a file. [#526]


0.21.0 (2024-03-10)
-------------------

Expand Down
12 changes: 8 additions & 4 deletions gwcs/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,14 @@ def world_to_array_index_values(self, *world_arrays):
`~BaseLowLevelWCS.pixel_to_world_values`). The indices should be
returned as rounded integers.
"""
result = self.world_to_pixel_values(*world_arrays)
if self.pixel_n_dim != 1:
result = result[::-1]
return result
results = self.world_to_pixel_values(*world_arrays)
if self.pixel_n_dim == 1:
results = (results,)
else:
results = results[::-1]

results = tuple(utils._toindex(result) for result in results)
return results[0] if self.pixel_n_dim == 1 else results

@property
def array_shape(self):
Expand Down

0 comments on commit c01c6d0

Please sign in to comment.