From c455cab7e9c6e24161a09f5c60cbe8dd08198e63 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Tue, 10 Dec 2024 16:45:17 -0500 Subject: [PATCH] fix something --- gwcs/tests/test_wcs.py | 6 +++--- gwcs/wcs.py | 30 ++++-------------------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/gwcs/tests/test_wcs.py b/gwcs/tests/test_wcs.py index 1baad46f..5b2a47fb 100644 --- a/gwcs/tests/test_wcs.py +++ b/gwcs/tests/test_wcs.py @@ -1161,10 +1161,10 @@ def test_in_image(): None)]) w2.bounding_box = [(1, 100), (2, 20)] - assert np.isscalar(w2.in_image(2, 6)) + assert np.isscalar(w2.in_image(2, 6))#[0]) assert not np.isscalar(w2.in_image([2], [6])) - assert w2.in_image(4, 6) - assert not w2.in_image(5, 0) + assert (w2.in_image(4, 6))#.all() + assert not (w2.in_image(5, 0))#, [True, False]) assert np.array_equal( w2.in_image( [[9, 10, 11, 15], [8, 9, 67, 98], [2, 2, np.nan, 102]], diff --git a/gwcs/wcs.py b/gwcs/wcs.py index 94a10bd5..97f2da14 100644 --- a/gwcs/wcs.py +++ b/gwcs/wcs.py @@ -400,31 +400,12 @@ def in_image(self, *args, **kwargs): and `False` if input is outside the footprint. """ - coords = self.invert(*args, with_bounding_box=False, **kwargs) + coords = self.invert(*args, **kwargs) result = np.isfinite(coords) if self.input_frame.naxes > 1: result = np.all(result, axis=0) - if self.bounding_box is None or not np.any(result): - return result - - if self.input_frame.naxes == 1: - x1, x2 = self.bounding_box.bounding_box() - - if len(np.shape(args[0])) > 0: - result[result] = (coords[result] >= x1) & (coords[result] <= x2) - elif result: - result = (coords >= x1) and (coords <= x2) - - else: - if len(np.shape(args[0])) > 0: - for c, (x1, x2) in zip(coords, self.bounding_box): - result[result] = (c[result] >= x1) & (c[result] <= x2) - - elif result: - result = all([(c >= x1) and (c <= x2) for c, (x1, x2) in zip(coords, self.bounding_box)]) - return result def invert(self, *args, **kwargs): @@ -489,7 +470,7 @@ def invert(self, *args, **kwargs): fill_value = kwargs.pop('fill_value', np.nan) akwargs = {k: v for k, v in kwargs.items() if k not in _ITER_INV_KWARGS} if with_bounding_box and self.bounding_box is not None: - result = self.outside_footprint(args) + args = self.outside_footprint(args) if btrans is not None: result = btrans(*args, **akwargs) @@ -513,11 +494,8 @@ def outside_footprint(self, world_arrays): axes_types = set(self.output_frame.axes_type) footprint = self.footprint() - world_arrays = [coo.to(unit) for coo, unit in zip(world_arrays, self.output_frame.unit) - if isinstance(coo, u.Quantity)] - world_arrays = [high_level_objects_to_values(coo, low_level_wcs=self) for - coo in world_arrays if not utils.isnumerical(coo)] - + if not utils.isnumerical(world_arrays[0]): + world_arrays = high_level_objects_to_values(*world_arrays, low_level_wcs=self) for axtyp in axes_types: ind = np.asarray((np.asarray(self.output_frame.axes_type) == axtyp))