From 8925e021b84951da7fdee78e10eda381cc9f8609 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 10 Nov 2023 12:32:35 -0500 Subject: [PATCH] use @with_spinner from upstream this requires https://github.com/spacetelescope/jdaviz/pull/2560 --- lcviz/plugins/binning/binning.py | 7 +++---- lcviz/plugins/flatten/flatten.py | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lcviz/plugins/binning/binning.py b/lcviz/plugins/binning/binning.py index 84f141f6..6dffb06c 100644 --- a/lcviz/plugins/binning/binning.py +++ b/lcviz/plugins/binning/binning.py @@ -9,7 +9,8 @@ from jdaviz.core.registries import tray_registry from jdaviz.core.template_mixin import (PluginTemplateMixin, DatasetSelectMixin, AddResultsMixin, - skip_if_no_updates_since_last_active) + skip_if_no_updates_since_last_active, + with_spinner) from jdaviz.core.user_api import PluginUserApi from lcviz.events import EphemerisChangedMessage @@ -50,7 +51,6 @@ class Binning(PluginTemplateMixin, DatasetSelectMixin, EphemerisSelectMixin, Add last_live_time = Float(0).tag(sync=True) previews_temp_disable = Bool(False).tag(sync=True) - spinner = Bool(False).tag(sync=True) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -213,8 +213,8 @@ def _on_ephemeris_update(self, msg): self._live_update() + @with_spinner() def bin(self, add_data=True): - self.spinner = True if self.n_bins == '' or self.n_bins <= 0: raise ValueError("n_bins must be a positive integer") @@ -260,7 +260,6 @@ def bin(self, add_data=True): # by resetting x_att, the preview marks may have dissappeared self._live_update() - self.spinner = False return lc def vue_apply(self, event={}): diff --git a/lcviz/plugins/flatten/flatten.py b/lcviz/plugins/flatten/flatten.py index 7f09f9bc..66b8e94c 100644 --- a/lcviz/plugins/flatten/flatten.py +++ b/lcviz/plugins/flatten/flatten.py @@ -8,7 +8,8 @@ from jdaviz.core.registries import tray_registry from jdaviz.core.template_mixin import (PluginTemplateMixin, DatasetSelectMixin, AddResultsMixin, - skip_if_no_updates_since_last_active) + skip_if_no_updates_since_last_active, + with_spinner) from jdaviz.core.user_api import PluginUserApi from lcviz.marks import LivePreviewTrend, LivePreviewFlattened @@ -60,7 +61,6 @@ class Flatten(PluginTemplateMixin, DatasetSelectMixin, AddResultsMixin): last_live_time = Float(0).tag(sync=True) previews_temp_disable = Bool(False).tag(sync=True) - spinner = Bool(False).tag(sync=True) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -121,6 +121,7 @@ def _set_default_results_label(self, event={}): else: self.results_label_default = f"{self.dataset_selected} (flattened)" + @with_spinner() def flatten(self, add_data=True): """ Flatten the input light curve (``dataset``) using lightkurve.flatten. @@ -138,7 +139,6 @@ def flatten(self, add_data=True): trend_lc : `~lightkurve.LightCurve` The trend used to flatten the light curve. """ - self.spinner = True input_lc = self.dataset.selected_obj if input_lc is None: # pragma: no cover raise ValueError("no input dataset selected") @@ -161,7 +161,6 @@ def flatten(self, add_data=True): data = _data_with_reftime(self.app, output_lc) self.add_results.add_results_from_plugin(data) - self.spinner = False return output_lc, trend_lc def _clear_marks(self):