diff --git a/jdaviz/configs/default/plugins/line_lists/line_lists.py b/jdaviz/configs/default/plugins/line_lists/line_lists.py index d324ea420c..f27b3eaad8 100644 --- a/jdaviz/configs/default/plugins/line_lists/line_lists.py +++ b/jdaviz/configs/default/plugins/line_lists/line_lists.py @@ -513,10 +513,8 @@ def _list_from_notebook(self, msg): list_contents[row["listname"]]["lines"].append(temp_dict) tmp_names_rest.append(row["name_rest"]) - self.loaded_lists = [] - self.loaded_lists = loaded_lists - self.list_contents = {} - self.list_contents = list_contents + self.send_state('loaded_lists') + self.send_state('list_contents') self._viewer.plot_spectral_lines(tmp_names_rest) self.update_line_mark_dict() @@ -654,9 +652,9 @@ def vue_show_all_in_list(self, listname): for line in lc[listname]["lines"]: line["show"] = True self._viewer.spectral_lines.loc[line["name_rest"]]["show"] = True - # Trick traitlets into updating - self.list_contents = {} + self.list_contents = lc + self.send_state('list_contents') self._viewer.plot_spectral_lines() self.update_line_mark_dict() @@ -665,14 +663,12 @@ def vue_hide_all_in_list(self, listname): """ Toggle all lines in list to be hidden """ - lc = self.list_contents name_rests = [] - for line in lc[listname]["lines"]: + for line in self.list_contents[listname]["lines"]: line["show"] = False name_rests.append(line["name_rest"]) - # Trick traitlets into updating - self.list_contents = {} - self.list_contents = lc + + self.send_state('list_contents') self._viewer.erase_spectral_lines(name_rest=name_rests) self.update_line_mark_dict() @@ -686,14 +682,12 @@ def vue_plot_all_lines(self, event): sender=self, color="error") self.hub.broadcast(warn_message) return - lc = self.list_contents - for listname in lc: - for line in lc[listname]["lines"]: + for listname in self.list_contents: + for line in self.list_contents[listname]["lines"]: line["show"] = True self._viewer.spectral_lines["show"] = True - # Trick traitlets into updating - self.list_contents = {} - self.list_contents = lc + + self.send_state('list_contents') self._viewer.plot_spectral_lines() self.update_line_mark_dict() @@ -707,13 +701,11 @@ def vue_erase_all_lines(self, event): sender=self, color="error") self.hub.broadcast(warn_message) return - lc = self.list_contents - for listname in lc: - for line in lc[listname]["lines"]: + for listname in self.list_contents: + for line in self.list_contents[listname]["lines"]: line["show"] = False - # Trick traitlets into updating - self.list_contents = {} - self.list_contents = lc + + self.send_state('list_contents') self._viewer.erase_spectral_lines() self.update_line_mark_dict() @@ -798,11 +790,10 @@ def vue_set_color(self, data): color = data['color'] if "listname" in data: listname = data["listname"] - # force a copy so that the change is picked up by traitlets - lc = self.list_contents[listname].copy() - lc["color"] = color - for line in lc["lines"]: + self.list_contents[listname]["color"] = color + + for line in self.list_contents[listname]["lines"]: line["colors"] = color # Update the astropy table entry name_rest = line["name_rest"] @@ -811,7 +802,7 @@ def vue_set_color(self, data): if name_rest in self.line_mark_dict: self.line_mark_dict[name_rest].colors = [color] - self.list_contents = {**self.list_contents, listname: lc} + self.send_state('list_contents') elif "linename" in data: pass diff --git a/jdaviz/configs/default/plugins/model_fitting/model_fitting.py b/jdaviz/configs/default/plugins/model_fitting/model_fitting.py index e7ccc53395..66a92c49b3 100644 --- a/jdaviz/configs/default/plugins/model_fitting/model_fitting.py +++ b/jdaviz/configs/default/plugins/model_fitting/model_fitting.py @@ -241,10 +241,7 @@ def _update_parameters_from_fit(self): m["parameters"] = temp_params - # Trick traitlets into updating the displayed values - component_models = self.component_models - self.component_models = [] - self.component_models = component_models + self.send_state('component_models') def _update_parameters_from_QM(self): """ @@ -283,10 +280,7 @@ def _update_parameters_from_QM(self): temp_params += temp_param m["parameters"] = temp_params - # Trick traitlets into updating the displayed values - component_models = self.component_models - self.component_models = [] - self.component_models = component_models + self.send_state('component_models') def _update_initialized_parameters(self): # If the user changes a parameter value, we need to change it in the diff --git a/jdaviz/configs/mosviz/plugins/slit_overlay/slit_overlay.py b/jdaviz/configs/mosviz/plugins/slit_overlay/slit_overlay.py index 400e72a523..3ec0734111 100644 --- a/jdaviz/configs/mosviz/plugins/slit_overlay/slit_overlay.py +++ b/jdaviz/configs/mosviz/plugins/slit_overlay/slit_overlay.py @@ -152,7 +152,6 @@ def remove_slit_overlay(self): # We need to do the following instead of just removing directly on # the marks otherwise traitlets doesn't register a change in the # marks. - marks = image_figure.marks.copy() - marks.remove(self._slit_overlay_mark) - image_figure.marks = marks + image_figure.marks.remove(self._slit_overlay_mark) + image_figure.send_state('marks') self._slit_overlay_mark = None