From 6a7002c9a6faf8c0b789af83bb1b5d5b6b1d7811 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Fri, 16 Feb 2024 18:19:37 -0500 Subject: [PATCH 1/8] Increase Imviz rotation test coverage. --- jdaviz/configs/imviz/helper.py | 4 +- .../configs/imviz/tests/test_orientation.py | 148 ++++++++++++++++-- jdaviz/configs/imviz/tests/test_wcs_utils.py | 14 +- jdaviz/configs/imviz/wcs_utils.py | 4 +- 4 files changed, 151 insertions(+), 19 deletions(-) diff --git a/jdaviz/configs/imviz/helper.py b/jdaviz/configs/imviz/helper.py index b371f18651..0d83f75415 100644 --- a/jdaviz/configs/imviz/helper.py +++ b/jdaviz/configs/imviz/helper.py @@ -296,8 +296,10 @@ def get_link_type(self, data_label_1, data_label_2): break # Might have duplicate, just grab first match if link_type is None: + avail_links = [f"({elink.data1.label}, {elink.data2.label})" + for elink in self.app.data_collection.external_links] raise ValueError(f'{data_label_1} and {data_label_2} combo not found ' - 'in data collection external links') + f'in data collection external links: {avail_links}') return link_type diff --git a/jdaviz/configs/imviz/tests/test_orientation.py b/jdaviz/configs/imviz/tests/test_orientation.py index 0b2a52dfd2..bc94a68a5a 100644 --- a/jdaviz/configs/imviz/tests/test_orientation.py +++ b/jdaviz/configs/imviz/tests/test_orientation.py @@ -1,31 +1,149 @@ import pytest - from astropy.table import Table +from numpy.testing import assert_allclose + from jdaviz.configs.imviz.tests.utils import BaseImviz_WCS_WCS -class TestLinksControl(BaseImviz_WCS_WCS): - def test_plugin(self): - lc_plugin = self.imviz.app.get_tray_item_from_name('imviz-orientation') +class TestDefaultOrientation(BaseImviz_WCS_WCS): + def test_affine_reset_and_linktype(self): + lc_plugin = self.imviz.plugins['Orientation'] - lc_plugin.link_type.selected = 'WCS' + lc_plugin.link_type = 'WCS' lc_plugin.wcs_use_affine = False - lc_plugin.link_type.selected = 'Pixels' + assert self.imviz.get_link_type("Default orientation", "has_wcs_2[SCI,1]") == "wcs" - # wcs_use_affine should revert/default to True + # wcs_use_affine should revert/default to True when change back to Pixels. + lc_plugin.link_type = 'Pixels' assert lc_plugin.wcs_use_affine is True + assert self.imviz.get_link_type("has_wcs_1[SCI,1]", "has_wcs_2[SCI,1]") == "pixels" + + assert self.imviz.get_link_type("has_wcs_1[SCI,1]", "has_wcs_1[SCI,1]") == "self" + + with pytest.raises(ValueError, match=".*combo not found"): + self.imviz.get_link_type("has_wcs_1[SCI,1]", "foo") - # adding markers should disable changing linking from both UI and API - assert lc_plugin.need_clear_astrowidget_markers is False + def test_astrowidgets_markers_disable_relinking(self): + lc_plugin = self.imviz.plugins['Orientation'] + lc_plugin.link_type = 'Pixels' + + # Adding markers should disable changing linking from both UI and API. + assert lc_plugin._obj.need_clear_astrowidget_markers is False tbl = Table({'x': (0, 0), 'y': (0, 1)}) self.viewer.add_markers(tbl, marker_name='xy_markers') - assert lc_plugin.need_clear_astrowidget_markers is True + assert lc_plugin._obj.need_clear_astrowidget_markers is True with pytest.raises(ValueError, match="cannot change linking"): - lc_plugin.link_type.selected = 'WCS' - assert lc_plugin.link_type.selected == 'Pixels' + lc_plugin.link_type = 'WCS' + assert lc_plugin.link_type == 'Pixels' + + lc_plugin._obj.vue_reset_astrowidget_markers() + + assert lc_plugin._obj.need_clear_astrowidget_markers is False + lc_plugin.link_type = 'WCS' + + def test_markers_plugin_recompute_positions_pixels_to_wcs(self): + lc_plugin = self.imviz.plugins['Orientation'] + lc_plugin.link_type = 'Pixels' + + # Blink to second image, if we have to. + if self.viewer.top_visible_data_label != "has_wcs_2[SCI,1]": + self.viewer.blink_once() + + label_mouseover = self.imviz.app.session.application._tools['g-coords-info'] + mp = self.imviz.plugins['Markers'] + mp._obj.plugin_opened = True + + # (0, 0) on second image. + label_mouseover._viewer_mouse_event( + self.viewer, {'event': 'mousemove', 'domain': {'x': 1, 'y': 0}}) + mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) + + # (0, 0) on first image. + self.viewer.blink_once() + label_mouseover._viewer_mouse_event( + self.viewer, {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) + mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) + + lc_plugin.link_type = 'WCS' + + # Both marks stay the same in sky, so this means X and Y w.r.t. reference + # same on both entries. + # 0.25 offset probably introduced by fake WCS layer. + assert_allclose(mp._obj.marks["imviz-0"].x, -0.25) + assert_allclose(mp._obj.marks["imviz-0"].y, -0.25) + + mp.clear_table() + mp._obj.plugin_opened = False + + def test_markers_plugin_recompute_positions_wcs_to_pixels(self): + lc_plugin = self.imviz.plugins['Orientation'] + lc_plugin.link_type = 'WCS' + + # Blink to second image, if we have to. + if self.viewer.top_visible_data_label != "has_wcs_2[SCI,1]": + self.viewer.blink_once() + + label_mouseover = self.imviz.app.session.application._tools['g-coords-info'] + mp = self.imviz.plugins['Markers'] + mp._obj.plugin_opened = True + + # (0, 0) on second image, but linked by WCS. + label_mouseover._viewer_mouse_event( + self.viewer, {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) + mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) + + # (0, 0) on first image. + self.viewer.blink_once() + label_mouseover._viewer_mouse_event( + self.viewer, {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) + mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) + + lc_plugin.link_type = 'Pixels' + + # Both marks now get separated, so this means X and Y w.r.t. reference + # are different on both entries. + # 0.25 offset probably introduced by fake WCS layer. + assert_allclose(mp._obj.marks["imviz-0"].x, [1.25, 0.25]) + assert_allclose(mp._obj.marks["imviz-0"].y, 0.25) + + mp.clear_table() + mp._obj.plugin_opened = False + + +class TestNonDefaultOrientation(BaseImviz_WCS_WCS): + def test_N_up_multi_viewer(self): + lc_plugin = self.imviz.plugins['Orientation'] + lc_plugin.link_type = 'WCS' + + # Should automatically be applied as reference to first viewer. + lc_plugin._obj.create_north_up_east_left(set_on_create=True) + + # This would set a different reference to second viewer. + viewer_2 = self.imviz.create_image_viewer() + self.imviz.app.add_data_to_viewer("imviz-1", "has_wcs_1[SCI,1]") + lc_plugin.viewer = "imviz-1" + lc_plugin._obj.create_north_up_east_right(set_on_create=True) + + assert self.viewer.state.reference_data.label == "North-up, East-left" + assert viewer_2.state.reference_data.label == "North-up, East-right" + + # Both viewers should revert back to same reference when pixel-linked. + lc_plugin.link_type = 'Pixels' + assert self.viewer.state.reference_data.label == "has_wcs_1[SCI,1]" + assert viewer_2.state.reference_data.label == "has_wcs_1[SCI,1]" - lc_plugin.vue_reset_astrowidget_markers() + # FIXME: Brett, this seems wrong. I thought it would go back either + # to previous fake WCS layers or Default Orientation, but it is neither. + lc_plugin.link_type = 'WCS' + assert self.viewer.state.reference_data.label == "has_wcs_1[SCI,1]" + assert viewer_2.state.reference_data.label == "has_wcs_1[SCI,1]" - assert lc_plugin.need_clear_astrowidget_markers is False - lc_plugin.link_type.selected = 'WCS' + def test_custom_orientation(self): + lc_plugin = self.imviz.plugins['Orientation'] + lc_plugin.link_type = 'WCS' + lc_plugin.viewer = "imviz-0" + lc_plugin.rotation_angle = 42 # Triggers auto-label + lc_plugin._obj.add_orientation(rotation_angle=None, east_left=True, label=None, + set_on_create=True, wrt_data=None) + assert self.viewer.state.reference_data.label == "CCW 42.00 deg (E-left)" diff --git a/jdaviz/configs/imviz/tests/test_wcs_utils.py b/jdaviz/configs/imviz/tests/test_wcs_utils.py index 312f571d25..0db7de540f 100644 --- a/jdaviz/configs/imviz/tests/test_wcs_utils.py +++ b/jdaviz/configs/imviz/tests/test_wcs_utils.py @@ -10,7 +10,7 @@ from jdaviz.configs.imviz import wcs_utils from jdaviz.configs.imviz.helper import base_wcs_layer_label -from jdaviz.configs.imviz.tests.utils import BaseImviz_WCS_GWCS +from jdaviz.configs.imviz.tests.utils import BaseImviz_WCS_GWCS, create_example_gwcs def test_simple_fits_wcs(): @@ -161,3 +161,15 @@ def test_get_rotated_nddata_from_label_no_wcs(imviz_helper): imviz_helper.load_data(a, data_label="no_wcs") with pytest.raises(ValueError, match=r".*has no WCS for rotation"): wcs_utils._get_rotated_nddata_from_label(imviz_helper.app, "no_wcs", 0 * u.deg) + + +def test_compute_scale(): + # NOTE: compute_scale does not work with FITS WCS. + image_gwcs = create_example_gwcs((10, 10)) + fiducial = [197.8925, -1.36555556] * u.deg + + pixscale = wcs_utils.compute_scale(image_gwcs, fiducial, None) + assert_allclose(pixscale, 3.0555555555555554e-05) + + pixscale = wcs_utils.compute_scale(image_gwcs, fiducial, None, pscale_ratio=1e+5) + assert_allclose(pixscale, 3.0555555555555554) diff --git a/jdaviz/configs/imviz/wcs_utils.py b/jdaviz/configs/imviz/wcs_utils.py index 7dc17d81a5..be9b2b7dd8 100644 --- a/jdaviz/configs/imviz/wcs_utils.py +++ b/jdaviz/configs/imviz/wcs_utils.py @@ -564,7 +564,7 @@ def compute_scale(wcs, fiducial, disp_axis, pscale_ratio=1): """ spectral = 'SPECTRAL' in wcs.output_frame.axes_type - if spectral and disp_axis is None: + if spectral and disp_axis is None: # pragma: no cover raise ValueError('If input WCS is spectral, a disp_axis must be given') crpix = np.array(wcs.invert(*fiducial)) @@ -588,7 +588,7 @@ def compute_scale(wcs, fiducial, disp_axis, pscale_ratio=1): xscale *= pscale_ratio yscale *= pscale_ratio - if spectral: + if spectral: # pragma: no cover # Assuming scale doesn't change with wavelength # Assuming disp_axis is consistent with DataModel.meta.wcsinfo.dispersion.direction return yscale if disp_axis == 1 else xscale From 25c089ca9f93581f4c546a4da6cbbf76088f1a08 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Thu, 22 Feb 2024 14:48:39 -0500 Subject: [PATCH 2/8] TST: Use as_active context manager Co-authored-by: Kyle Conroy --- .../configs/imviz/tests/test_orientation.py | 70 +++++++++---------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/jdaviz/configs/imviz/tests/test_orientation.py b/jdaviz/configs/imviz/tests/test_orientation.py index bc94a68a5a..5cff91a6e4 100644 --- a/jdaviz/configs/imviz/tests/test_orientation.py +++ b/jdaviz/configs/imviz/tests/test_orientation.py @@ -52,29 +52,28 @@ def test_markers_plugin_recompute_positions_pixels_to_wcs(self): label_mouseover = self.imviz.app.session.application._tools['g-coords-info'] mp = self.imviz.plugins['Markers'] - mp._obj.plugin_opened = True - # (0, 0) on second image. - label_mouseover._viewer_mouse_event( - self.viewer, {'event': 'mousemove', 'domain': {'x': 1, 'y': 0}}) - mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) + with mp.as_active(): + # (0, 0) on second image. + label_mouseover._viewer_mouse_event( + self.viewer, {'event': 'mousemove', 'domain': {'x': 1, 'y': 0}}) + mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) - # (0, 0) on first image. - self.viewer.blink_once() - label_mouseover._viewer_mouse_event( - self.viewer, {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) - mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) + # (0, 0) on first image. + self.viewer.blink_once() + label_mouseover._viewer_mouse_event( + self.viewer, {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) + mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) - lc_plugin.link_type = 'WCS' + lc_plugin.link_type = 'WCS' - # Both marks stay the same in sky, so this means X and Y w.r.t. reference - # same on both entries. - # 0.25 offset probably introduced by fake WCS layer. - assert_allclose(mp._obj.marks["imviz-0"].x, -0.25) - assert_allclose(mp._obj.marks["imviz-0"].y, -0.25) + # Both marks stay the same in sky, so this means X and Y w.r.t. reference + # same on both entries. + # 0.25 offset probably introduced by fake WCS layer. + assert_allclose(mp._obj.marks["imviz-0"].x, -0.25) + assert_allclose(mp._obj.marks["imviz-0"].y, -0.25) - mp.clear_table() - mp._obj.plugin_opened = False + mp.clear_table() def test_markers_plugin_recompute_positions_wcs_to_pixels(self): lc_plugin = self.imviz.plugins['Orientation'] @@ -86,29 +85,28 @@ def test_markers_plugin_recompute_positions_wcs_to_pixels(self): label_mouseover = self.imviz.app.session.application._tools['g-coords-info'] mp = self.imviz.plugins['Markers'] - mp._obj.plugin_opened = True - # (0, 0) on second image, but linked by WCS. - label_mouseover._viewer_mouse_event( - self.viewer, {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) - mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) + with mp.as_active(): + # (0, 0) on second image, but linked by WCS. + label_mouseover._viewer_mouse_event( + self.viewer, {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) + mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) - # (0, 0) on first image. - self.viewer.blink_once() - label_mouseover._viewer_mouse_event( - self.viewer, {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) - mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) + # (0, 0) on first image. + self.viewer.blink_once() + label_mouseover._viewer_mouse_event( + self.viewer, {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) + mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) - lc_plugin.link_type = 'Pixels' + lc_plugin.link_type = 'Pixels' - # Both marks now get separated, so this means X and Y w.r.t. reference - # are different on both entries. - # 0.25 offset probably introduced by fake WCS layer. - assert_allclose(mp._obj.marks["imviz-0"].x, [1.25, 0.25]) - assert_allclose(mp._obj.marks["imviz-0"].y, 0.25) + # Both marks now get separated, so this means X and Y w.r.t. reference + # are different on both entries. + # 0.25 offset probably introduced by fake WCS layer. + assert_allclose(mp._obj.marks["imviz-0"].x, [1.25, 0.25]) + assert_allclose(mp._obj.marks["imviz-0"].y, 0.25) - mp.clear_table() - mp._obj.plugin_opened = False + mp.clear_table() class TestNonDefaultOrientation(BaseImviz_WCS_WCS): From 26a704aad25976fd1365419f10a535f3a965e3b2 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:12:14 -0500 Subject: [PATCH 3/8] Confirmed bug is follow-up issue. Add regression test for JDAT-3958 but cannot reproduce the failure. --- .../configs/imviz/tests/test_delete_data.py | 38 ++++++++++++++++++- .../configs/imviz/tests/test_orientation.py | 3 +- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/jdaviz/configs/imviz/tests/test_delete_data.py b/jdaviz/configs/imviz/tests/test_delete_data.py index fd39ea8cad..7cec59ea16 100644 --- a/jdaviz/configs/imviz/tests/test_delete_data.py +++ b/jdaviz/configs/imviz/tests/test_delete_data.py @@ -1,9 +1,12 @@ import numpy as np +from astropy.coordinates import Angle from astropy.nddata import NDData +from astropy.tests.helper import assert_quantity_allclose +from glue.core.message import DataCollectionDeleteMessage from numpy.testing import assert_allclose -from regions import PixCoord, CirclePixelRegion, RectanglePixelRegion +from regions import PixCoord, CirclePixelRegion, RectanglePixelRegion, EllipsePixelRegion -from jdaviz.configs.imviz.tests.utils import BaseImviz_WCS_WCS +from jdaviz.configs.imviz.tests.utils import BaseImviz_WCS_WCS, BaseImviz_WCS_GWCS class TestDeleteData(BaseImviz_WCS_WCS): @@ -71,3 +74,34 @@ def test_delete_with_subset_wcs(self): assert_allclose(subset2.subset_state.roi.ymin, 0, atol=1e-6) assert_allclose(subset2.subset_state.roi.xmax, 3) assert_allclose(subset2.subset_state.roi.ymax, 2) + + +class TestDeleteWCSLayerWithSubset(BaseImviz_WCS_GWCS): + """Regression test for https://jira.stsci.edu/browse/JDAT-3958""" + def test_delete_wcs_layer_with_subset(self): + lc_plugin = self.imviz.plugins['Orientation'] + lc_plugin.link_type = 'WCS' + + # Should automatically be applied as reference to first viewer. + lc_plugin._obj.create_north_up_east_left(set_on_create=True) + + # Create a rotated ellipse. + reg = EllipsePixelRegion( + PixCoord(3.5, 4.5), width=2, height=5, angle=Angle(30, 'deg')).to_sky(self.wcs_1) + self.imviz.load_regions(reg) + + # Switch back to Default Orientation. + self.imviz.app._change_reference_data("Default orientation") + + # Delete N-up E-left reference data. + self.imviz.app._on_data_deleted(DataCollectionDeleteMessage( + data=self.imviz.app.data_collection["North-up, East-left"], + sender=self.imviz.app.data_collection)) + + # Make sure rotated ellipse is still the same as before. + out_reg_d = self.imviz.app.get_subsets(include_sky_region=True)['Subset 1'][0]['sky_region'] + assert_allclose(reg.center.ra.deg, out_reg_d.center.ra.deg) + assert_allclose(reg.center.dec.deg, out_reg_d.center.dec.deg) + assert_quantity_allclose(reg.height, out_reg_d.height) + assert_quantity_allclose(reg.width, out_reg_d.width) + assert_quantity_allclose(reg.angle, out_reg_d.angle) diff --git a/jdaviz/configs/imviz/tests/test_orientation.py b/jdaviz/configs/imviz/tests/test_orientation.py index 5cff91a6e4..d56d657b16 100644 --- a/jdaviz/configs/imviz/tests/test_orientation.py +++ b/jdaviz/configs/imviz/tests/test_orientation.py @@ -131,8 +131,7 @@ def test_N_up_multi_viewer(self): assert self.viewer.state.reference_data.label == "has_wcs_1[SCI,1]" assert viewer_2.state.reference_data.label == "has_wcs_1[SCI,1]" - # FIXME: Brett, this seems wrong. I thought it would go back either - # to previous fake WCS layers or Default Orientation, but it is neither. + # FIXME: https://github.com/spacetelescope/jdaviz/issues/2724 lc_plugin.link_type = 'WCS' assert self.viewer.state.reference_data.label == "has_wcs_1[SCI,1]" assert viewer_2.state.reference_data.label == "has_wcs_1[SCI,1]" From 75a720ff257000d482c75589b76cfc0167840ca1 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:29:08 -0500 Subject: [PATCH 4/8] TST: Reproduce the reparenting failure. Co-authored-by: Ricky O'Steen <39831871+rosteen@users.noreply.github.com> --- jdaviz/configs/imviz/tests/test_delete_data.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/jdaviz/configs/imviz/tests/test_delete_data.py b/jdaviz/configs/imviz/tests/test_delete_data.py index 7cec59ea16..08d277fecd 100644 --- a/jdaviz/configs/imviz/tests/test_delete_data.py +++ b/jdaviz/configs/imviz/tests/test_delete_data.py @@ -2,7 +2,6 @@ from astropy.coordinates import Angle from astropy.nddata import NDData from astropy.tests.helper import assert_quantity_allclose -from glue.core.message import DataCollectionDeleteMessage from numpy.testing import assert_allclose from regions import PixCoord, CirclePixelRegion, RectanglePixelRegion, EllipsePixelRegion @@ -93,10 +92,8 @@ def test_delete_wcs_layer_with_subset(self): # Switch back to Default Orientation. self.imviz.app._change_reference_data("Default orientation") - # Delete N-up E-left reference data. - self.imviz.app._on_data_deleted(DataCollectionDeleteMessage( - data=self.imviz.app.data_collection["North-up, East-left"], - sender=self.imviz.app.data_collection)) + # Delete N-up E-left reference data from GUI. + self.imviz.app.vue_data_item_remove({"item_name": "North-up, East-left"}) # Make sure rotated ellipse is still the same as before. out_reg_d = self.imviz.app.get_subsets(include_sky_region=True)['Subset 1'][0]['sky_region'] From 1a2be307a4ae3997fe57f1a647b598813026fb5f Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:39:49 -0500 Subject: [PATCH 5/8] Mark test as xfail and turn xpass into failure. --- jdaviz/configs/imviz/tests/test_delete_data.py | 2 ++ pyproject.toml | 1 + 2 files changed, 3 insertions(+) diff --git a/jdaviz/configs/imviz/tests/test_delete_data.py b/jdaviz/configs/imviz/tests/test_delete_data.py index 08d277fecd..b4b6c99c64 100644 --- a/jdaviz/configs/imviz/tests/test_delete_data.py +++ b/jdaviz/configs/imviz/tests/test_delete_data.py @@ -1,4 +1,5 @@ import numpy as np +import pytest from astropy.coordinates import Angle from astropy.nddata import NDData from astropy.tests.helper import assert_quantity_allclose @@ -75,6 +76,7 @@ def test_delete_with_subset_wcs(self): assert_allclose(subset2.subset_state.roi.ymax, 2) +@pytest.mark.xfail(reason="FIXME: JDAT-3958") class TestDeleteWCSLayerWithSubset(BaseImviz_WCS_GWCS): """Regression test for https://jira.stsci.edu/browse/JDAT-3958""" def test_delete_wcs_layer_with_subset(self): diff --git a/pyproject.toml b/pyproject.toml index 2687363f61..38d256a80b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -124,6 +124,7 @@ astropy_header = true doctest_plus = "enabled" text_file_format = "rst" addopts = "--doctest-rst --import-mode=append" +xfail_strict = true filterwarnings = [ "error", "ignore:numpy\\.ufunc size changed:RuntimeWarning", From ccbab4e6b6f571df452de24df4398a8545b88240 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Mon, 26 Feb 2024 13:34:19 -0500 Subject: [PATCH 6/8] Update test with expected answers but this would fail the test, so catch the failures for now --- jdaviz/configs/imviz/tests/test_orientation.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jdaviz/configs/imviz/tests/test_orientation.py b/jdaviz/configs/imviz/tests/test_orientation.py index d56d657b16..ea480ff4b8 100644 --- a/jdaviz/configs/imviz/tests/test_orientation.py +++ b/jdaviz/configs/imviz/tests/test_orientation.py @@ -131,10 +131,12 @@ def test_N_up_multi_viewer(self): assert self.viewer.state.reference_data.label == "has_wcs_1[SCI,1]" assert viewer_2.state.reference_data.label == "has_wcs_1[SCI,1]" - # FIXME: https://github.com/spacetelescope/jdaviz/issues/2724 + # FIXME: spacetelescope/jdaviz#2724 (remove AssertionError) lc_plugin.link_type = 'WCS' - assert self.viewer.state.reference_data.label == "has_wcs_1[SCI,1]" - assert viewer_2.state.reference_data.label == "has_wcs_1[SCI,1]" + with pytest.raises(AssertionError): + assert self.viewer.state.reference_data.label == "Default orientation" + with pytest.raises(AssertionError): + assert viewer_2.state.reference_data.label == "Default orientation" def test_custom_orientation(self): lc_plugin = self.imviz.plugins['Orientation'] From 63b460be8283feba1cd30251320ca19d79163af8 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Tue, 27 Feb 2024 12:44:57 -0500 Subject: [PATCH 7/8] Fix comment in a test --- jdaviz/configs/imviz/tests/test_orientation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdaviz/configs/imviz/tests/test_orientation.py b/jdaviz/configs/imviz/tests/test_orientation.py index ea480ff4b8..2bab19b53d 100644 --- a/jdaviz/configs/imviz/tests/test_orientation.py +++ b/jdaviz/configs/imviz/tests/test_orientation.py @@ -54,7 +54,7 @@ def test_markers_plugin_recompute_positions_pixels_to_wcs(self): mp = self.imviz.plugins['Markers'] with mp.as_active(): - # (0, 0) on second image. + # (1, 0) on second image but same sky coordinates as (0, 0) on first. label_mouseover._viewer_mouse_event( self.viewer, {'event': 'mousemove', 'domain': {'x': 1, 'y': 0}}) mp._obj._on_viewer_key_event(self.viewer, {'event': 'keydown', 'key': 'm'}) From 0336005ec1c2018a3524b8f7bba10f27e13efc31 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:10:42 -0500 Subject: [PATCH 8/8] xfail roundtrip bug for fake GWCS --- jdaviz/configs/imviz/tests/test_orientation.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/jdaviz/configs/imviz/tests/test_orientation.py b/jdaviz/configs/imviz/tests/test_orientation.py index 2bab19b53d..2dbcd53928 100644 --- a/jdaviz/configs/imviz/tests/test_orientation.py +++ b/jdaviz/configs/imviz/tests/test_orientation.py @@ -69,9 +69,12 @@ def test_markers_plugin_recompute_positions_pixels_to_wcs(self): # Both marks stay the same in sky, so this means X and Y w.r.t. reference # same on both entries. - # 0.25 offset probably introduced by fake WCS layer. - assert_allclose(mp._obj.marks["imviz-0"].x, -0.25) - assert_allclose(mp._obj.marks["imviz-0"].y, -0.25) + # FIXME: 0.25 offset introduced by fake WCS layer (remove AssertionError). + # https://jira.stsci.edu/browse/JDAT-4256 + with pytest.raises(AssertionError): + assert_allclose(mp._obj.marks["imviz-0"].x, 0) + with pytest.raises(AssertionError): + assert_allclose(mp._obj.marks["imviz-0"].y, 0) mp.clear_table() @@ -102,9 +105,12 @@ def test_markers_plugin_recompute_positions_wcs_to_pixels(self): # Both marks now get separated, so this means X and Y w.r.t. reference # are different on both entries. - # 0.25 offset probably introduced by fake WCS layer. - assert_allclose(mp._obj.marks["imviz-0"].x, [1.25, 0.25]) - assert_allclose(mp._obj.marks["imviz-0"].y, 0.25) + # FIXME: 0.25 offset introduced by fake WCS layer (remove AssertionError). + # https://jira.stsci.edu/browse/JDAT-4256 + with pytest.raises(AssertionError): + assert_allclose(mp._obj.marks["imviz-0"].x, [1, 0]) + with pytest.raises(AssertionError): + assert_allclose(mp._obj.marks["imviz-0"].y, 0) mp.clear_table()