From c1b38785f882b5fc727f33f3d4f4b5e88482ad0f Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 13 Dec 2024 13:31:51 -0500 Subject: [PATCH] fix test failures --- .../default/plugins/data_quality/data_quality.py | 2 +- .../default/plugins/subset_tools/subset_tools.py | 14 +++++++------- .../default/plugins/subset_tools/subset_tools.vue | 2 +- .../configs/imviz/plugins/footprints/footprints.py | 3 ++- jdaviz/configs/mosviz/helper.py | 2 +- jdaviz/core/template_mixin.py | 12 ++++++++++-- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/jdaviz/configs/default/plugins/data_quality/data_quality.py b/jdaviz/configs/default/plugins/data_quality/data_quality.py index e432e7b133..10ad8619f6 100644 --- a/jdaviz/configs/default/plugins/data_quality/data_quality.py +++ b/jdaviz/configs/default/plugins/data_quality/data_quality.py @@ -142,7 +142,7 @@ def update_dq_layer(self, *args): return self.dq_layer.filter_is_child_of = self.science_layer_selected - self.dq_layer._update_layer_items() + self.dq_layer._update_items() # listen for changes on the image opacity, and update the # data quality layer opacity on changes to the science layer opacity diff --git a/jdaviz/configs/default/plugins/subset_tools/subset_tools.py b/jdaviz/configs/default/plugins/subset_tools/subset_tools.py index 930eb5444f..4e9dc5290a 100644 --- a/jdaviz/configs/default/plugins/subset_tools/subset_tools.py +++ b/jdaviz/configs/default/plugins/subset_tools/subset_tools.py @@ -116,8 +116,8 @@ class SubsetTools(PluginTemplateMixin): icon_radialtocheck = Unicode(read_icon(os.path.join(ICON_DIR, 'radialtocheck.svg'), 'svg+xml')).tag(sync=True) # noqa icon_checktoradial = Unicode(read_icon(os.path.join(ICON_DIR, 'checktoradial.svg'), 'svg+xml')).tag(sync=True) # noqa - combination_items = List([]).tag(sync=True) - combination_selected = Any().tag(sync=True) + combination_mode_items = List([]).tag(sync=True) + combination_mode_selected = Any().tag(sync=True) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -160,8 +160,8 @@ def __init__(self, *args, **kwargs): multiselect=None) self.combination_mode = SelectPluginComponent(self, - items='combination_items', - selected='combination_selected', + items='combination_mode_items', + selected='combination_mode_selected', manual_options=COMBO_OPTIONS) @property @@ -1125,11 +1125,11 @@ def _load_regions(self, regions, combination_mode=None, max_num_regions=None, if return_bad_regions: return bad_regions - @observe('combination_selected') - def _combination_selected_updated(self, change): + @observe('combination_mode_selected') + def _combination_mode_selected_updated(self, change): self.app.session.edit_subset_mode.mode = SUBSET_MODES_PRETTY[change['new']] def _update_combination_mode(self): if self.app.session.edit_subset_mode.mode in SUBSET_TO_PRETTY.keys(): - self.combination_mode.selected = SUBSET_TO_PRETTY[ + self.combination_mode_selected = SUBSET_TO_PRETTY[ self.app.session.edit_subset_mode.mode] diff --git a/jdaviz/configs/default/plugins/subset_tools/subset_tools.vue b/jdaviz/configs/default/plugins/subset_tools/subset_tools.vue index 7055a0b45a..d6c16dd72d 100644 --- a/jdaviz/configs/default/plugins/subset_tools/subset_tools.vue +++ b/jdaviz/configs/default/plugins/subset_tools/subset_tools.vue @@ -52,7 +52,7 @@ - plg.combination_mode = '{{ combination_selected }}' + plg.combination_mode = '{{ combination_mode_selected }}' diff --git a/jdaviz/configs/imviz/plugins/footprints/footprints.py b/jdaviz/configs/imviz/plugins/footprints/footprints.py index 9498538831..341959a6d3 100644 --- a/jdaviz/configs/imviz/plugins/footprints/footprints.py +++ b/jdaviz/configs/imviz/plugins/footprints/footprints.py @@ -143,7 +143,8 @@ def __init__(self, *args, **kwargs): self.preset_obs = SelectPluginComponent(self, items='preset_obs_items', selected='preset_obs_selected', - manual_options=preset_obs_options) + manual_options=preset_obs_options, + apply_filter_to_manual_options=True) self.preset = FileImportSelectPluginComponent(self, items='preset_items', diff --git a/jdaviz/configs/mosviz/helper.py b/jdaviz/configs/mosviz/helper.py index 2ded2d0624..bd3cf23e1e 100644 --- a/jdaviz/configs/mosviz/helper.py +++ b/jdaviz/configs/mosviz/helper.py @@ -163,7 +163,7 @@ def _row_click_message_handler(self, msg): # update data filters in each viewer's data_menu for viewer in self.viewers.values(): if data_menu := getattr(viewer._obj, '_data_menu', None): - data_menu.dataset._on_data_changed() + data_menu.dataset._update_items() def _handle_image_zoom(self, msg): mos_data = self.app.data_collection['MOS Table'] diff --git a/jdaviz/core/template_mixin.py b/jdaviz/core/template_mixin.py index 3d09098c62..1515a87c23 100644 --- a/jdaviz/core/template_mixin.py +++ b/jdaviz/core/template_mixin.py @@ -779,6 +779,7 @@ def __init__(self, *args, **kwargs): # we'll pop from kwargs now to avoid passing to the super.__init__, but need to # wait for everything else to be set before setting to the traitlet filters = kwargs.pop('filters', [])[:] # [:] needed to force copy from kwarg default + self._apply_filters_to_manual_options = kwargs.pop('apply_filters_to_manual_options', False) super().__init__(*args, **kwargs) self._selected_previous = None @@ -914,8 +915,15 @@ def remove_filter(self, *filters): @observe('filters') def _update_items(self, msg={}): - all_items = [self._to_item(opt) for opt in self.manual_options] - self.items = [item for item in all_items if self._is_valid_item(item)] + if self._apply_filters_to_manual_options: + all_items = self.items + [self._to_item(opt) + for opt in self.manual_options + if self._to_item(opt) not in self.items] + self.items = [item for item in all_items if self._is_valid_item(item)] + else: + filtered_items = [item for item in self.items if self._is_valid_item(item)] + manual_options = [self._to_item(opt) for opt in self.manual_options if self._to_item(opt) not in filtered_items] + self.items = filtered_items + manual_options try: self._apply_default_selection()