Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

make use of with_spinner decorator #57

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lcviz/plugins/binning/binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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={}):
Expand Down
7 changes: 3 additions & 4 deletions lcviz/plugins/flatten/flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -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")
Expand All @@ -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):
Expand Down
Loading