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

Remove hard coded 'Subset' string checks #2611

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,8 @@
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
else:
Expand Down Expand Up @@ -2047,27 +2048,27 @@

def _get_continuum(self, dataset, spatial_subset, spectral_subset, update_marks=False):
if dataset.selected == '':
self._update_continuum_marks()
return None, None, None

Check warning on line 2052 in jdaviz/core/template_mixin.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/core/template_mixin.py#L2051-L2052

Added lines #L2051 - L2052 were not covered by tests

if spatial_subset == 'per-pixel':
if self.app.config != 'cubeviz':
raise ValueError("per-pixel only supported for cubeviz")

Check warning on line 2056 in jdaviz/core/template_mixin.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/core/template_mixin.py#L2056

Added line #L2056 was not covered by tests
full_spectrum = self.dataset.selected_obj
else:
full_spectrum = dataset.selected_spectrum_for_spatial_subset(spatial_subset.selected if spatial_subset is not None else None, # noqa
use_display_units=True)

if full_spectrum is None or self.continuum_width == "":
self._update_continuum_marks()
return None, None, None

Check warning on line 2064 in jdaviz/core/template_mixin.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/core/template_mixin.py#L2063-L2064

Added lines #L2063 - L2064 were not covered by tests

spectral_axis = full_spectrum.spectral_axis
if spectral_axis.unit == u.pix:
# plugin should be disabled so not get this far, but can still get here
# before the disabled message is set
self._update_continuum_marks()
return None, None, None

Check warning on line 2071 in jdaviz/core/template_mixin.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/core/template_mixin.py#L2070-L2071

Added lines #L2070 - L2071 were not covered by tests

if self.continuum_subset_selected == spectral_subset.selected:
# already raised a validation error in the UI
Expand Down Expand Up @@ -2144,7 +2145,7 @@
spectral_axis_nanmasked = spectral_axis.value.copy()
spectral_axis_nanmasked[~continuum_mask] = np.nan
if not update_marks:
pass

Check warning on line 2148 in jdaviz/core/template_mixin.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/core/template_mixin.py#L2148

Added line #L2148 was not covered by tests
elif spectral_subset.selected == "Entire Spectrum":
mark_x = {'left': spectral_axis_nanmasked,
'center': spectral_axis.value,
Expand Down
Loading