Skip to content

Commit

Permalink
ephemeris plugin: phase viewer user API and float support for times_t…
Browse files Browse the repository at this point in the history
…o_phases (#87)

* ephem create_phase_viewer to return user API object
* times_to_phases support for floats
* changelog entry
* update tests
  • Loading branch information
kecnry authored Feb 19, 2024
1 parent 2f09030 commit ca0efe9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
* Flatten plugin no longer creates new data entries, but instead appends a new column to the input
light curve and selects as the flux column (origin). [#77]

* Ephemeris plugin now supports passing floats to ``times_to_phases``. [#87]

* Ephemeris plugin's ``create_phase_viewer`` now returns the public user API instance of the viewer
instead of the underlying object. [#87]

0.1.0 (12-14-2023)
------------------

Expand Down
4 changes: 2 additions & 2 deletions lcviz/plugins/ephemeris/ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _times_to_phases_callable(self, component):
wrap_at = ephem.get('wrap_at', _default_wrap_at)

def _callable(times):
if not len(times):
if hasattr(times, '__len__') and not len(times):
return []
if dpdt != 0:
return np.mod(1./dpdt * np.log(1 + dpdt/period*(times-t0)) + (1-wrap_at), 1.0) - (1-wrap_at) # noqa
Expand Down Expand Up @@ -300,7 +300,7 @@ def create_phase_viewer(self):
if create_phase_viewer:
pv.state.x_min, pv.state.x_max = (self.wrap_at-1, self.wrap_at)
pv.state.x_att = self.app._jdaviz_helper._component_ids[self.phase_comp_lbl]
return pv
return pv.user_api

def vue_create_phase_viewer(self, *args):
self.create_phase_viewer()
Expand Down
2 changes: 1 addition & 1 deletion lcviz/tests/test_plugin_binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_plugin_binning(helper, light_curve_like_kepler_quarter):
b._obj.plugin_opened = True
ephem = helper.plugins['Ephemeris']
ephem.period = 1.2345
pv = ephem.create_phase_viewer()
pv = ephem.create_phase_viewer()._obj

with b.as_active():
assert b.ephemeris == 'No ephemeris'
Expand Down
2 changes: 1 addition & 1 deletion lcviz/tests/test_plugin_flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_plugin_flatten(helper, light_curve_like_kepler_quarter):
tv = helper.app.get_viewer(helper._default_time_viewer_reference_name)

ephem = helper.plugins['Ephemeris']
pv = ephem.create_phase_viewer()
pv = ephem.create_phase_viewer()._obj
f = helper.plugins['Flatten']

# no marks until plugin opened/active
Expand Down
2 changes: 1 addition & 1 deletion lcviz/tests/test_plugin_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_plugin_markers(helper, light_curve_like_kepler_quarter):
assert len(_get_markers_from_viewer(tv).x) == 1

ephem = helper.plugins['Ephemeris']
pv = ephem.create_phase_viewer()
pv = ephem.create_phase_viewer()._obj

# test event in flux-vs-phase viewer
label_mouseover._viewer_mouse_event(pv,
Expand Down

0 comments on commit ca0efe9

Please sign in to comment.