diff --git a/jdaviz/app.py b/jdaviz/app.py index 92b419e3ee..1e629fae2f 100644 --- a/jdaviz/app.py +++ b/jdaviz/app.py @@ -1899,13 +1899,14 @@ def vue_data_item_remove(self, event): # the reference data (which would leave 0 external_links). if len(self.data_collection) > 1 and len(self.data_collection.external_links) == 0: if self.config == "imviz" and imviz_refdata: + subset_labels = [sg.label for sg in self.data_collection.subset_groups] link_type = self._jdaviz_helper.plugins["Links Control"].link_type.selected.lower() self._jdaviz_helper.link_data(link_type=link_type, error_on_fail=True) # Hack to restore responsiveness to imviz layers for viewer_ref in self.get_viewer_reference_names(): viewer = self.get_viewer(viewer_ref) loaded_layers = [layer.layer.label for layer in viewer.layers if - "Subset" not in layer.layer.label] + layer.layer.label not in subset_labels] if len(loaded_layers): self.remove_data_from_viewer(viewer_ref, loaded_layers[-1]) self.add_data_to_viewer(viewer_ref, loaded_layers[-1]) diff --git a/jdaviz/core/helpers.py b/jdaviz/core/helpers.py index d3b2dddd13..2ceff9f408 100644 --- a/jdaviz/core/helpers.py +++ b/jdaviz/core/helpers.py @@ -865,7 +865,8 @@ def get_interactive_regions(self): # TODO: Remove this when Jdaviz support round-tripping, see # https://github.com/spacetelescope/jdaviz/pull/721 - if not subset_label.startswith('Subset'): + + if subset_label not in [sg.label for sg in self.app.data_collection.subset_groups]: continue try: diff --git a/jdaviz/core/template_mixin.py b/jdaviz/core/template_mixin.py index 88e980f242..7a5b86ce54 100644 --- a/jdaviz/core/template_mixin.py +++ b/jdaviz/core/template_mixin.py @@ -1670,9 +1670,15 @@ def _delete_subset(self, subset): def _is_valid_item(self, subset): def is_spectral(subset): + if isinstance(subset, dict) and "type" in subset.keys(): + if subset["type"] == "spectral": + return True return get_subset_type(subset) == 'spectral' def is_spatial(subset): + if isinstance(subset, dict) and "type" in subset.keys(): + if subset["type"] == "spatial": + return True return get_subset_type(subset) == 'spatial' def is_not_composite(subset): @@ -1704,7 +1710,8 @@ def _update_subset(self, subset, attribute=None): if subset.label not in self.labels: # NOTE: this logic will need to be revisited if generic renaming of subsets is added # see https://github.com/spacetelescope/jdaviz/pull/1175#discussion_r829372470 - if subset.label.startswith('Subset') and self._is_valid_item(subset): + dc_subset_labels = [sg.label for sg in self.app.data_collection.subset_groups] + if subset.label in dc_subset_labels and self._is_valid_item(subset): # NOTE: += will not trigger traitlet update self.items = self.items + [self._subset_to_dict(subset)] # noqa