From 070f663e64c3ea422b3e7c11c76d758d27d8c4a2 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Tue, 2 Jan 2024 12:57:31 -0500 Subject: [PATCH] API example in docs --- docs/plugins.rst | 26 ++++++++++++++++++++++++++ lcviz/tests/test_plugin_flux_origin.py | 12 ++++++++++++ 2 files changed, 38 insertions(+) diff --git a/docs/plugins.rst b/docs/plugins.rst index 66c862aa..bf76e5eb 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -44,6 +44,32 @@ This plugin allows choosing which column in the underlying data should be used a throughout the app (when plotting and in any data analysis plugins). +.. admonition:: User API Example + :class: dropdown + + See the :class:`~lcviz.plugins.plot_options.plot_options.PlotOptions` user API documentation for more details. + + .. code-block:: python + + from lcviz import LCviz + lc = search_lightcurve("HAT-P-11", mission="Kepler", + cadence="long", quarter=10).download().flatten() + lcviz = LCviz() + lcviz.load_data(lc) + lcviz.show() + + flux_origin = lcviz.plugins['Flux Origin'] + print(flux_origin.flux_origin.choices) + flux_origin.flux_origin = 'sap_flux' + + +.. seealso:: + + This plugin reproduces the behavior also available in ``lightkurve`` as: + + * :meth:`lightkurve.LightCurve.select_flux` + + .. _plot-options: Plot Options diff --git a/lcviz/tests/test_plugin_flux_origin.py b/lcviz/tests/test_plugin_flux_origin.py index e44bb5ca..e4243818 100644 --- a/lcviz/tests/test_plugin_flux_origin.py +++ b/lcviz/tests/test_plugin_flux_origin.py @@ -1,6 +1,18 @@ from numpy.testing import assert_allclose +def test_docs_snippets(helper, light_curve_like_kepler_quarter): + lcviz, lc = helper, light_curve_like_kepler_quarter + + lcviz.load_data(lc) + # lcviz.show() + + flux_origin = lcviz.plugins['Flux Origin'] + print(flux_origin.flux_origin.choices) + # NOTE: choices for docs example are: ['sap_flux', 'sap_bkg', 'pdcsap_flux'] + flux_origin.flux_origin = 'flux_alt' + + def test_plugin_flux_origin(helper, light_curve_like_kepler_quarter): helper.load_data(light_curve_like_kepler_quarter)