Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integer rounding to match APE 14 #525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

- 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]

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 @@
`~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,)

Check warning on line 152 in gwcs/api.py

View check run for this annotation

Codecov / codecov/patch

gwcs/api.py#L152

Added line #L152 was not covered by tests
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