Skip to content

Commit

Permalink
Add test for delete_pts
Browse files Browse the repository at this point in the history
  • Loading branch information
jni committed Dec 11, 2023
1 parent 39109e5 commit 004fc00
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/affinder/_tests/test_affinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,33 @@ def test_load_affine(tmp_path):
widget(layer, affile)

np.testing.assert_allclose(layer.affine, affine)


@pytest.mark.parametrize('remove_pts', [True, False])
def test_remove_points_layers(remove_pts, make_napari_viewer):
"""Check whether remove_points_layer option actually removes the layers."""
ref_im = np.random.random((5, 5))
mov_im = np.random.random((5, 5))
ref_pts = np.array([[1, 1], [2, 2], [1, 4]], dtype=float)
mov_pts = np.array([[4, 1], [2, 2], [1, 4]], dtype=float)

viewer = make_napari_viewer()
qtwidget, widget = viewer.window.add_plugin_dock_widget(
'affinder', 'Start affinder'
)
widget(
viewer=viewer,
reference=ref_im,
moving=mov_im,
model=AffineTransformChoices.affine,
delete_pts=remove_pts
)
viewer.layers['ref_im_pts'].data = ref_pts
viewer.layers['mov_im_pts'].data = mov_pts

widget() # close the widget

assert remove_pts != any(
pt_layer in viewer.layers
for pt_layer in ['ref_im_pts', 'mov_im_pts']
)

0 comments on commit 004fc00

Please sign in to comment.