Skip to content

Commit

Permalink
More test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Dec 4, 2024
1 parent afc7989 commit 6fd7e2b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions gwcs/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from astropy.modeling import separable
import astropy.units as u

from gwcs import utils

__all__ = ["GWCSAPIMixin"]


Expand Down
22 changes: 12 additions & 10 deletions gwcs/tests/test_wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from gwcs import utils
from gwcs.wcstools import (wcs_from_fiducial, grid_from_bounding_box, wcs_from_points)
from gwcs.utils import CoordinateFrameError
from gwcs.utils import _gwcs_from_hst_fits_wcs
from gwcs.tests.utils import _gwcs_from_hst_fits_wcs
from gwcs.tests import data
from gwcs.examples import gwcs_2d_bad_bounding_box_order

Expand Down Expand Up @@ -467,7 +467,8 @@ def test_bounding_box_eval():
Tests evaluation with and without respecting the bounding_box.
"""
trans3 = models.Shift(10) & models.Scale(2) & models.Shift(-1)
pipeline = [('detector', trans3), ('sky', None)]
pipeline = [(cf.CoordinateFrame(naxes=1, axes_type=("PIXEL",), axes_order=(0,), name='detector'), trans3),
(cf.CoordinateFrame(naxes=1, axes_type=("SPATIAL",), axes_order=(0,), name='sky'), None)]
w = wcs.WCS(pipeline)
w.bounding_box = ((-1, 10), (6, 15), (4.3, 6.9))

Expand Down Expand Up @@ -608,11 +609,13 @@ def setup_class(self):
tan = models.Pix2Sky_TAN(name='tangent_projection')
sky_cs = cf.CelestialFrame(reference_frame=coord.ICRS(), name='sky')
det = cf.Frame2D(name='detector')
focal = cf.Frame2D(name='focal')
wcs_forward = wcslin | tan | n2c
pipeline = [wcs.Step('detector', distortion),
wcs.Step('focal', wcs_forward),
wcs.Step(sky_cs, None)
]
pipeline = [
wcs.Step(det, distortion),
wcs.Step(focal, wcs_forward),
wcs.Step(sky_cs, None)
]

self.wcs = wcs.WCS(input_frame=det,
output_frame=sky_cs,
Expand Down Expand Up @@ -659,7 +662,7 @@ def test_inverse(self):

def test_back_coordinates(self):
sky_coord = self.wcs(1, 2, with_units=True)
res = self.wcs.transform('sky', 'focal', sky_coord, with_units=True)
res = self.wcs.transform('sky', 'focal', sky_coord, with_units=False)
assert_allclose(res, self.wcs.get_transform('detector', 'focal')(1, 2))

def test_units(self):
Expand Down Expand Up @@ -1553,9 +1556,8 @@ def test_high_level_objects_in_pipeline_forward(gwcs_with_pipeline_celestial):
*input_pixel,
with_units=True
)
assert len(intermediate_world_with_units) == 1
assert isinstance(intermediate_world_with_units[0], coord.SkyCoord)
sc = intermediate_world_with_units[0]
assert isinstance(intermediate_world_with_units, coord.SkyCoord)
sc = intermediate_world_with_units
assert u.allclose(sc.ra, 20*u.arcsec)
assert u.allclose(sc.dec, 15*u.deg)

Expand Down
4 changes: 2 additions & 2 deletions gwcs/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,8 @@ def transform(self, from_frame, to_frame, *args, **kwargs):
to_frame = self._get_frame_by_name(to_frame)

with_units = kwargs.pop("with_units", False)
if with_units and backward:
args = high_level_objects_to_values(*args, low_level_wcs=self)
if backward and utils.is_high_level(*args, low_level_wcs=from_frame):
args = high_level_objects_to_values(*args, low_level_wcs=from_frame)

results = self._call_forward(*args, from_frame=from_frame, to_frame=to_frame, **kwargs)

Expand Down

0 comments on commit 6fd7e2b

Please sign in to comment.