Skip to content

Commit

Permalink
basic test coverage and API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Aug 7, 2023
1 parent a61d36c commit bc79cdf
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
32 changes: 32 additions & 0 deletions jdaviz/configs/imviz/plugins/footprints/footprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,38 @@ class Footprints(PluginTemplateMixin, ViewerSelectMixin):
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray`
* ``footprint`` (:class:`~jdaviz.core.template_mixin.EditableSelectPluginComponent`): the
currently active footprint (all other traitlets control this footprint instance)
* :meth:``rename_footprint``
rename any footprint
* :meth:``add_footprint``
add a new footprint instance (and select as active)
* :meth:``remove_footprint``
remove any footprint
* ``viewer`` (:class:`~jdaviz.core.template_mixin.ViewerSelect`):
viewer(s) to show the current footprint
* ``visible``
whether the currently selected footprint should be visible in the selected viewers
* ``color``
color of the currently selected footprint overlay
* ``fill_opacity``
opacity of the filled region of the currently selected footprint overlay
* ``instrument`` (:class:`~jdaviz.core.template_mixin.SelectPluginComponent`):
selected instrument
* ``ra``
central right ascension for the footprint overlay
* ``dec``
central declination (in degrees) for the footprint overlay
* ``pa``
position angle (in degrees) measured from North to central vertical axis in North to East
direction.
* ``v2_offset``
Additional V2 offset in telescope coordinates to apply to instrument center, as from a
dither pattern.
* ``v3_offset``
Additional V3 offset in telescope coordinates to apply to instrument center, as from a
dither pattern.
* :meth:``footprint_regions``
"""
template_file = __file__, "footprints.vue"
uses_active_status = Bool(True).tag(sync=True)
Expand Down
2 changes: 2 additions & 0 deletions jdaviz/configs/imviz/plugins/footprints/preset_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
__all__ = [
"_has_pysiaf",
"_instruments",
"_full_apertures",
"_all_apertures",
"jwst_footprint"
]

Expand Down
25 changes: 23 additions & 2 deletions jdaviz/configs/imviz/plugins/footprints/tests/test_footprints.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
def test_user_api(imviz_helper):
import numpy as np

from astropy.nddata import NDData

from jdaviz.core.marks import FootprintOverlay
from jdaviz.configs.imviz.plugins.footprints.preset_regions import _all_apertures


def _get_markers_from_viewer(viewer):
return [m for m in viewer.figure.marks if isinstance(m, FootprintOverlay)]


def test_user_api(imviz_helper, image_2d_wcs):
arr = np.ones((10, 10))
ndd = NDData(arr, wcs=image_2d_wcs)
imviz_helper.load_data(ndd)

plugin = imviz_helper.plugins['Footprints']
plugin.plugin_opened = True
with plugin.as_active():
for instrument in plugin.instrument.choices:
plugin.instrument = instrument

viewer_marks = _get_markers_from_viewer(imviz_helper.default_viewer)
assert len(viewer_marks) == len(_all_apertures.get(instrument))
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ test = [
"pytest",
"pytest-astropy",
"pytest-tornasync",
"pysiaf"
]
docs = [
"sphinx-astropy[confv2]>=1.9.1",
Expand Down

0 comments on commit bc79cdf

Please sign in to comment.