Skip to content

Commit

Permalink
BUG: Avoid crashing when line list is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed May 16, 2022
1 parent cac9374 commit 48899e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Specviz
Bug Fixes
---------

- Line Lists plugin no longer crashes when a list is removed under
certain conditions. [#1318]

Cubeviz
^^^^^^^

Expand Down
7 changes: 5 additions & 2 deletions jdaviz/configs/default/plugins/line_lists/line_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 48899e9

Please sign in to comment.