Commit 0478c7c2 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'master' into 'master'

Unit tests

See merge request !30
parents b73d553e 8c3f56e9
Pipeline #775 failed with stages
in 32 minutes and 29 seconds
......@@ -31,10 +31,10 @@ def setup_module():
# or 'fslinfo ...'
def mock_check_output(args):
if args[0].endswith('fslinfo'):
return 'info'
return 'info'.encode('utf-8')
img = nib.load(args[-2])
return str(img.get_data().mean())
return str(img.get_data().mean()).encode('utf-8')
def test_callfsl():
......
......@@ -108,9 +108,11 @@ def test_scaleOffsetXform():
expected = [[float(v) for v in l.split()] for l in expected]
expected = np.array(expected)
result = transform.scaleOffsetXform(scales, offsets)
result1 = transform.scaleOffsetXform( scales, offsets)
result2 = transform.scaleOffsetXform(tuple(scales), tuple(offsets))
assert np.all(np.isclose(result, expected))
assert np.all(np.isclose(result1, expected))
assert np.all(np.isclose(result2, expected))
def test_compose_and_decompose():
......@@ -138,6 +140,19 @@ def test_compose_and_decompose():
assert np.all(np.isclose(xform, result, atol=1e-5))
# compose should also accept a rotation matrix
rots = [np.pi / 5, np.pi / 4, np.pi / 3]
rmat = transform.axisAnglesToRotMat(*rots)
xform = transform.compose([1, 1, 1], [0, 0, 0], rmat)
sc, of, rot = transform.decompose(xform)
sc = np.array(sc)
of = np.array(of)
rot = np.array(rot)
assert np.all(sc == [1, 1, 1])
assert np.all(of == [0, 0, 0])
assert np.all(np.isclose(rot, rots))
def test_axisBounds():
testfile = op.join(datadir, 'test_transform_test_axisBounds.txt')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment