diff --git a/lcviz/helper.py b/lcviz/helper.py index a0481494..2487dcec 100644 --- a/lcviz/helper.py +++ b/lcviz/helper.py @@ -31,7 +31,7 @@ def _get_range_subset_bounds(self, subset_state, *args, **kwargs): # TODO: use display units once implemented in Glue for ScatterViewer # units = u.Unit(viewer.state.x_display_unit) units = u.Unit(viewer.time_unit) - else: + else: # pragma: no cover raise ValueError("Unable to find time axis units") region = reference_time + u.Quantity([subset_state.lo * units, subset_state.hi * units]) diff --git a/lcviz/plugins/ephemeris/ephemeris.py b/lcviz/plugins/ephemeris/ephemeris.py index 4eb0a87e..38aecee0 100644 --- a/lcviz/plugins/ephemeris/ephemeris.py +++ b/lcviz/plugins/ephemeris/ephemeris.py @@ -280,7 +280,7 @@ def _on_component_remove(self, lbl): _ = self._ephemerides.pop(lbl, {}) # remove the corresponding viewer, if it exists viewer_item = self.app._viewer_item_by_id(self._phase_viewer_id(lbl)) - if viewer_item is None: + if viewer_item is None: # pragma: no cover return cid = viewer_item.get('id', None) if cid is not None: @@ -346,7 +346,7 @@ def update_ephemeris(self, component=None, t0=None, period=None, dpdt=None): if component is None: component = self.component_selected - if component not in self.component.choices: + if component not in self.component.choices: # pragma: no cover raise ValueError(f"component must be one of {self.component.choices}") existing_ephem = self._ephemerides.get(component, {}) @@ -411,7 +411,7 @@ def _update_periodogram(self, *args): self.method_spinner = False self.method_err = str(err) return - else: + else: # pragma: no cover self.method_spinner = False raise NotImplementedError(f"periodogram not implemented for {self.method}") diff --git a/lcviz/tests/test_plugin_ephemeris.py b/lcviz/tests/test_plugin_ephemeris.py index 587e170e..a837b6d3 100644 --- a/lcviz/tests/test_plugin_ephemeris.py +++ b/lcviz/tests/test_plugin_ephemeris.py @@ -31,6 +31,22 @@ def test_plugin_ephemeris(helper, light_curve_like_kepler_quarter): assert 'renamed custom component' in ephem.ephemerides assert len(helper.app.get_viewer_ids()) == 3 + assert ephem.component == 'renamed custom component' + assert ephem.period == 3.14 + assert ephem.ephemeris['period'] == 3.14 + # modify the ephemeris of the NON-selected ephemeris component + ephem.update_ephemeris(component='default', period=2) + assert ephem.period == 3.14 + assert ephem.ephemerides['default']['period'] == 2 + ephem.remove_component('renamed custom component') assert len(ephem.ephemerides) == 1 assert len(helper.app.get_viewer_ids()) == 2 + assert ephem.component == 'default' + assert ephem.period == 2 + + assert ephem.method.selected == 'Lomb-Scargle' + ephem.method = 'Box Least Squares' + assert ephem._obj.method_err == '' + ephem._obj.vue_adopt_period_at_max_power() + assert ephem.period != 2 diff --git a/lcviz/utils.py b/lcviz/utils.py index 1bb0e28e..3dbff498 100644 --- a/lcviz/utils.py +++ b/lcviz/utils.py @@ -25,7 +25,7 @@ class TimeCoordinates(Coordinates): """ def __init__(self, times, reference_time=None, unit=u.d): - if not isinstance(times, Time): + if not isinstance(times, Time): # pragma: no cover raise TypeError('values should be a Time instance') self._index = np.arange(len(times)) self._times = times @@ -44,7 +44,7 @@ def time_axis(self): return self._times def world_to_pixel_values(self, *world): - if len(world) > 1: + if len(world) > 1: # pragma: no cover raise ValueError('TimeCoordinates is a 1-d coordinate class ' 'and only accepts a single scalar or array to convert') return interp1d( @@ -52,7 +52,7 @@ def world_to_pixel_values(self, *world): )(world[0]) def pixel_to_world_values(self, *pixel): - if len(pixel) > 1: + if len(pixel) > 1: # pragma: no cover raise ValueError('SpectralCoordinates is a 1-d coordinate class ' 'and only accepts a single scalar or array to convert') return interp1d(