Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Dec 27, 2024
1 parent 5e4b424 commit 2f35bc1
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2075,23 +2075,32 @@ def _rename_subset(self, old_label, new_label, subset_group=None, check_valid=Tr
self.state.layer_icons[new_label] = self.state.layer_icons[old_label]
_ = self.state.layer_icons.pop(old_label)

# Updated extracted spectrum if applicable and update _update_live_plugin_results dict.
if self.config == 'cubeviz':
for d in self.data_collection:
if d.label.split("(")[-1].split(",")[0] == old_label:
old_data_label = d.label
new_data_label = d.label.replace(old_label, new_label)
d.label = new_data_label
self.state.layer_icons[new_data_label] = self.state.layer_icons[old_data_label]
_ = self.state.layer_icons.pop(old_data_label)
results_dict = d.meta['_update_live_plugin_results']
results_dict['aperture'] = new_label
# Updated derived data if applicable
for d in self.data_collection:
data_renamed = False
# Extracted spectra are named, e.g., 'Data (Subset 1, sum)'
if d.label.split("(")[-1].split(",")[0] == old_label:
old_data_label = d.label
new_data_label = d.label.replace(old_label, new_label)
d.label = new_data_label
self.state.layer_icons[new_data_label] = self.state.layer_icons[old_data_label]
_ = self.state.layer_icons.pop(old_data_label)

# Update the entries in the old data menu
for data_item in self.state.data_items:
if data_item['name'] == old_data_label:
data_item['name'] = new_data_label

# Update live plugin results subscriptions
if hasattr(d, 'meta') and '_update_live_plugin_results' in d.meta:
results_dict = d.meta['_update_live_plugin_results']
for key in results_dict.get('_subscriptions', {}).get('subset'):
results_dict[key] = new_label

if data_renamed:
results_dict['add_results']['label'] = new_data_label
d.meta['_update_live_plugin_results'] = results_dict

for data_item in self.state.data_items:
if data_item['name'] == old_data_label:
data_item['name'] = new_data_label
d.meta['_update_live_plugin_results'] = results_dict

self.hub.broadcast(SubsetRenameMessage(subset_group, old_label, new_label, sender=self))

Expand Down

0 comments on commit 2f35bc1

Please sign in to comment.