Skip to content

Commit

Permalink
update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Dec 19, 2022
1 parent 9d9ee23 commit 9e85b73
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions jdaviz/configs/imviz/tests/test_linking.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def test_wcslink_rotated(self):
assert self.viewer.label_mouseover.value == '+1.00000e+00 '
assert self.viewer.label_mouseover.world_ra_deg == ''
assert self.viewer.label_mouseover.world_dec_deg == ''
assert not self.viewer.label_mouseover.unreliable_world
assert self.viewer.label_mouseover.unreliable_world
assert self.viewer.label_mouseover.unreliable_pixel

self.viewer.on_mouse_or_key_event({'event': 'keydown', 'key': 'b',
'domain': {'x': 0, 'y': 0}})
Expand All @@ -246,6 +247,7 @@ def test_wcslink_rotated(self):
assert self.viewer.label_mouseover.world_ra_deg == '3.5817255823'
assert self.viewer.label_mouseover.world_dec_deg == '-30.3920580740'
assert not self.viewer.label_mouseover.unreliable_world
assert not self.viewer.label_mouseover.unreliable_pixel

self.viewer.on_mouse_or_key_event({'event': 'keydown', 'key': 'b',
'domain': {'x': 0, 'y': 0}})
Expand All @@ -254,6 +256,7 @@ def test_wcslink_rotated(self):
assert self.viewer.label_mouseover.world_ra_deg == '3.5817255823'
assert self.viewer.label_mouseover.world_dec_deg == '-30.3920580740'
assert not self.viewer.label_mouseover.unreliable_world
assert not self.viewer.label_mouseover.unreliable_pixel

# Make sure GWCS now can extrapolate. Domain x,y is for FITS WCS data
# but they are linked by WCS.
Expand All @@ -264,8 +267,10 @@ def test_wcslink_rotated(self):
assert self.viewer.label_mouseover.value == ''
assert self.viewer.label_mouseover.world_ra_deg == '3.5815955408'
assert self.viewer.label_mouseover.world_dec_deg == '-30.3919405616'
# FITS WCS is reference data and has no concept of bounding box.
assert not self.viewer.label_mouseover.unreliable_world
# FITS WCS is reference data and has no concept of bounding box
# but cursor is outside GWCS bounding box
assert self.viewer.label_mouseover.unreliable_world
assert self.viewer.label_mouseover.unreliable_pixel


class TestLink_GWCS_GWCS(BaseImviz_GWCS_GWCS):
Expand All @@ -280,6 +285,7 @@ def test_wcslink_offset(self):
assert self.viewer.label_mouseover.world_ra_deg == '3.5817877198'
assert self.viewer.label_mouseover.world_dec_deg == '-30.3919358920'
assert self.viewer.label_mouseover.unreliable_world
assert self.viewer.label_mouseover.unreliable_pixel

# Non-reference image out of bounds of its own bounds but not of the
# reference image's bounds. Head hurting yet?
Expand All @@ -288,7 +294,8 @@ def test_wcslink_offset(self):
assert self.viewer.label_mouseover.value == ''
assert self.viewer.label_mouseover.world_ra_deg == '3.5816283341'
assert self.viewer.label_mouseover.world_dec_deg == '-30.3919519949'
assert not self.viewer.label_mouseover.unreliable_world
assert self.viewer.label_mouseover.unreliable_world
assert self.viewer.label_mouseover.unreliable_pixel

# Back to reference image
self.viewer.on_mouse_or_key_event({'event': 'keydown', 'key': 'b',
Expand All @@ -298,6 +305,7 @@ def test_wcslink_offset(self):
assert self.viewer.label_mouseover.world_ra_deg == '3.5816174030'
assert self.viewer.label_mouseover.world_dec_deg == '-30.3919481838'
assert not self.viewer.label_mouseover.unreliable_world
assert not self.viewer.label_mouseover.unreliable_pixel

# Still reference image but outside its own bounds.
self.viewer.on_mouse_or_key_event({'event': 'mousemove', 'domain': {'x': 10, 'y': 3}})
Expand All @@ -306,18 +314,19 @@ def test_wcslink_offset(self):
assert self.viewer.label_mouseover.world_ra_deg == '3.5817877198'
assert self.viewer.label_mouseover.world_dec_deg == '-30.3919358920'
assert self.viewer.label_mouseover.unreliable_world
assert not self.viewer.label_mouseover.unreliable_pixel

def test_pixel_linking(self):
self.imviz.link_data(link_type='pixels')

# Check the coordinates display: Last loaded is on top.
# When linked by pixel, there is no bounds check if image is not reference image.
self.viewer.on_mouse_or_key_event({'event': 'mousemove', 'domain': {'x': -1, 'y': -1}})
assert self.viewer.label_mouseover.pixel == 'x=-1.0 y=-1.0'
assert self.viewer.label_mouseover.value == ''
assert self.viewer.label_mouseover.world_ra_deg == '3.5816611274'
assert self.viewer.label_mouseover.world_dec_deg == '-30.3919634282'
assert not self.viewer.label_mouseover.unreliable_world
assert self.viewer.label_mouseover.unreliable_world
assert not self.viewer.label_mouseover.unreliable_pixel

# Back to reference image with bounds check.
self.viewer.on_mouse_or_key_event({'event': 'keydown', 'key': 'b',
Expand All @@ -327,6 +336,7 @@ def test_pixel_linking(self):
assert self.viewer.label_mouseover.world_ra_deg == '3.5815955408'
assert self.viewer.label_mouseover.world_dec_deg == '-30.3919405616'
assert self.viewer.label_mouseover.unreliable_world
assert not self.viewer.label_mouseover.unreliable_pixel


def test_imviz_no_data(imviz_helper):
Expand Down

0 comments on commit 9e85b73

Please sign in to comment.