Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

TST: See if percentile is breaking devdeps (try 2) #96

Closed
wants to merge 12 commits into from
37 changes: 0 additions & 37 deletions .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,6 @@ jobs:
strategy:
matrix:
include:
- name: Code style checks
os: ubuntu-latest
python: 3.x
toxenv: codestyle
allow_failure: false

- name: PEP 517
os: ubuntu-latest
python: 3.x
toxenv: pep517
allow_failure: false

- name: Security audit
os: ubuntu-latest
python: 3.x
toxenv: securityaudit
allow_failure: false

- name: Python 3.10 with coverage checking, all deps, and remote data
os: ubuntu-latest
python: '3.10'
toxenv: py310-test-alldeps-cov
toxposargs: --remote-data
allow_failure: false

- name: OS X - Python 3.9
os: macos-latest
python: 3.9
toxenv: py39-test
allow_failure: false

- name: Windows - Python 3.9
os: windows-latest
python: 3.9
toxenv: py39-test
allow_failure: false

# This also runs on cron but we want to make sure new changes
# won't break this job at the PR stage.
- name: Python 3.11 with latest dev versions of key dependencies, and remote data
Expand Down
14 changes: 7 additions & 7 deletions docs/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,18 +318,18 @@ This plugin supports binning a light curve in time or phase-space.
* :meth:`lightkurve.LightCurve.bin`


.. _export-plot:
.. _export:

Export Plot
===========
Export
======

This plugin allows exporting the plot in a given viewer to various image formats.


.. admonition:: User API Example
:class: dropdown

See the :class:`~lcviz.plugins.export_plot.export_plot.ExportViewer` user API documentation for more details.
See the :class:`~lcviz.plugins.export.export.Export` user API documentation for more details.

.. code-block:: python

Expand All @@ -340,11 +340,11 @@ This plugin allows exporting the plot in a given viewer to various image formats
lcviz.load_data(lc)
lcviz.show()

export = lcviz.plugins['Export Plot']
export.save_figure('test.png')
export = lcviz.plugins['Export']
export.export('test.png')


.. seealso::

