Skip to content

Commit d1bd90e

Browse files
committed
Merge remote-tracking branch 'upstream/master' into rel/2.5.0
2 parents ced392b + 7ee4aa6 commit d1bd90e

File tree

12 files changed

+51
-28
lines changed

12 files changed

+51
-28
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
url = git://github.com/matthew-brett/nitest-minc2.git
77
[submodule "nipy-ecattest"]
88
path = nibabel-data/nipy-ecattest
9-
url = https://github.com/freec84/nipy-ecattest
9+
url = https://github.com/effigies/nipy-ecattest
1010
[submodule "nibabel-data/nitest-freesurfer"]
1111
path = nibabel-data/nitest-freesurfer
1212
url = https://bitbucket.org/nipy/nitest-freesurfer.git

nibabel/__init__.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,27 @@
3535
For more detailed information see the :ref:`manual`.
3636
"""
3737

38-
39-
def setup_test():
40-
""" Set numpy print options to "legacy" for new versions of numpy
41-
42-
If imported into a file, nosetest will run this before any doctests.
43-
"""
44-
import numpy
38+
# Package-wide test setup and teardown
39+
_test_states = {
40+
# Numpy changed print options in 1.14; we can update docstrings and remove
41+
# these when our minimum for building docs exceeds that
42+
'legacy_printopt': None,
43+
}
44+
45+
def setup_package():
46+
""" Set numpy print style to legacy="1.13" for newer versions of numpy """
47+
import numpy as np
4548
from distutils.version import LooseVersion
46-
if LooseVersion(numpy.__version__) >= LooseVersion('1.14'):
47-
numpy.set_printoptions(legacy="1.13")
49+
if LooseVersion(np.__version__) >= LooseVersion('1.14'):
50+
if _test_states.get('legacy_printopt') is None:
51+
_test_states['legacy_printopt'] = np.get_printoptions().get('legacy')
52+
np.set_printoptions(legacy="1.13")
53+
54+
def teardown_package():
55+
""" Reset print options when tests finish """
56+
import numpy as np
57+
if _test_states.get('legacy_printopt') is not None:
58+
np.set_printoptions(legacy=_test_states.pop('legacy_printopt'))
4859

4960

5061
# module imports

nibabel/affines.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import numpy as np
77

88
from six.moves import reduce
9-
from . import setup_test # noqa
109

1110

1211
class AffineError(ValueError):

nibabel/brikhead.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ def __init__(self, info):
295295
--------
296296
>>> fname = os.path.join(datadir, 'example4d+orig.HEAD')
297297
>>> header = AFNIHeader(parse_AFNI_header(fname))
298-
>>> header.get_data_dtype()
299-
dtype('int16')
298+
>>> header.get_data_dtype().str
299+
'<i2'
300300
>>> header.get_zooms()
301301
(3.0, 3.0, 3.0, 3.0)
302302
>>> header.get_data_shape()

nibabel/casting.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from platform import processor, machine
99

1010
import numpy as np
11-
from . import setup_test # noqa
1211

1312

1413
class CastingError(Exception):

nibabel/ecat.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,9 @@ def _check_affines(self):
559559
affs = [self.get_frame_affine(i) for i in range(nframes)]
560560
if affs:
561561
i = iter(affs)
562-
first = i.next()
562+
first = next(i)
563563
for item in i:
564-
if not np.all(first == item):
564+
if not np.allclose(first, item):
565565
return False
566566
return True
567567

@@ -760,7 +760,7 @@ def __init__(self, dataobj, affine, header,
760760
761761
Parameters
762762
----------
763-
dataabj : array-like
763+
dataobj : array-like
764764
image data
765765
affine : None or (4,4) array-like
766766
homogeneous affine giving relationship between voxel coords and
@@ -811,6 +811,7 @@ def __init__(self, dataobj, affine, header,
811811
file_map = self.__class__.make_file_map()
812812
self.file_map = file_map
813813
self._data_cache = None
814+
self._fdata_cache = None
814815

815816
@property
816817
def affine(self):

nibabel/nicom/dwiparams.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
'''
2222
import numpy as np
2323
import numpy.linalg as npl
24-
from .. import setup_test as setup_module # noqa
2524

2625

2726
def B2q(B, tol=None):

nibabel/nifti1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from .spm99analyze import SpmAnalyzeHeader
2929
from .casting import have_binary128
3030
from .pydicom_compat import have_dicom, pydicom as pdcm
31-
from . import setup_test # noqa
3231

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

nibabel/quaternions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
import math
2929
import numpy as np
30-
from . import setup_test # noqa
3130

3231
MAX_FLOAT = np.maximum_sctype(np.float)
3332
FLOAT_EPS = np.finfo(np.float).eps

0 commit comments

Comments
 (0)