Skip to content

Commit

Permalink
fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Dec 18, 2024
1 parent 056271c commit f135ad5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions jdaviz/configs/default/plugins/subset_tools/subset_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<v-row v-if="api_hints_enabled" style="margin-top: -32px">
<span class="api-hint">
plg.combination_mode = '{{ combination_selected }}'
plg.combination_mode = '{{ combination_mode_selected }}'
</span>
</v-row>

Expand Down
3 changes: 2 additions & 1 deletion jdaviz/configs/imviz/plugins/footprints/footprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/mosviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
16 changes: 14 additions & 2 deletions jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -914,8 +915,19 @@ 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()
Expand Down

0 comments on commit f135ad5

Please sign in to comment.