From dca6233bf2a62764819d08d13c1af761a3b65447 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Tue, 27 Feb 2018 12:11:33 +0000 Subject: [PATCH] unit test for canonicalShape function --- tests/test_image.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/tests/test_image.py b/tests/test_image.py index 6d1ed0cfd..00a2cc749 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -284,7 +284,7 @@ def _test_Image_atts(imgtype): dims, pixdims, dtype = atts - expdims = imagewrapper.canonicalShape(dims) + expdims = fslimage.canonicalShape(dims) expndims = len(expdims) ndims = len(dims) pixdims = pixdims[:ndims] @@ -340,6 +340,33 @@ def _test_Image_atts2(imgtype): assert img.intent == intent +def test_canonicalShape(): + + # (input, expected) + tests = [ + ((10,), (10, 1, 1)), + ((10, 1), (10, 1, 1)), + ((10, 1, 1), (10, 1, 1)), + ((10, 1, 1, 1), (10, 1, 1)), + ((10, 1, 1, 1, 1), (10, 1, 1)), + ((10, 10), (10, 10, 1)), + ((10, 10, 1), (10, 10, 1)), + ((10, 10, 1, 1), (10, 10, 1)), + ((10, 10, 1, 1, 1), (10, 10, 1)), + ((10, 10, 10), (10, 10, 10)), + ((10, 10, 10, 1), (10, 10, 10)), + ((10, 10, 10, 1, 1), (10, 10, 10)), + ((10, 10, 10, 10), (10, 10, 10, 10)), + ((10, 10, 10, 10, 1), (10, 10, 10, 10)), + ((10, 10, 10, 10, 1, 1), (10, 10, 10, 10)), + ((10, 10, 10, 10, 10), (10, 10, 10, 10, 10)), + ((10, 10, 10, 10, 10, 1), (10, 10, 10, 10, 10)), + ] + + for input, expected in tests: + assert tuple(fslimage.canonicalShape(input)) == expected + + def test_looksLikeImage(): """Test the looksLikeImage function. """ -- GitLab