Skip to content
Snippets Groups Projects
Commit 70216109 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

TEST: use fixture so we can see seed value. Make test more lenient

parent da579bd8
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ def test_help():
def test_linear():
def test_linear(seed):
with tempdir.tempdir():
src2ref = _random_affine()
......@@ -65,7 +65,7 @@ def test_linear():
assert np.all(np.isclose(result.data, expect))
def test_nonlinear():
def test_nonlinear(seed):
with tempdir.tempdir():
src2ref = _random_affine()
......@@ -92,7 +92,7 @@ def test_nonlinear():
assert np.all(np.isclose(result, expect))
def test_linear_altref():
def test_linear_altref(seed):
with tempdir.tempdir():
src2ref = affine.scaleOffsetXform([1, 1, 1], [5, 5, 5])
......@@ -119,7 +119,7 @@ def test_linear_altref():
assert np.all(result.data == expect)
def test_nonlinear_altref():
def test_nonlinear_altref(seed):
with tempdir.tempdir():
src2ref = affine.scaleOffsetXform([1, 1, 1], [5, 5, 5])
......@@ -149,7 +149,7 @@ def test_nonlinear_altref():
assert np.all(result.data == expect)
def test_linear_altsrc():
def test_linear_altsrc(seed):
with tempdir.tempdir():
src2ref = _random_affine()
......@@ -198,7 +198,7 @@ def test_linear_altsrc():
assert np.all(np.isclose(outoff.data, expoff))
def test_nonlinear_altsrc():
def test_nonlinear_altsrc(seed):
with tempdir.tempdir():
src2ref = _random_affine()
......@@ -252,13 +252,20 @@ def test_nonlinear_altsrc():
assert outhi .sameSpace(ref)
assert outoff.sameSpace(ref)
# We get boundary issues just at the first
# voxel, so I'm masking that voxel out
for img in (out, outlo, outhi, outoff,
exp, explo, exphi, expoff):
img[0, 0, 0] = 0
assert np.all(np.isclose(out .data, exp))
assert np.all(np.isclose(outlo .data, explo))
assert np.all(np.isclose(outhi .data, exphi))
assert np.all(np.isclose(outoff.data, expoff))
# We get boundary cropping,
# so ignore edge slices
out = out .data[1:-1, 1:-1, 1:-1]
outlo = outlo .data[1:-1, 1:-1, 1:-1]
outhi = outhi .data[1:-1, 1:-1, 1:-1]
outoff = outoff.data[1:-1, 1:-1, 1:-1]
exp = exp[ 1:-1, 1:-1, 1:-1]
explo = explo[ 1:-1, 1:-1, 1:-1]
exphi = exphi[ 1:-1, 1:-1, 1:-1]
expoff = expoff[ 1:-1, 1:-1, 1:-1]
tol = dict(atol=1e-3, rtol=1e-3)
assert np.all(np.isclose(out, exp, **tol))
assert np.all(np.isclose(outlo, explo, **tol))
assert np.all(np.isclose(outhi, exphi, **tol))
assert np.all(np.isclose(outoff, expoff, **tol))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment