diff --git a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py index 64bda12fb1..796223fc38 100644 --- a/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py +++ b/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py @@ -52,9 +52,11 @@ def test_fits_image_hdu_with_microns(image_cube_hdu_obj_microns, cubeviz_helper) unc_viewer = cubeviz_helper.app.get_viewer('uncert-viewer') label_mouseover._viewer_mouse_event(unc_viewer, {'event': 'mousemove', 'domain': {'x': -1, 'y': 0}}) - assert label_mouseover.as_text() == ('Pixel x=-1.0 y=00.0', - 'World 13h41m45.5759s +27d00m12.3044s (ICRS)', - '205.4398995981 27.0034178810 (deg)') # noqa + assert label_mouseover.as_text()[0] == 'Pixel x=-1.0 y=00.0' # Out of bounds + # remaining lines are unvalidated, + # see https://github.com/spacetelescope/jdaviz/pull/1976#discussion_r1093199919 + # 'World 13h41m45.5759s +27d00m12.3044s (ICRS)', + # '205.4398995981 27.0034178810 (deg)') # noqa def test_spectrum1d_with_fake_fixed_units(spectrum1d, cubeviz_helper): @@ -115,7 +117,7 @@ def test_fits_image_hdu_parse_from_file(tmpdir, image_cube_hdu_obj, cubeviz_help unc_viewer = cubeviz_helper.app.get_viewer(cubeviz_helper._default_uncert_viewer_reference_name) label_mouseover._viewer_mouse_event(unc_viewer, {'event': 'mousemove', 'domain': {'x': -1, 'y': 0}}) - assert label_mouseover.as_text() == ('Pixel x=-1.0 y=00.0', + assert label_mouseover.as_text() == ('Pixel x=-1.0 y=00.0', # Out of bounds 'World 13h41m46.5994s +26d59m58.6136s (ICRS)', '205.4441642302 26.9996148973 (deg)') # noqa diff --git a/jdaviz/configs/imviz/plugins/coords_info/coords_info.py b/jdaviz/configs/imviz/plugins/coords_info/coords_info.py index 8b52b01bff..7053991d2e 100644 --- a/jdaviz/configs/imviz/plugins/coords_info/coords_info.py +++ b/jdaviz/configs/imviz/plugins/coords_info/coords_info.py @@ -114,7 +114,7 @@ def _viewer_mouse_clear_event(self, viewer, data=None): marks.visible = False def _viewer_mouse_event(self, viewer, data): - if data['event'] in ['mouseleave', 'mouseenter']: + if data['event'] in ('mouseleave', 'mouseenter'): return self._viewer_mouse_clear_event(viewer, data) if len(self.app.data_collection) < 1: @@ -143,8 +143,6 @@ def _layers_changed(self, viewer): self.update_display(viewer, self._x, self._y) def update_display(self, viewer, x, y): - """ - """ if isinstance(viewer, SpecvizProfileView): self._spectrum_viewer_update(viewer, x, y) elif isinstance(viewer, diff --git a/jdaviz/configs/imviz/tests/test_linking.py b/jdaviz/configs/imviz/tests/test_linking.py index 5728e74160..9c3597a84d 100644 --- a/jdaviz/configs/imviz/tests/test_linking.py +++ b/jdaviz/configs/imviz/tests/test_linking.py @@ -164,13 +164,11 @@ def test_wcslink_affine_with_extras(self): {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) -# assert label_mouseover.as_text() == ('Pixel x=00.0 y=00.0 Value +1.00000e+00', -# 'World 22h30m04.8674s -20d49m59.9990s (ICRS)', -# '337.5202808000 -20.8333330600 (deg)') -# for some reason getting: -# ('Pixel x=01.0 y=-0.0 Value +1.00000e+00', -# 'World 22h30m04.8674s -20d49m59.9990s (ICRS)', -# '337.5202808000 -20.8333330600 (deg)') + lmtext = label_mouseover.as_text() + assert lmtext[0] in ('Pixel x=01.0 y=00.0 Value +1.00000e+00', + 'Pixel x=01.0 y=-0.0 Value +1.00000e+00') + assert lmtext[1:] == ('World 22h30m04.8674s -20d49m59.9990s (ICRS)', + '337.5202808000 -20.8333330600 (deg)') # blink image through clicking with blink tool self.viewer.toolbar.active_tool_id = 'jdaviz:blinkonce' @@ -286,12 +284,11 @@ def test_wcslink_offset(self): label_mouseover = self.imviz.app.session.application._tools['g-coords-info'] label_mouseover._viewer_mouse_event(self.viewer, {'event': 'mousemove', 'domain': {'x': 10, 'y': 3}}) - assert label_mouseover.as_text() in [('Pixel x=07.0 y=00.0 Value +0.00000e+00', - 'World 00h14m19.6291s -30d23m30.9692s (ICRS)', - '3.5817877198 -30.3919358920 (deg)'), - ('Pixel x=07.0 y=-0.0 Value +0.00000e+00', - 'World 00h14m19.6291s -30d23m30.9692s (ICRS)', - '3.5817877198 -30.3919358920 (deg)')] + lmtext = label_mouseover.as_text() + assert lmtext[0] in ('Pixel x=07.0 y=00.0 Value +0.00000e+00', + 'Pixel x=07.0 y=-0.0 Value +0.00000e+00') + assert lmtext[1:] == ('World 00h14m19.6291s -30d23m30.9692s (ICRS)', + '3.5817877198 -30.3919358920 (deg)') assert label_mouseover.row1_unreliable assert label_mouseover.row2_unreliable @@ -349,9 +346,11 @@ def test_pixel_linking(self): label_mouseover._viewer_mouse_event(self.viewer, {'event': 'keydown', 'key': 'b', 'domain': {'x': -1, 'y': -1}}) + self.viewer.on_mouse_or_key_event({'event': 'keydown', 'key': 'b', + 'domain': {'x': -1, 'y': -1}}) assert label_mouseover.as_text() == ('Pixel x=-1.0 y=-1.0', - 'World 00h14m19.5987s -30d23m31.0683s (ICRS)', - '3.5816611274 -30.3919634282 (deg)') + 'World 00h14m19.5829s -30d23m30.9860s (ICRS)', + '3.5815955408 -30.3919405616 (deg)') assert not label_mouseover.row1_unreliable assert label_mouseover.row2_unreliable assert label_mouseover.row3_unreliable diff --git a/jdaviz/configs/mosviz/tests/test_data_loading.py b/jdaviz/configs/mosviz/tests/test_data_loading.py index 19fc937ffa..64b968625f 100644 --- a/jdaviz/configs/mosviz/tests/test_data_loading.py +++ b/jdaviz/configs/mosviz/tests/test_data_loading.py @@ -162,7 +162,7 @@ def test_load_single_image_multi_spec(mosviz_helper, mos_image, spectrum1d, mos_ # Coordinates info panel should not crash even when nothing is loaded. label_mouseover = mosviz_helper.app.session.application._tools['g-coords-info'] - label_mouseover._viewer_mouse_event(image_viewer, {'event': 'mouseover', + label_mouseover._viewer_mouse_event(image_viewer, {'event': 'mousemove', 'domain': {'x': 0, 'y': 0}}) assert label_mouseover.as_text() == ('', '', '') @@ -214,9 +214,11 @@ def test_load_single_image_multi_spec(mosviz_helper, mos_image, spectrum1d, mos_ assert label_mouseover.as_text() == ('Pixel x=00010.0 y=00100.0 Value +8.12986e-01', '', '') assert label_mouseover.icon == 'b' + # need to trigger a mouseleave or mouseover to reset the traitlets + label_mouseover._viewer_mouse_event(spec1d_viewer, {'event': 'mouseenter'}) label_mouseover._viewer_mouse_event(spec1d_viewer, {'event': 'mousemove', 'domain': {'x': 7000, 'y': 170}}) - assert label_mouseover.as_text() == ('Cursor 7.00000e+03, 1.70000e+02 Value +8.12986e-01', + assert label_mouseover.as_text() == ('Cursor 7.00000e+03, 1.70000e+02', 'Wave 6.88889e+03 Angstrom (4 pix)', 'Flux 1.35436e+01 Jy') assert label_mouseover.icon == 'c' diff --git a/jdaviz/configs/specviz2d/tests/test_parsers.py b/jdaviz/configs/specviz2d/tests/test_parsers.py index b31d8fea2a..9ba04f513d 100644 --- a/jdaviz/configs/specviz2d/tests/test_parsers.py +++ b/jdaviz/configs/specviz2d/tests/test_parsers.py @@ -78,9 +78,11 @@ def test_2d_parser_no_unit(specviz2d_helper, mos_spectrum2d): assert label_mouseover.icon == 'a' viewer_1d = specviz2d_helper.app.get_viewer('spectrum-viewer') + # need to trigger a mouseleave or mouseover to reset the traitlets + label_mouseover._viewer_mouse_event(viewer_1d, {'event': 'mouseenter'}) label_mouseover._viewer_mouse_event(viewer_1d, {'event': 'mousemove', 'domain': {'x': 6.5, 'y': 3}}) - assert label_mouseover.as_text() == ('Cursor 6.50000e+00, 3.00000e+00 Value +3.74540e-01', + assert label_mouseover.as_text() == ('Cursor 6.50000e+00, 3.00000e+00', 'Wave 6.00000e+00 pix', 'Flux -3.59571e+00') assert label_mouseover.icon == 'b'