From f41f4af4741c9dd62f50a4bcfb060c2556d1c854 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:30:37 -0500 Subject: [PATCH] BUG: Not all viewers have get_limits (#3361) Add test and change log. Test was proven to fail on main locally. --- CHANGES.rst | 2 ++ .../plugins/plot_options/tests/test_plot_options.py | 9 +++++++++ jdaviz/core/tools.py | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 8d58281fed..3f12ee4ab3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -70,6 +70,8 @@ Bug Fixes occured when certain flux-to flux-conversions occured, as well as certain conversions between flux and surface brightness. This PR also fixed an issue with unit string formatting in the aperture photometry plugin. [#3228] +- Fixed broken histogram pan/zoom in Plot Options plugin. [#3361] + Cubeviz ^^^^^^^ - Removed the deprecated ``save as fits`` option from the Collapse, Moment Maps, and Spectral Extraction plugins; use the Export plugin instead. [#3256] diff --git a/jdaviz/configs/default/plugins/plot_options/tests/test_plot_options.py b/jdaviz/configs/default/plugins/plot_options/tests/test_plot_options.py index a72b31c30b..0d0781ae57 100644 --- a/jdaviz/configs/default/plugins/plot_options/tests/test_plot_options.py +++ b/jdaviz/configs/default/plugins/plot_options/tests/test_plot_options.py @@ -137,6 +137,15 @@ def test_stretch_histogram(cubeviz_helper, spectrum1d_cube_with_uncerts): assert po.stretch_histogram.marks['vmin'].x[0] == po.stretch_vmin.value assert po.stretch_histogram.marks['vmax'].x[0] == po.stretch_vmax.value + # Make sure some tools work + + po_panzoom = po.stretch_histogram.toolbar.tools["jdaviz:panzoom"] + po_panzoom.activate() + po_panzoom.deactivate() + + po_prevzoom = po.stretch_histogram.toolbar.tools["jdaviz:prevzoom"] + po_prevzoom.activate() + @pytest.mark.filterwarnings('ignore') def test_user_api(cubeviz_helper, spectrum1d_cube): diff --git a/jdaviz/core/tools.py b/jdaviz/core/tools.py index 71e0b9f53e..7a6f68542e 100644 --- a/jdaviz/core/tools.py +++ b/jdaviz/core/tools.py @@ -40,7 +40,10 @@ class _BaseZoomHistory: # Mixin for custom zoom tools to be able to save their previous zoom state # which is then used by the PrevZoom tool def save_prev_zoom(self): - self.viewer._prev_limits = self.viewer.get_limits() + # Cannot use viewer.get_limits() here because viewers from + # glue-jupyter does not have that method. + self.viewer._prev_limits = (self.viewer.state.x_min, self.viewer.state.x_max, + self.viewer.state.y_min, self.viewer.state.y_max) class _MatchedZoomMixin: