Skip to content

Commit

Permalink
remove unused method, rename its successor
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Jul 24, 2024
1 parent ace77a8 commit 3a21b05
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
46 changes: 24 additions & 22 deletions lcviz/plugins/ephemeris/ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def user_api(self):
'times_to_phases', 'phases_to_times', 'get_data',
'dataset', 'method', 'period_at_max_power',
'adopt_period_at_max_power', 'query_for_ephemeris',
'query_result', 'adopt_from_catalog', 'adopt_from_catalog_in_new_viewer'
'query_result', 'adopt_from_catalog', 'create_ephemeris_from_query'
]
return PluginUserApi(self, expose=expose)

Expand Down Expand Up @@ -680,36 +680,38 @@ def _select_query_result(self, *args):
def vue_query_for_ephemeris(self, *args):
self.query_for_ephemeris()

Check warning on line 681 in lcviz/plugins/ephemeris/ephemeris.py

View check run for this annotation

Codecov / codecov/patch

lcviz/plugins/ephemeris/ephemeris.py#L681

Added line #L681 was not covered by tests

def adopt_from_catalog(self, *args):
if len(self._get_phase_viewers()):
# if a phase viewer is available, adopt the ephemeris in the phase viewer:
if not np.any(np.isnan([self.period_from_catalog, self.t0_from_catalog])):
self.period = self.period_from_catalog
self.t0 = self.t0_from_catalog

# reset the phase axis wrap to feature the primary transit:
self.wrap_at = 0.5
viewer = self._get_phase_viewers()[0]
viewer.reset_limits()
else:
# otherwise, adopt the ephemeris in a new phase viewer:
self.adopt_from_catalog_in_new_viewer()

def adopt_from_catalog_in_new_viewer(self, *args):
def create_ephemeris_from_query(self, *args):
new_component_label = self.query_result_selected.replace(' ', '')
if new_component_label in self.component.choices:
# warn the user that an ephemeris component already exists with this label,
# a second won't be added:
self.hub.broadcast(

Check warning on line 688 in lcviz/plugins/ephemeris/ephemeris.py

View check run for this annotation

Codecov / codecov/patch

lcviz/plugins/ephemeris/ephemeris.py#L688

Added line #L688 was not covered by tests
SnackbarMessage(
f"Ephemeris component {new_component_label} already exists, skipping.",
f"Ephemeris component {new_component_label} already exists, "
f"this ephemeris component will not be added.",
sender=self, color="warning"
)
)
else:
elif not np.any(np.isnan([self.period_from_catalog, self.t0_from_catalog])):
self.add_component(new_component_label)
self.create_phase_viewer()
self.adopt_from_catalog()

def vue_adopt_from_catalog_in_new_viewer(self, *args):
self.adopt_from_catalog_in_new_viewer()
self.period = self.period_from_catalog
self.t0 = self.t0_from_catalog

# reset the phase axis wrap to feature the primary transit:
self.wrap_at = 0.5
viewer = self._get_phase_viewers()[0]
viewer.reset_limits()
else:
self.hub.broadcast(

Check warning on line 707 in lcviz/plugins/ephemeris/ephemeris.py

View check run for this annotation

Codecov / codecov/patch

lcviz/plugins/ephemeris/ephemeris.py#L707

Added line #L707 was not covered by tests
SnackbarMessage(
f"Catalog period ({self.period_from_catalog}) or "
f"epoch ({self.t0_from_catalog}) is NaN, this ephemeris "
f"component will not be added.",
sender=self, color="warning"
)
)

def vue_create_ephemeris_from_query(self, *args):
self.create_ephemeris_from_query()

Check warning on line 717 in lcviz/plugins/ephemeris/ephemeris.py

View check run for this annotation

Codecov / codecov/patch

lcviz/plugins/ephemeris/ephemeris.py#L717

Added line #L717 was not covered by tests
2 changes: 1 addition & 1 deletion lcviz/plugins/ephemeris/ephemeris.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
<v-row justify="end">
<v-col>
<plugin-action-button
@click="adopt_from_catalog_in_new_viewer"
@click="create_ephemeris_from_query"
:disabled="component_items.map(item => item.label).includes(query_result_selected.replace(/\s/g, ''))">
Create new component
</plugin-action-button>
Expand Down
6 changes: 2 additions & 4 deletions lcviz/tests/test_plugin_ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,11 @@ def test_ephemeris_queries(helper, light_curve_like_kepler_quarter):
ephem = helper.plugins['Ephemeris']

ephem.query_for_ephemeris()
# this should be HAT-P-11 b:
planet = ephem.query_result.choices[0]
assert planet == 'HAT-P-11 b'

ephem.query_result = planet
ephem.adopt_from_catalog()
ephem.create_ephemeris_from_query()

compare_against_literature_ephemeris(helper, ephem)

Expand All @@ -168,11 +167,10 @@ def test_ephemeris_query_no_name(helper, light_curve_like_kepler_quarter):
ephem = helper.plugins['Ephemeris']

ephem.query_for_ephemeris()
# this should be HAT-P-11 b:
planet = ephem.query_result.choices[0]
assert planet == 'HAT-P-11 b'

ephem.query_result = planet
ephem.adopt_from_catalog()
ephem.create_ephemeris_from_query()

compare_against_literature_ephemeris(helper, ephem)

0 comments on commit 3a21b05

Please sign in to comment.