From 8fa6b2486407808ae315127e22850fa5efe6eec2 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 8 Mar 2024 14:00:27 -0500 Subject: [PATCH] include flux-vs-phase:default from init --- lcviz/plugins/viewer_creator/viewer_creator.py | 5 +++-- lcviz/tests/test_plugin_ephemeris.py | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lcviz/plugins/viewer_creator/viewer_creator.py b/lcviz/plugins/viewer_creator/viewer_creator.py index 8830e8be..c8dc3c8f 100644 --- a/lcviz/plugins/viewer_creator/viewer_creator.py +++ b/lcviz/plugins/viewer_creator/viewer_creator.py @@ -1,5 +1,5 @@ from jdaviz.configs.default.plugins import ViewerCreator -from jdaviz.core.events import NewViewerMessage +from jdaviz.core.events import NewViewerMessage, ViewerAddedMessage from jdaviz.core.registries import tool_registry from lcviz.events import EphemerisComponentChangedMessage from lcviz.viewers import TimeScatterView @@ -25,7 +25,8 @@ def _rebuild_available_viewers(self, *args): phase_viewers = [{'name': f'lcviz-phase-viewer:{e}', 'label': f'flux-vs-phase:{e}'} for e in self.app._jdaviz_helper.plugins['Ephemeris'].component.choices] # noqa else: - phase_viewers = [] + phase_viewers = [{'name': 'lcviz-phase-viewer:default', + 'label': 'flux-vs-phase:default'}] self.viewer_types = [v for v in self.viewer_types if v['name'].startswith('lcviz') and not v['label'].startswith('flux-vs-phase')] + phase_viewers diff --git a/lcviz/tests/test_plugin_ephemeris.py b/lcviz/tests/test_plugin_ephemeris.py index 303ecf1d..dea97b68 100644 --- a/lcviz/tests/test_plugin_ephemeris.py +++ b/lcviz/tests/test_plugin_ephemeris.py @@ -118,9 +118,9 @@ def test_create_phase_viewer(helper, light_curve_like_kepler_quarter): ephem = helper.plugins['Ephemeris'] vc = helper._tray_tools['lcviz-viewer-creator'] - assert len(vc.viewer_types) == 1 # just time viewer + assert len(vc.viewer_types) == 2 # time viewer, phase viewer for default _ = ephem.create_phase_viewer() - assert len(vc.viewer_types) == 2 + assert len(ephem._obj._get_phase_viewers()) == 1 vc.vue_create_viewer('flux-vs-phase:default') assert len(ephem._obj._get_phase_viewers()) == 2 @@ -134,3 +134,6 @@ def test_create_phase_viewer(helper, light_curve_like_kepler_quarter): for pv in ephem._obj._get_phase_viewers(): assert pv._ephemeris_component == 'renamed' + + ephem.add_component('new') + assert len(vc.viewer_types) == 3