From fdb3ae915bf166fd23da3cad1a49efb6f6a75c79 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 1 Sep 2023 15:13:39 -0400 Subject: [PATCH] (disabled) ability to "freeze" subsets by converting to masks fix event handling for choosing config from launcher filepath fallback when object from config-detection fails to load fix: support for notebook 7 (#2420) Notebook 7 requires a different way to detect if the app runs in a notebook context. Fix explanation in markdown cell. DOC: Footprints plugin API docs (#2426) * build footprints API docs * add code snippet in plugin docs * fix syntax in API docs --------- Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com> prevent overwriting user-API methods (#2425) fix default color for overlay when traitlet set by user * for the FIRST overlay, the user could have set the color traitlet before the internal overlay object is created (which occurs as soon as the plugin is first shown). In that case, we want to respect the user choice of color. similar fixes for any other traitlet when plugin inactive regression test change log entry fix API import of single region and overwriting existing entry * along with regression testing TST: Also pull in scikit-image dev to get rid of incompatibility with numpy Use new "true circle" tool from glue-jupyter (#2332) * Use truecircle tool from https://github.com/glue-viz/glue-jupyter/pull/376 * MNT: Bump glue-jupyter minversion that can use this new tool * Add change log * Fix line too long * Fix change log verbiage Co-authored-by: Kyle Conroy --------- Co-authored-by: Kyle Conroy Enable multiselect in subset plugin for recentering (#2430) * Enable multiselect in subset plugin for recentering * Fix bug with default text * Remove unused import * Fix bug in aperature photometry * Address review comments * Remove commented out code * Add initial tests * Fix bug when exiting multiselect and switching subsets * Add documentation and update CHANGES file * Remove print statement * Add comment about recentering taking multiple iterations to docs * fix chip styling in subset dropdown * only set selected_has_subregions if exists * only show multiselect toggle in imviz * Apply suggestions from code review Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com> --------- Co-authored-by: Kyle Conroy Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com> Debug standalone build (#2441) * Log jdaviz output for debugging * Run workflow on debugging branch * See if collecting data from jupyter-client will fix this, otherwise might need to downgrade * Remove debugging stuff MNT: Bump actions/checkout to v4 Enable workflow_dispatch for standalone because it cannot be enabled outside of main apparently [ci skip] [rtd skip] EXP: Update workflow versions Fix Mosviz slit overlay (#2434) * Fix Mosviz slit overlay by using polygon instead of forcing a rectangle without angle info. Co-authored-by: Camilla Pacifici * Off by one error in predicted PR num --------- Co-authored-by: Camilla Pacifici API access (hidden) to disable cubeviz movie UI (#2440) * (hidden) API access to disable cubeviz movie UI * default movie_enabled based on new app-setting server_is_remote * test coverage TST: Ignore ASDF warning about gwcs-1.0.0 schema because gwcs dev and/or asdf-wcs-schemas 0.2.0 triggers the warning because the schema is no longer supported. --- .../plugins/subset_plugin/subset_plugin.py | 52 ++++++++++++++++++- .../plugins/subset_plugin/subset_plugin.vue | 13 +++-- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/jdaviz/configs/default/plugins/subset_plugin/subset_plugin.py b/jdaviz/configs/default/plugins/subset_plugin/subset_plugin.py index b1e00c65ef..9b84929adb 100644 --- a/jdaviz/configs/default/plugins/subset_plugin/subset_plugin.py +++ b/jdaviz/configs/default/plugins/subset_plugin/subset_plugin.py @@ -7,8 +7,9 @@ from glue.core.message import EditSubsetMessage, SubsetUpdateMessage from glue.core.edit_subset_mode import (AndMode, AndNotMode, OrMode, ReplaceMode, XorMode) +from glue.core.exceptions import IncompatibleAttribute from glue.core.roi import CircularROI, CircularAnnulusROI, EllipticalROI, RectangularROI -from glue.core.subset import RoiSubsetState, RangeSubsetState, CompositeSubsetState +from glue.core.subset import SubsetState, RoiSubsetState, RangeSubsetState, CompositeSubsetState from glue.icons import icon_path from glue_jupyter.widgets.subset_mode_vuetify import SelectionModeMenu from glue_jupyter.common.toolbar_vuetify import read_icon @@ -32,6 +33,44 @@ } +class MultiMaskSubsetState(SubsetState): + """ + A subset state that can include a different mask for different datasets. + Adopted from https://github.com/glue-viz/glue/pull/2415 + + Parameters + ---------- + masks : dict + A dictionary mapping data UUIDs to boolean arrays with the same + dimensions as the data arrays. + """ + + def __init__(self, masks=None): + super(MultiMaskSubsetState, self).__init__() + self._masks = masks + + def to_mask(self, data, view=None): + if data.uuid in self._masks: + mask = self._masks[data.uuid] + if view is not None: + mask = mask[view] + return mask + else: + raise IncompatibleAttribute() + + def copy(self): + return MultiMaskSubsetState(masks=self._masks) + + def __gluestate__(self, context): + serialized = {key: context.do(value) for key, value in self._masks.items()} + return {'masks': serialized} + + @classmethod + def __setgluestate__(cls, rec, context): + masks = {key: context.object(value) for key, value in rec['masks'].items()} + return cls(masks=masks) + + @tray_registry('g-subset-plugin', label="Subset Tools") class SubsetPlugin(PluginTemplateMixin, DatasetSelectMixin): template_file = __file__, "subset_plugin.vue" @@ -51,6 +90,7 @@ class SubsetPlugin(PluginTemplateMixin, DatasetSelectMixin): multiselect = Bool(False).tag(sync=True) is_centerable = Bool(False).tag(sync=True) can_simplify = Bool(False).tag(sync=True) + can_freeze = Bool(False).tag(sync=True) icon_replace = Unicode(read_icon(os.path.join(icon_path("glue_replace", icon_format="svg")), 'svg+xml')).tag(sync=True) # noqa icon_or = Unicode(read_icon(os.path.join(icon_path("glue_or", icon_format="svg")), 'svg+xml')).tag(sync=True) # noqa @@ -258,6 +298,16 @@ def _get_subset_definition(self, *args): self._unpack_get_subsets_for_ui() + def vue_freeze_subset(self, *args): + sgs = {sg.label: sg for sg in self.app.data_collection.subset_groups} + sg = sgs.get(self.subset_selected) + + masks = {} + for data in self.app.data_collection: + masks[data.uuid] = sg.subset_state.to_mask(data) + + sg.subset_state = MultiMaskSubsetState(masks) + def vue_simplify_subset(self, *args): if self.multiselect: self.hub.broadcast(SnackbarMessage("Cannot simplify spectral subset " diff --git a/jdaviz/configs/default/plugins/subset_plugin/subset_plugin.vue b/jdaviz/configs/default/plugins/subset_plugin/subset_plugin.vue index 14060d4135..36284ed71f 100644 --- a/jdaviz/configs/default/plugins/subset_plugin/subset_plugin.vue +++ b/jdaviz/configs/default/plugins/subset_plugin/subset_plugin.vue @@ -113,10 +113,13 @@ - - Simplify - - Update - + + Freeze + + + Simplify + + Update +