From 1b12174ad9dcb9a59a5792d30b8efa07d71758b0 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 8 May 2024 12:32:47 -0400 Subject: [PATCH 1/4] prevent repeatedly updating previews --- .../spectral_extraction/spectral_extraction.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py index 9f496385e3..dd2bcaebf3 100644 --- a/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py @@ -417,6 +417,7 @@ def update_marks(self, step=None): raise ValueError("step must be one of: trace, bg, ext") # also listens to is_active from any _interaction_in_*_step methods + @observe('is_active', 'active_step') @skip_if_not_tray_instance() def _update_plugin_marks(self, msg={}): if self.app._jdaviz_helper is None: @@ -527,10 +528,10 @@ def _update_interactive_extract(self, event={}): 'trace_pixel', 'trace_peak_method_selected', 'trace_do_binning', 'trace_bins', 'trace_window', 'active_step') @skip_if_not_tray_instance() + @skip_if_no_updates_since_last_active() def _interaction_in_trace_step(self, event={}): if ((event.get('name', '') in ('active_step', 'is_active') and self.active_step != 'trace') or not self.is_active): - self._update_plugin_marks(event) return try: @@ -546,16 +547,15 @@ def _interaction_in_trace_step(self, event={}): self._update_interactive_extract(event) self.active_step = 'trace' - self._update_plugin_marks(event) @observe('is_active', 'bg_dataset_selected', 'bg_type_selected', 'bg_trace_selected', 'bg_trace_pixel', 'bg_separation', 'bg_width', 'bg_statistic_selected', 'active_step') @skip_if_not_tray_instance() + @skip_if_no_updates_since_last_active() def _interaction_in_bg_step(self, event={}): if ((event.get('name', '') in ('active_step', 'is_active') and self.active_step != 'bg') or not self.is_active): - self._update_plugin_marks(event) return try: @@ -599,15 +599,14 @@ def _interaction_in_bg_step(self, event={}): self._update_interactive_extract(event) self.active_step = 'bg' - self._update_plugin_marks(event) @observe('is_active', 'ext_dataset_selected', 'ext_trace_selected', 'ext_type_selected', 'ext_width', 'active_step') @skip_if_not_tray_instance() + @skip_if_no_updates_since_last_active() def _interaction_in_ext_step(self, event={}): - if ((event.get('name', '') in ('active_step', 'is_active') and self.active_step not in ('ext', '')) # noqa + if ((event.get('name', '') in ('active_step', 'is_active') and self.active_step != 'ext') or not self.is_active): - self._update_plugin_marks(event) return try: @@ -633,7 +632,6 @@ def _interaction_in_ext_step(self, event={}): self._update_interactive_extract(event) self.active_step = 'ext' - self._update_plugin_marks(event) # TODO: remove this, the traitlet, and the row in spectral_extraction.vue # when specutils handles the warning/exception From 38054613d82474f12c8aff2c615d928cba53d7e9 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 8 May 2024 12:36:28 -0400 Subject: [PATCH 2/4] changelog --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index c4f59d2035..81b9199e0a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -161,6 +161,8 @@ Specviz Specviz2d ^^^^^^^^^ +- Prevent laggy behavior in trace previews for spectral extraction. [#2862] + 3.10 (2024-05-03) ================= From 44855841dba8aac8f580cdbfd4e0e4747060433f Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 8 May 2024 12:37:50 -0400 Subject: [PATCH 3/4] revert small change when no active step is set --- .../plugins/spectral_extraction/spectral_extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py index dd2bcaebf3..815cdffece 100644 --- a/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py @@ -605,7 +605,7 @@ def _interaction_in_bg_step(self, event={}): @skip_if_not_tray_instance() @skip_if_no_updates_since_last_active() def _interaction_in_ext_step(self, event={}): - if ((event.get('name', '') in ('active_step', 'is_active') and self.active_step != 'ext') + if ((event.get('name', '') in ('active_step', 'is_active') and self.active_step not in ('ext', '')) # noqa or not self.is_active): return From 291e0b9e5f7499d95a1e951d48409c218c07d013 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 8 May 2024 12:43:33 -0400 Subject: [PATCH 4/4] remove outdated comment --- .../specviz2d/plugins/spectral_extraction/spectral_extraction.py | 1 - 1 file changed, 1 deletion(-) diff --git a/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py index 815cdffece..82403676ef 100644 --- a/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py @@ -416,7 +416,6 @@ def update_marks(self, step=None): else: raise ValueError("step must be one of: trace, bg, ext") - # also listens to is_active from any _interaction_in_*_step methods @observe('is_active', 'active_step') @skip_if_not_tray_instance() def _update_plugin_marks(self, msg={}):