Skip to content

Commit

Permalink
Merge pull request #1318 from pllim/line-list-no-crash-on-del
Browse files Browse the repository at this point in the history
BUG: Avoid crashing when line list is removed
  • Loading branch information
pllim authored May 17, 2022
2 parents 926623e + ce7205f commit bfa615e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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,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"
Expand Down

0 comments on commit bfa615e

Please sign in to comment.