Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename subsets hack #6

Open
wants to merge 4 commits into
base: subset-rename-2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
3 changes: 2 additions & 1 deletion jdaviz/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down