diff --git a/src/affinder/_tests/load_test/2D_test_affine.txt b/src/affinder/_tests/load_test/2D_test_affine.txt deleted file mode 100644 index 8eb30a5..0000000 --- a/src/affinder/_tests/load_test/2D_test_affine.txt +++ /dev/null @@ -1,3 +0,0 @@ -2.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00 -0.000000000000000000e+00,2.000000000000000000e+00,0.000000000000000000e+00 -0.000000000000000000e+00,0.000000000000000000e+00,1.000000000000000000e+00 diff --git a/src/affinder/_tests/test_affinder.py b/src/affinder/_tests/test_affinder.py index efb1900..ef5f0c7 100644 --- a/src/affinder/_tests/test_affinder.py +++ b/src/affinder/_tests/test_affinder.py @@ -139,17 +139,17 @@ def test_apply_affine_nonimage(): widget(ref_layer, mov_layer) -def test_load_affine(): - existing_affine = np.array([[0.9, 0.1, 5], [0.4, 0.2, 9], [0, 0, 1]]) +def test_load_affine(tmp_path): + affile = tmp_path / 'test_affine.txt' + affine = np.array([[2, 0, 5], [0, 2, 5], [0, 0, 1]]) + np.savetxt(affile, affine, delimiter=',') layer = napari.layers.Image(np.random.random((5, 5))) - layer.affine = existing_affine - widget = load_affine(, - widget(layer, './src/affinder/_tests/load_test/2d_test_affine.txt') + widget = load_affine() + widget(layer, affile) + np.testing.assert_allclose( - layer.affine, - np.loadtxt('./src/affinder/_tests/load_test/2d_test_affine.txt', - delimiter=',') @ existing_affine - ) + layer.affine, affine + ) diff --git a/src/affinder/load_tf.py b/src/affinder/load_tf.py index e30a9a1..43bebe2 100644 --- a/src/affinder/load_tf.py +++ b/src/affinder/load_tf.py @@ -1,10 +1,12 @@ +from pathlib import Path + import numpy as np from magicgui import magic_factory from napari.layers import Layer -@magic_factory(call_button='Load') -def load_affine(layer: Layer, affine: str): +@magic_factory(call_button='Load', affine={'mode': 'r'}) +def load_affine(layer: Layer, affine: Path): """Load affine from string. Parameters @@ -15,4 +17,4 @@ def load_affine(layer: Layer, affine: str): Affine to load. """ affine = np.loadtxt(affine, delimiter=',') - layer.affine = affine @ layer.affine + layer.affine = affine