Skip to content

Commit

Permalink
test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Sep 15, 2023
1 parent a4ea5e5 commit 2780e97
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
47 changes: 47 additions & 0 deletions jdaviz/configs/imviz/tests/test_simple_aper_phot.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,53 @@ def test_plugin_wcs_dithered(self):
phot_plugin.vue_do_aper_phot()
assert phot_plugin.plot.figure.title == 'Curve of growth from aperture center'

def test_batch_unpack(self):
phot_plugin = self.imviz.app.get_tray_item_from_name('imviz-aper-phot-simple')

# NOTE: these input values are not currently validated, so it does not matter that the
# datasets and subsets do not exist with these names (if that changes, this test will
# need to be udpated accordingly)
unpacked = phot_plugin.unpack_batch_options(dataset=['image1', 'image2'],
subset=['Subset 1', 'Subset 2'],
bg_subset=['Subset 3'],
flux_scaling=3)
assert unpacked == [{'subset': 'Subset 1',
'dataset': 'image1',
'bg_subset': 'Subset 3',
'flux_scaling': 3},
{'subset': 'Subset 2',
'dataset': 'image1',
'bg_subset': 'Subset 3',
'flux_scaling': 3},
{'subset': 'Subset 1',
'dataset': 'image2',
'bg_subset': 'Subset 3',
'flux_scaling': 3},
{'subset': 'Subset 2',
'dataset': 'image2',
'bg_subset': 'Subset 3',
'flux_scaling': 3}]

def test_batch_phot(self):
self.imviz.link_data(link_type='wcs') # They are dithered by 1 pixel on X
self.imviz._apply_interactive_region('bqplot:truecircle', (0, 0), (9, 9)) # Draw a circle

phot_plugin = self.imviz.app.get_tray_item_from_name('imviz-aper-phot-simple')
assert phot_plugin.dataset.choices == ['has_wcs_1[SCI,1]', 'has_wcs_2[SCI,1]']
assert phot_plugin.subset.choices == ['Subset 1']

phot_plugin.batch_aper_phot([{'dataset': 'has_wcs_1[SCI,1]', 'subset': 'Subset 1'},
{'dataset': 'has_wcs_2[SCI,1]'}])

assert len(phot_plugin.table) == 2

with pytest.raises(RuntimeError):
phot_plugin.batch_aper_phot([{'dataset': 'has_wcs_1[SCI,1]', 'subset': 'DNE'},
{'dataset': 'has_wcs_2[SCI,1]', 'subset': 'Subset 1'}])

# second entry above should have been successful, resulting in one addition to the results
assert len(phot_plugin.table) == 3


class TestSimpleAperPhot_NoWCS(BaseImviz_WCS_NoWCS):
def test_plugin_no_wcs(self):
Expand Down
3 changes: 3 additions & 0 deletions jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,9 @@ def float_precision(column, item):
# clean data to show in the UI
self.items = self.items + [{k: json_safe(k, v) for k, v in item.items()}]

def __len__(self):
return len(self.items)

def clear_table(self):
"""
Clear all entries/markers from the current table.
Expand Down

0 comments on commit 2780e97

Please sign in to comment.