From b4aa984c5db3519ba529185d431aed54141b7db7 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 2 Mar 2023 11:04:43 +0000 Subject: [PATCH 1/2] Fix world_axis_units for SpectralCoordinates --- glue_astronomy/spectral_coordinates.py | 4 ++++ glue_astronomy/tests/test_spectral_coordinates.py | 1 + 2 files changed, 5 insertions(+) diff --git a/glue_astronomy/spectral_coordinates.py b/glue_astronomy/spectral_coordinates.py index 7e20c37..662f2d6 100644 --- a/glue_astronomy/spectral_coordinates.py +++ b/glue_astronomy/spectral_coordinates.py @@ -27,6 +27,10 @@ def spectral_axis(self): """ return self._values + @property + def world_axis_units(self): + return (self._values.unit.to_string('vounit'),) + def world_to_pixel_values(self, *world): """ Parameters diff --git a/glue_astronomy/tests/test_spectral_coordinates.py b/glue_astronomy/tests/test_spectral_coordinates.py index 6d1fed8..b9741df 100644 --- a/glue_astronomy/tests/test_spectral_coordinates.py +++ b/glue_astronomy/tests/test_spectral_coordinates.py @@ -17,6 +17,7 @@ def test_basic(): assert_allclose(sc.world_to_pixel_values(10), 0) assert_allclose(sc.world_to_pixel_values([10, 15, 20]), [0, 0.5, 1.0]) + assert sc.world_axis_units == ('Hz',) def test_invalid_init(): From 2125340922bc0a9a63f95710558800bb6ca8b364 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 2 Mar 2023 11:09:12 +0000 Subject: [PATCH 2/2] Fix code style --- glue_astronomy/tests/test_spectral_coordinates.py | 1 + 1 file changed, 1 insertion(+) diff --git a/glue_astronomy/tests/test_spectral_coordinates.py b/glue_astronomy/tests/test_spectral_coordinates.py index b9741df..79fa2e0 100644 --- a/glue_astronomy/tests/test_spectral_coordinates.py +++ b/glue_astronomy/tests/test_spectral_coordinates.py @@ -19,6 +19,7 @@ def test_basic(): assert sc.world_axis_units == ('Hz',) + def test_invalid_init(): with pytest.raises(TypeError, match='values should be a Quantity instance'):