From a5134564d40d6dfdd6310c43f30c5a689700441a Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Tue, 24 Jan 2023 14:50:07 -0500 Subject: [PATCH] Backport PR #1971: BUG: Home after markers no longer crash Imviz --- CHANGES.rst | 2 ++ jdaviz/configs/imviz/tests/test_astrowidgets_api.py | 4 ++++ jdaviz/core/freezable_state.py | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index c5479d311e..85d253c933 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,8 @@ Cubeviz Imviz ^^^^^ +- Fixed crashing when clicking Home button after markers are added. [#1971] + Mosviz ^^^^^^ diff --git a/jdaviz/configs/imviz/tests/test_astrowidgets_api.py b/jdaviz/configs/imviz/tests/test_astrowidgets_api.py index 95d8aff1a0..434c1f9c23 100644 --- a/jdaviz/configs/imviz/tests/test_astrowidgets_api.py +++ b/jdaviz/configs/imviz/tests/test_astrowidgets_api.py @@ -323,6 +323,10 @@ def test_mvp_markers(self): # TODO: How to check imviz.app.data_collection.links is correct? assert len(self.imviz.app.data_collection.links) == 14 + # Just want to make sure nothing crashes. Zooming already testing elsewhere. + # https://github.com/spacetelescope/jdaviz/pull/1971 + self.viewer.zoom_level = 'fit' + # Remove markers with default name. self.viewer.remove_markers() assert self.imviz.app.data_collection.labels == [ diff --git a/jdaviz/core/freezable_state.py b/jdaviz/core/freezable_state.py index f1ec76a08e..58d24c5f4b 100644 --- a/jdaviz/core/freezable_state.py +++ b/jdaviz/core/freezable_state.py @@ -88,7 +88,7 @@ def reset_limits(self, *event): x_min, x_max = -0.5, -np.inf y_min, y_max = -0.5, -np.inf for layer in self.layers: - if not layer.visible: + if not layer.visible or layer.layer.data.ndim == 1: continue pixel_ids = layer.layer.pixel_component_ids