Skip to content

Commit

Permalink
More roundtip test fixing
Browse files Browse the repository at this point in the history
Seems this leaves one troublesome test
  • Loading branch information
Cadair committed Sep 26, 2024
1 parent 760a636 commit 54a3936
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions gwcs/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,8 @@ def test_high_level_wrapper(wcsobj, request):

pixel_input = [3] * wcsobj.pixel_n_dim

# If the model expects units we have to pass in units
if wcsobj.forward_transform.uses_quantity:
pixel_input *= u.pix

# The wrapper and the raw gwcs class can take different paths
# Assert that both APE 14 API and GWCS give the same answer The APE 14 API
# uses the mixin class and __call__ calls values_to_high_level_objects
wc1 = hlvl.pixel_to_world(*pixel_input)
wc2 = wcsobj(*pixel_input, with_units=True)

Expand All @@ -290,6 +287,22 @@ def test_high_level_wrapper(wcsobj, request):
else:
_compare_frame_output(wc1, wc2)

# we have just asserted that wc1 and wc2 are equal
if not isinstance(wc1, (list, tuple)):
wc1 = (wc1,)

pix_out1 = hlvl.world_to_pixel(*wc1)
pix_out2 = wcsobj.invert(*wc1)

if not isinstance(pix_out2, (list, tuple)):
pix_out2 = (pix_out2,)

if wcsobj.forward_transform.uses_quantity:
pix_out2 = tuple(p.to_value(unit) for p, unit in zip(pix_out2, wcsobj.input_frame.unit))

np.testing.assert_allclose(pix_out1, pixel_input)
np.testing.assert_allclose(pix_out2, pixel_input)


def test_stokes_wrapper(gwcs_stokes_lookup):
pytest.importorskip("astropy", minversion="4.0dev0")
Expand Down

0 comments on commit 54a3936

Please sign in to comment.