From 262ee74acdeb729e26fe8dee741135cf872d1aa4 Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Tue, 12 Nov 2024 14:14:14 -0500 Subject: [PATCH] Add integer rounding to match APE 14 Update changes --- CHANGES.rst | 2 ++ gwcs/api.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 6f0cce2a..d9e241d2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) ------------------- diff --git a/gwcs/api.py b/gwcs/api.py index 4f2ce9fc..2b1ca22e 100644 --- a/gwcs/api.py +++ b/gwcs/api.py @@ -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):