Skip to content

Commit

Permalink
handle case of empty cached slice values
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed May 28, 2024
1 parent af6966b commit 11d4f70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jdaviz/configs/cubeviz/plugins/slice/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def _initialize_location(self, *args):
if str(viewer.state.x_att) not in self.valid_slice_att_names:
# avoid setting value to degs, before x_att is changed to wavelength, for example
continue
# ensure the cache is reset (if previous attempts to initialize failed resulting in an
# empty list as the cache)
viewer._clear_cache('slice_values')
slice_values = viewer.slice_values
if len(slice_values):
self.value = slice_values[int(len(slice_values)/2)]
Expand Down
1 change: 1 addition & 0 deletions jdaviz/configs/cubeviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def _get_component(layer):
return np.asarray(np.unique(np.concatenate([_get_component(layer) for layer in self.layers])), # noqa
dtype=float)
except ValueError:
# NOTE: this will result in caching an empty list
return np.array([])

def _set_slice_indicator_value(self, value):
Expand Down

0 comments on commit 11d4f70

Please sign in to comment.