Skip to content

Commit 2f1faf4

Browse files
committed
TEST: Create and import setup_test fixture into affected files
1 parent 600f7f2 commit 2f1faf4

File tree

6 files changed

+15
-29
lines changed

6 files changed

+15
-29
lines changed

nibabel/affines.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
""" Utility routines for working with points and affine transforms
4-
5-
.. testsetup::
6-
7-
from distutils.version import LooseVersion
8-
if LooseVersion(np.__version__) > LooseVersion('1.13.1'):
9-
np.set_printoptions(sign='legacy')
104
"""
115

126
import numpy as np
137

148
from six.moves import reduce
9+
from .testing import setup_test
1510

1611

1712
class AffineError(ValueError):

nibabel/casting.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22
33
Most routines work round some numpy oddities in floating point precision and
44
casting. Others work round numpy casting to and from python ints
5-
6-
.. testsetup::
7-
8-
from distutils.version import LooseVersion
9-
if LooseVersion(np.__version__) > LooseVersion('1.13.1'):
10-
np.set_printoptions(sign='legacy')
115
"""
126

137
from numbers import Integral
148
from platform import processor, machine
159

1610
import numpy as np
11+
from .testing import setup_test
1712

1813

1914
class CastingError(Exception):

nibabel/nicom/dwiparams.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@
1818
1919
B ~ (q_est . q_est.T) / norm(q_est)
2020
21-
.. testsetup::
22-
23-
from distutils.version import LooseVersion
24-
if LooseVersion(np.__version__) > LooseVersion('1.13.1'):
25-
np.set_printoptions(sign='legacy')
2621
'''
2722
import numpy as np
2823
import numpy.linalg as npl
24+
from ..testing import setup_test
2925

3026

3127
def B2q(B, tol=None):

nibabel/nifti1.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
''' Read / write access to NIfTI1 image format
1010
1111
NIfTI1 format defined at http://nifti.nimh.nih.gov/nifti-1/
12-
13-
.. testsetup::
14-
15-
from distutils.version import LooseVersion
16-
if LooseVersion(np.__version__) > LooseVersion('1.13.1'):
17-
np.set_printoptions(sign='legacy')
1812
'''
1913
from __future__ import division, print_function
2014
import warnings
@@ -33,6 +27,7 @@
3327
from .spm99analyze import SpmAnalyzeHeader
3428
from .casting import have_binary128
3529
from .pydicom_compat import have_dicom, pydicom as pdcm
30+
from .testing import setup_test
3631

3732
# nifti1 flat header definition for Analyze-like first 348 bytes
3833
# first number in comments indicates offset in file header in bytes

nibabel/quaternions.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,11 @@
2323
>>> M = quat2mat(q) # from this module
2424
>>> vec = np.array([1, 2, 3]).reshape((3,1)) # column vector
2525
>>> tvec = np.dot(M, vec)
26-
27-
.. testsetup::
28-
29-
from distutils.version import LooseVersion
30-
if LooseVersion(np.__version__) > LooseVersion('1.13.1'):
31-
np.set_printoptions(sign='legacy')
3226
'''
3327

3428
import math
3529
import numpy as np
30+
from .testing import setup_test
3631

3732
MAX_FLOAT = np.maximum_sctype(np.float)
3833
FLOAT_EPS = np.finfo(np.float).eps

nibabel/testing/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,13 @@ def assert_arr_dict_equal(dict1, dict2):
209209
for key, value1 in dict1.items():
210210
value2 = dict2[key]
211211
assert_array_equal(value1, value2)
212+
213+
214+
def setup_test():
215+
""" Set numpy print options to "legacy" for new versions of numpy
216+
217+
If imported into a file, nosetest will run this before any doctests.
218+
"""
219+
from distutils.version import LooseVersion
220+
if LooseVersion(np.__version__) > LooseVersion('1.13.1'):
221+
np.set_printoptions(sign='legacy')

0 commit comments

Comments
 (0)