Skip to content

Commit

Permalink
fix centering on click test
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Jan 12, 2024
1 parent 131a412 commit e366643
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 1 addition & 4 deletions jdaviz/configs/imviz/plugins/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ def on_click(self, data):
if x is None or y is None: # Out of bounds
return
x, y, _, _ = self.viewer._get_real_xy(image, x, y)
if image.coords is not None:
self.viewer.center_on(image.coords.pixel_to_world(x, y))
else:
self.viewer.center_on((x, y))
self.viewer.center_on((x, y))


@viewer_tool
Expand Down
7 changes: 3 additions & 4 deletions jdaviz/configs/imviz/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,17 @@ def test_panzoom_tools(self):
t_normpan.activate()
t_normpan.on_click({'event': 'click', 'domain': {'x': 1, 'y': 1}})
# make sure only first viewer re-centered since this mode is not linked mode
assert_allclose((v.state.x_min, v.state.x_max, v.state.y_min, v.state.y_max), (-1.5, 5.5, -2.5, 4.5)) # noqa
assert_allclose((v.state.x_min, v.state.x_max, v.state.y_min, v.state.y_max), (-2.5, 4.5, -2.5, 4.5)) # noqa
assert_allclose((v2.state.x_min, v2.state.x_max, v2.state.y_min, v2.state.y_max), (-3.5, 3.5, -3.5, 3.5)) # noqa
t_normpan.deactivate()

t_linkedpan.activate()
t_linkedpan.on_click({'event': 'click', 'domain': {'x': 2, 'y': 2}})
# make sure both viewers moved to the new center
assert_allclose((v.state.x_min, v.state.x_max, v.state.y_min, v.state.y_max), (-0.5, 6.5, -1.5, 5.5)) # noqa
assert_allclose((v2.state.x_min, v2.state.x_max, v2.state.y_min, v2.state.y_max), (-0.5, 6.5, -1.5, 5.5)) # noqa
assert_allclose((v.state.x_min, v.state.x_max, v.state.y_min, v.state.y_max), (-1.5, 5.5, -1.5, 5.5)) # noqa
assert_allclose((v2.state.x_min, v2.state.x_max, v2.state.y_min, v2.state.y_max), (-1.5, 5.5, -1.5, 5.5)) # noqa
t_linkedpan.deactivate()


# We use a new test class to avoid a dirty state from previous test.
class TestSinglePixelRegion(BaseImviz_WCS_WCS):
def test_singlepixelregion(self):
Expand Down

0 comments on commit e366643

Please sign in to comment.