diff --git a/CHANGES.rst b/CHANGES.rst index a6d98771a2..d394e4e54d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -45,6 +45,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..1db7d2d968 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,12 @@ 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 + assert ll_plugin.identify_label == '' + def test_line_identify(specviz_helper, spectrum1d): label = "Test 1D Spectrum"