Skip to content

Commit 1ea55de

Browse files
committed
TEST: Normalize array printing ourselves
1 parent 55ee3f1 commit 1ea55de

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

nipype/conftest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
import numpy
33
import os
4-
from distutils.version import LooseVersion
54

65
DATADIR = os.path.realpath(
76
os.path.join(os.path.dirname(__file__), 'testing/data'))
@@ -20,5 +19,3 @@ def in_testing(request):
2019
# This seems to be a reliable way to distinguish tests from doctests
2120
if request.function is None:
2221
os.chdir(DATADIR)
23-
if LooseVersion(numpy.__version__) >= LooseVersion('1.14'):
24-
numpy.set_printoptions(legacy="1.13")

nipype/interfaces/image.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ class Reorient(SimpleInterface):
5050
Examples
5151
--------
5252
53+
.. testsetup::
54+
55+
>>> def print_affine(matrix):
56+
... print(str(matrix).translate(dict(zip(b'[]', ' '))))
57+
58+
.. doctest::
59+
5360
If an image is not reoriented, the original file is not modified
5461
5562
>>> import numpy as np
@@ -60,22 +67,22 @@ class Reorient(SimpleInterface):
6067
>>> res.outputs.out_file
6168
'segmentation0.nii.gz'
6269
63-
>>> print(np.loadtxt(res.outputs.transform))
64-
[[ 1. 0. 0. 0.]
65-
[ 0. 1. 0. 0.]
66-
[ 0. 0. 1. 0.]
67-
[ 0. 0. 0. 1.]]
70+
>>> print_affine(np.loadtxt(res.outputs.transform))
71+
1. 0. 0. 0.
72+
0. 1. 0. 0.
73+
0. 0. 1. 0.
74+
0. 0. 0. 1.
6875
6976
>>> reorient.inputs.orientation = 'RAS'
7077
>>> res = reorient.run()
7178
>>> res.outputs.out_file # doctest: +ELLIPSIS
7279
'.../segmentation0_ras.nii.gz'
7380
74-
>>> print(np.loadtxt(res.outputs.transform))
75-
[[ -1. 0. 0. 60.]
76-
[ 0. -1. 0. 72.]
77-
[ 0. 0. 1. 0.]
78-
[ 0. 0. 0. 1.]]
81+
>>> print_affine(np.loadtxt(res.outputs.transform))
82+
-1. 0. 0. 60.
83+
0. -1. 0. 72.
84+
0. 0. 1. 0.
85+
0. 0. 0. 1.
7986
8087
.. testcleanup::
8188

0 commit comments

Comments
 (0)