:ref:`Jdaviz Export Plot <jdaviz:imviz-export-plot>`
Jdaviz documentation on the Export Plot plugin.
Jdaviz documentation on the Export plugin.
10 changes: 3 additions & 7 deletions lcviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ class LCviz(ConfigHelper):
'tab_headers': True},
'dense_toolbar': False,
'context': {'notebook': {'max_height': '600px'}}},
'toolbar': ['g-data-tools', 'g-subset-tools', 'lcviz-viewer-creator', 'lcviz-coords-info'],
'toolbar': ['g-data-tools', 'g-subset-tools', 'g-viewer-creator', 'lcviz-coords-info'],
'tray': ['lcviz-metadata-viewer', 'flux-column',
'lcviz-plot-options', 'lcviz-subset-plugin',
'lcviz-markers', 'flatten', 'frequency-analysis', 'ephemeris',
'binning', 'lcviz-export-plot'],
'binning', 'lcviz-export'],
'viewer_area': [{'container': 'col',
'children': [{'container': 'row',
'viewers': [{'name': 'flux-vs-time',
Expand All @@ -92,11 +92,7 @@ def __init__(self, *args, **kwargs):
)

# inject custom css from lcviz_style.vue (on top of jdaviz styles)
if hasattr(self.app, '_add_style'):
# will be guaranteed after jdaviz 3.9
self.app._add_style((__file__, 'lcviz_style.vue'))
else:
self.app.set_style_template_file((__file__, 'lcviz_style.vue'))
self.app._add_style((__file__, 'lcviz_style.vue'))

# set the link to read the docs
self.app.docs_link = "https://lcviz.readthedocs.io"
Expand Down
2 changes: 1 addition & 1 deletion lcviz/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from .binning.binning import * # noqa
from .ephemeris.ephemeris import * # noqa
from .export_plot.export_plot import * # noqa
from .export.export import * # noqa
from .flatten.flatten import * # noqa
from .flux_column.flux_column import * # noqa
from .frequency_analysis.frequency_analysis import * # noqa
Expand Down
19 changes: 3 additions & 16 deletions lcviz/plugins/binning/binning.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import numpy as np
from time import time
from astropy.time import Time
from traitlets import Bool, Float, observe
from glue.config import data_translator
Expand All @@ -10,7 +8,7 @@
from jdaviz.core.template_mixin import (PluginTemplateMixin,
DatasetSelectMixin, AddResultsMixin,
skip_if_no_updates_since_last_active,
with_spinner)
with_spinner, with_temp_disable)
from jdaviz.core.user_api import PluginUserApi

from lcviz.components import FluxColumnSelectMixin
Expand Down Expand Up @@ -54,9 +52,6 @@ class Binning(PluginTemplateMixin, FluxColumnSelectMixin, DatasetSelectMixin,
n_bins = IntHandleEmpty(100).tag(sync=True)
bin_enabled = Bool(True).tag(sync=True)

last_live_time = Float(0).tag(sync=True)
previews_temp_disable = Bool(False).tag(sync=True)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand Down Expand Up @@ -164,20 +159,16 @@ def _toggle_marks(self, event={}):

@observe('flux_column_selected', 'dataset_selected',
'ephemeris_selected',
'n_bins', 'previews_temp_disable')
'n_bins', 'previews_temp_disabled')
@skip_if_no_updates_since_last_active()
@with_temp_disable(timeout=0.3)
def _live_update(self, event={}):
self.bin_enabled = self.n_bins != '' and self.n_bins > 0

if not self.show_live_preview or not self.is_active or not self.bin_enabled:
self._clear_marks()
return

if self.previews_temp_disable:
return

start = time()

if event.get('name', '') not in ('is_active', 'show_live_preview'):
# mark visibility hasn't been handled yet
self._toggle_marks()
Expand Down Expand Up @@ -214,10 +205,6 @@ def _live_update(self, event={}):
mark.times = []
mark.update_xy(times, lc.flux.value)

self.last_live_time = np.round(time() - start, 2)
if self.last_live_time > 0.3:
self.previews_temp_disable = True

def _on_ephemeris_update(self, msg):
if not self.show_live_preview or not self.is_active:
return
Expand Down
22 changes: 5 additions & 17 deletions lcviz/plugins/binning/binning.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,11 @@
</v-text-field>
</v-row>

<v-alert v-if="previews_temp_disable && show_live_preview" type='warning' style="margin-left: -12px; margin-right: -12px">
Live-updating is temporarily disabled (last update took {{last_live_time}}s)
<v-row justify='center'>
<j-tooltip tooltipcontent='hide live preview (can be re-enabled from the settings section in the plugin).' span_style="width: 100%">
<v-btn style='width: 100%' @click="show_live_preview = false">
disable previews
</v-btn>
</j-tooltip>
</v-row>
<v-row justify='center'>
<j-tooltip tooltipcontent='manually update live-previews based on current plugin inputs.' span_style="width: 100%">
<v-btn style='width: 100%' @click="previews_temp_disable = false">
update preview
</v-btn>
</j-tooltip>
</v-row>
</v-alert>
<plugin-previews-temp-disabled
:previews_temp_disabled.sync="previews_temp_disabled"
:previews_last_time="previews_last_time"
:show_live_preview.sync="show_live_preview"
/>

<plugin-add-results
:label.sync="results_label"
Expand Down
1 change: 1 addition & 0 deletions lcviz/plugins/export/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .export import * # noqa
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
from jdaviz.configs.default.plugins import ExportViewer
from jdaviz.configs.default.plugins import Export
from jdaviz.core.registries import tray_registry

__all__ = ['ExportViewer']
__all__ = ['Export']


@tray_registry('lcviz-export-plot', label="Export Plot")
class ExportViewer(ExportViewer):
@tray_registry('lcviz-export', label="Export")
class Export(Export):
"""
See the :ref:`Export Plot Plugin Documentation <export-plot>` for more details.
See the :ref:`Export Plot Plugin Documentation <export>` for more details.

Only the following attributes and methods are available through the
:ref:`public plugin API <plugin-apis>`:

* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.close_in_tray`
* ``viewer`` (:class:`~jdaviz.core.template_mixin.ViewerSelect`):
Viewer to select for exporting the figure image.
* :meth:`save_figure`
* ``viewer`` (:class:`~jdaviz.core.template_mixin.ViewerSelect`)
* ``viewer_format`` (:class:`~jdaviz.core.template_mixin.SelectPluginComponent`)
* ``filename``
* :meth:`export`
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.docs_link = f"https://lcviz.readthedocs.io/en/{self.vdocs}/plugins.html#export-plot"
self.docs_link = f"https://lcviz.readthedocs.io/en/{self.vdocs}/plugins.html#export"
1 change: 0 additions & 1 deletion lcviz/plugins/export_plot/__init__.py

This file was deleted.

18 changes: 4 additions & 14 deletions lcviz/plugins/flatten/flatten.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
from time import time

from traitlets import Bool, Float, Unicode, observe
from traitlets import Bool, Unicode, observe

from jdaviz.core.custom_traitlets import FloatHandleEmpty, IntHandleEmpty
from jdaviz.core.events import ViewerAddedMessage
Expand All @@ -10,7 +9,7 @@
DatasetSelectMixin,
AutoTextField,
skip_if_no_updates_since_last_active,
with_spinner)
with_spinner, with_temp_disable)
from jdaviz.core.user_api import PluginUserApi

from lcviz.components import FluxColumnSelectMixin
Expand Down Expand Up @@ -70,9 +69,6 @@ class Flatten(PluginTemplateMixin, FluxColumnSelectMixin, DatasetSelectMixin):
flux_label_invalid_msg = Unicode('').tag(sync=True)
flux_label_overwrite = Bool(False).tag(sync=True)

last_live_time = Float(0).tag(sync=True)
previews_temp_disable = Bool(False).tag(sync=True)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand Down Expand Up @@ -217,16 +213,14 @@ def _toggle_marks(self, event={}):

@observe('dataset_selected', 'flux_column_selected',
'window_length', 'polyorder', 'break_tolerance',
'niters', 'sigma', 'previews_temp_disable')
'niters', 'sigma', 'previews_temp_disabled')
@skip_if_no_updates_since_last_active()
@with_temp_disable(0.3)
def _live_update(self, event={}):
if self.previews_temp_disable:
return
if self.dataset_selected == '' or self.flux_column_selected == '':
self._clear_marks()
return

start = time()
try:
output_lc, trend_lc = self.flatten(add_data=False)
except Exception as e:
Expand All @@ -253,10 +247,6 @@ def _live_update(self, event={}):
for mark in flattened_marks.values():
mark.update_ty(times.value, output_flux)

self.last_live_time = np.round(time() - start, 2)
if self.last_live_time > 0.3:
self.previews_temp_disable = True

def vue_apply(self, *args, **kwargs):
try:
self.flatten(add_data=True)
Expand Down
23 changes: 6 additions & 17 deletions lcviz/plugins/flatten/flatten.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,12 @@
hint="Label for flux column."
></plugin-auto-label>

<v-alert v-if="previews_temp_disable && (show_live_preview || show_trend_preview)" type='warning' style="margin-left: -12px; margin-right: -12px">
Live-updating is temporarily disabled (last update took {{last_live_time}}s)
<v-row justify='center'>
<j-tooltip tooltipcontent='hide live trend and flattened previews (can be re-enabled from the settings section in the plugin).' span_style="width: 100%">
<v-btn style='width: 100%' @click="() => {show_live_preview = false; show_trend_preview = false}">
disable previews
</v-btn>
</j-tooltip>
</v-row>
<v-row justify='center'>
<j-tooltip tooltipcontent='manually update live-previews based on current plugin inputs.' span_style="width: 100%">
<v-btn style='width: 100%' @click="previews_temp_disable = false">
update preview
</v-btn>
</j-tooltip>
</v-row>
</v-alert>
<plugin-previews-temp-disabled
:previews_temp_disabled.sync="previews_temp_disabled"
:previews_last_time="previews_last_time"
:show_live_preview="show_live_preview || show_trend_preview"
@disable_previews="() => {show_live_preview=false; show_trend_preview=false}"
/>

<v-row justify="end">
<j-tooltip tooltipcontent="Flatten and select the new column as the adopted flux column">
Expand Down
2 changes: 1 addition & 1 deletion lcviz/plugins/viewer_creator/viewer_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__all__ = ['ViewerCreator']


@tool_registry('lcviz-viewer-creator')
@tool_registry('g-viewer-creator', overwrite=True) # overwrite requires upstream changes, we can do without if we just lose the tooltip
class ViewerCreator(ViewerCreator):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
18 changes: 7 additions & 11 deletions lcviz/tests/test_plugin_ephemeris.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import pytest
from packaging.version import Version

import jdaviz
JDAVIZ_LT_3_9_0 = Version(jdaviz.__version__) < Version('3.9.0')


def test_docs_snippets(helper, light_curve_like_kepler_quarter):
Expand Down Expand Up @@ -49,13 +45,12 @@ def test_plugin_ephemeris(helper, light_curve_like_kepler_quarter):
assert len(ephem.ephemerides) == 2
assert 'custom component' in ephem.ephemerides

if not JDAVIZ_LT_3_9_0:
with pytest.raises(ValueError):
# brackets interfere with cloned viewer label logic
ephem.rename_component('custom component', 'custom component[blah]')
with pytest.raises(ValueError):
# colons interfere with viewer ephemeris logic
ephem.rename_component('custom component', 'custom component:blah')
with pytest.raises(ValueError):
# brackets interfere with cloned viewer label logic
ephem.rename_component('custom component', 'custom component[blah]')
with pytest.raises(ValueError):
# colons interfere with viewer ephemeris logic
ephem.rename_component('custom component', 'custom component:blah')

ephem.rename_component('custom component', 'renamed custom component')
assert len(ephem.ephemerides) == 2
Expand Down Expand Up @@ -113,6 +108,7 @@ def test_cloned_phase_viewer(helper, light_curve_like_kepler_quarter):
assert len(helper.viewers) == 1 # just flux-vs-phase


@pytest.mark.skip("FIXME")
def test_create_phase_viewer(helper, light_curve_like_kepler_quarter):
helper.load_data(light_curve_like_kepler_quarter)
ephem = helper.plugins['Ephemeris']
Expand Down
Loading
Loading