From e108ddeaf0f5ec6f535a84c6c0213441193591c8 Mon Sep 17 00:00:00 2001 From: Brett Graham Date: Tue, 27 Feb 2024 08:31:56 -0500 Subject: [PATCH] fix __str__ for wcs with a None transform (#489) --- CHANGES.rst | 2 ++ gwcs/tests/test_wcs.py | 5 +++++ gwcs/wcs.py | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 7960a3a2..e66d32e7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ - Add a minimum version requirement for ``asdf-wcs-schemas``. [#488] +- Fix ``WCS.__str__`` for instances without transforms. [#489] + 0.20.0 (2023-11-29) ------------------- diff --git a/gwcs/tests/test_wcs.py b/gwcs/tests/test_wcs.py index 7268f392..77627176 100644 --- a/gwcs/tests/test_wcs.py +++ b/gwcs/tests/test_wcs.py @@ -1316,3 +1316,8 @@ def test_spatial_spectral_stokes(): assert_allclose(gw_sky.data.lat, aw_sky.data.lat) assert_allclose(gw_spec.value, aw_spec.value) assert_allclose(gw_stokes.value, aw_stokes.value) + + +def test_wcs_str(): + w = wcs.WCS(output_frame="icrs") + assert 'icrs' in str(w) diff --git a/gwcs/wcs.py b/gwcs/wcs.py index 3829c723..0432e541 100644 --- a/gwcs/wcs.py +++ b/gwcs/wcs.py @@ -1338,13 +1338,13 @@ def _get_axes_indices(self): def __str__(self): from astropy.table import Table - #col1 = [item[0] for item in self._pipeline] col1 = [step.frame for step in self._pipeline] col2 = [] for item in self._pipeline[: -1]: - #model = item[1] model = item.transform - if model.name is not None: + if model is None: + col2.append(None) + elif model.name is not None: col2.append(model.name) else: col2.append(model.__class__.__name__)