diff --git a/CHANGES.rst b/CHANGES.rst index 4db97dc98d..d63adc1f0d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -43,6 +43,9 @@ Specviz Bug Fixes --------- +- Line Lists plugin no longer crashes when a list is removed under + certain conditions. [#1318] + Cubeviz ^^^^^^^ diff --git a/jdaviz/configs/default/plugins/line_lists/line_lists.py b/jdaviz/configs/default/plugins/line_lists/line_lists.py index e9adb96f77..4e6bfb0c80 100644 --- a/jdaviz/configs/default/plugins/line_lists/line_lists.py +++ b/jdaviz/configs/default/plugins/line_lists/line_lists.py @@ -772,8 +772,11 @@ def vue_remove_list(self, listname): self.list_contents = {k: v for k, v in self.list_contents.items() if k != listname} row_inds = [i for i, ln in enumerate(self._viewer.spectral_lines['listname']) - if ln == listname] - self._viewer.spectral_lines.remove_rows(row_inds) + if ln != listname] + if len(row_inds) == 0: + self._viewer.spectral_lines = None + else: + self._viewer.spectral_lines = self._viewer.spectral_lines[row_inds] def vue_remove_line(self, line, erase=True): """ diff --git a/jdaviz/configs/default/plugins/line_lists/tests/test_line_lists.py b/jdaviz/configs/default/plugins/line_lists/tests/test_line_lists.py index c4b35b95a4..975906e53f 100644 --- a/jdaviz/configs/default/plugins/line_lists/tests/test_line_lists.py +++ b/jdaviz/configs/default/plugins/line_lists/tests/test_line_lists.py @@ -73,6 +73,14 @@ def test_redshift(specviz_helper, spectrum1d): 'obs_new': 5508}) assert_allclose(line['obs'], 5508) + # https://github.com/spacetelescope/jdaviz/issues/1168 + ll_plugin.vue_set_identify(('Test List', line, 0)) + ll_plugin.vue_remove_list('Test List') + assert ll_plugin._viewer.spectral_lines is None + + # TODO: The label is cleared in GUI but fails this test. + # assert ll_plugin.identify_label == '' + def test_line_identify(specviz_helper, spectrum1d): label = "Test 1D Spectrum"