From d56ea0d2c4c18045a49421a5b5ba5b82587fea04 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sat, 13 Jun 2020 12:45:52 -0400 Subject: [PATCH 1/3] MAINT: Set minimum numpy to 1.14 --- min-requirements.txt | 2 +- requirements.txt | 2 +- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/min-requirements.txt b/min-requirements.txt index 0d749072bf..811270d582 100644 --- a/min-requirements.txt +++ b/min-requirements.txt @@ -1,3 +1,3 @@ # Auto-generated by tools/update_requirements.py -numpy ==1.13 +numpy ==1.14 packaging ==14.3 diff --git a/requirements.txt b/requirements.txt index 3134ffd33c..06e3bf4989 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ # Auto-generated by tools/update_requirements.py -numpy >=1.13 +numpy >=1.14 packaging >=14.3 diff --git a/setup.cfg b/setup.cfg index 824a8bb5c3..c2bf604f94 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,7 +29,7 @@ provides = [options] python_requires = >=3.6 install_requires = - numpy >=1.13 + numpy >=1.14 packaging >=14.3 zip_safe = False packages = find: From 11f554f42fb6576c31fb0c5ac5420530fdaf9ea3 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sat, 13 Jun 2020 12:48:04 -0400 Subject: [PATCH 2/3] TEST: Drop numpy 1.13 doctest compatibility --- nibabel/conftest.py | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 nibabel/conftest.py diff --git a/nibabel/conftest.py b/nibabel/conftest.py deleted file mode 100644 index 243ea957e2..0000000000 --- a/nibabel/conftest.py +++ /dev/null @@ -1,15 +0,0 @@ -import pytest - - -@pytest.fixture(autouse=True, scope="session") -def set_printopts(): - import numpy as np - from distutils.version import LooseVersion - - if LooseVersion(np.__version__) >= LooseVersion("1.14"): - legacy_printopt = np.get_printoptions().get("legacy") - np.set_printoptions(legacy="1.13") - yield - np.set_printoptions(legacy=legacy_printopt) - else: - yield From a37130597db71304c908b856988197f8e9668ca4 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sun, 14 Jun 2020 00:52:34 -0400 Subject: [PATCH 3/3] TEST: Update doctests to use new numpy print format --- nibabel/affines.py | 12 ++++++------ nibabel/brikhead.py | 2 +- nibabel/casting.py | 2 +- nibabel/nicom/dwiparams.py | 12 ++++++------ nibabel/nifti1.py | 24 ++++++++++++------------ nibabel/quaternions.py | 4 ++-- nibabel/volumeutils.py | 2 +- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/nibabel/affines.py b/nibabel/affines.py index 87bec4be07..915167ab7a 100644 --- a/nibabel/affines.py +++ b/nibabel/affines.py @@ -205,12 +205,12 @@ def append_diag(aff, steps, starts=()): >>> aff = np.eye(4) >>> aff[:3,:3] = np.arange(9).reshape((3,3)) >>> append_diag(aff, [9, 10], [99,100]) - array([[ 0., 1., 2., 0., 0., 0.], - [ 3., 4., 5., 0., 0., 0.], - [ 6., 7., 8., 0., 0., 0.], - [ 0., 0., 0., 9., 0., 99.], - [ 0., 0., 0., 0., 10., 100.], - [ 0., 0., 0., 0., 0., 1.]]) + array([[ 0., 1., 2., 0., 0., 0.], + [ 3., 4., 5., 0., 0., 0.], + [ 6., 7., 8., 0., 0., 0.], + [ 0., 0., 0., 9., 0., 99.], + [ 0., 0., 0., 0., 10., 100.], + [ 0., 0., 0., 0., 0., 1.]]) """ aff = np.asarray(aff) steps = np.atleast_1d(steps) diff --git a/nibabel/brikhead.py b/nibabel/brikhead.py index 2afd5b2c89..1b328cbb6b 100644 --- a/nibabel/brikhead.py +++ b/nibabel/brikhead.py @@ -421,7 +421,7 @@ def get_data_scaling(self): >>> fname = os.path.join(datadir, 'scaled+tlrc.HEAD') >>> header = AFNIHeader(parse_AFNI_header(fname)) >>> header.get_data_scaling() - array([ 3.88336300e-08]) + array([3.883363e-08]) """ # BRICK_FLOAT_FACS has one value per sub-brick, such that the scaled # values for sub-brick array [n] are the values read from disk * diff --git a/nibabel/casting.py b/nibabel/casting.py index 8406824dbe..8e3b547686 100644 --- a/nibabel/casting.py +++ b/nibabel/casting.py @@ -585,7 +585,7 @@ def int_abs(arr): >>> int_abs(np.array([-128, 127], dtype=np.int8)) array([128, 127], dtype=uint8) >>> int_abs(np.array([-128, 127], dtype=np.float32)) - array([ 128., 127.], dtype=float32) + array([128., 127.], dtype=float32) """ arr = np.array(arr, copy=False) dt = arr.dtype diff --git a/nibabel/nicom/dwiparams.py b/nibabel/nicom/dwiparams.py index 6146897377..62b28cb7e3 100644 --- a/nibabel/nicom/dwiparams.py +++ b/nibabel/nicom/dwiparams.py @@ -89,9 +89,9 @@ def nearest_pos_semi_def(B): -------- >>> B = np.diag([1, 1, -1]) >>> nearest_pos_semi_def(B) - array([[ 0.75, 0. , 0. ], - [ 0. , 0.75, 0. ], - [ 0. , 0. , 0. ]]) + array([[0.75, 0. , 0. ], + [0. , 0.75, 0. ], + [0. , 0. , 0. ]]) """ B = np.asarray(B) vals, vecs = npl.eigh(B) @@ -146,11 +146,11 @@ def q2bg(q_vector, tol=1e-5): Examples -------- >>> q2bg([1, 0, 0]) - (1.0, array([ 1., 0., 0.])) + (1.0, array([1., 0., 0.])) >>> q2bg([0, 10, 0]) - (10.0, array([ 0., 1., 0.])) + (10.0, array([0., 1., 0.])) >>> q2bg([0, 0, 0]) - (0.0, array([ 0., 0., 0.])) + (0.0, array([0., 0., 0.])) """ q_vec = np.asarray(q_vector) norm = np.sqrt(np.sum(q_vec * q_vec)) diff --git a/nibabel/nifti1.py b/nibabel/nifti1.py index 202decd8e0..0be9080661 100644 --- a/nibabel/nifti1.py +++ b/nibabel/nifti1.py @@ -1879,10 +1879,10 @@ def set_qform(self, affine, code=None, strip_shears=True, **kwargs): >>> aff = np.diag([2, 3, 4, 1]) >>> img = Nifti1Pair(data, aff) >>> img.get_qform() - array([[ 2., 0., 0., 0.], - [ 0., 3., 0., 0.], - [ 0., 0., 4., 0.], - [ 0., 0., 0., 1.]]) + array([[2., 0., 0., 0.], + [0., 3., 0., 0.], + [0., 0., 4., 0.], + [0., 0., 0., 1.]]) >>> img.get_qform(coded=True) (None, 0) >>> aff2 = np.diag([3, 4, 5, 1]) @@ -1962,16 +1962,16 @@ def set_sform(self, affine, code=None, **kwargs): >>> aff = np.diag([2, 3, 4, 1]) >>> img = Nifti1Pair(data, aff) >>> img.get_sform() - array([[ 2., 0., 0., 0.], - [ 0., 3., 0., 0.], - [ 0., 0., 4., 0.], - [ 0., 0., 0., 1.]]) + array([[2., 0., 0., 0.], + [0., 3., 0., 0.], + [0., 0., 4., 0.], + [0., 0., 0., 1.]]) >>> saff, code = img.get_sform(coded=True) >>> saff - array([[ 2., 0., 0., 0.], - [ 0., 3., 0., 0.], - [ 0., 0., 4., 0.], - [ 0., 0., 0., 1.]]) + array([[2., 0., 0., 0.], + [0., 3., 0., 0.], + [0., 0., 4., 0.], + [0., 0., 0., 1.]]) >>> int(code) 2 >>> aff2 = np.diag([3, 4, 5, 1]) diff --git a/nibabel/quaternions.py b/nibabel/quaternions.py index cd3646853d..d9769bcba9 100644 --- a/nibabel/quaternions.py +++ b/nibabel/quaternions.py @@ -466,13 +466,13 @@ def quat2angle_axis(quat, identity_thresh=None): >>> np.allclose(theta, np.pi) True >>> vec - array([ 1., 0., 0.]) + array([1., 0., 0.]) If this is an identity rotation, we return a zero angle and an arbitrary vector >>> quat2angle_axis([1, 0, 0, 0]) - (0.0, array([ 1., 0., 0.])) + (0.0, array([1., 0., 0.])) Notes ----- diff --git a/nibabel/volumeutils.py b/nibabel/volumeutils.py index 606e06f52f..78fc5218b5 100644 --- a/nibabel/volumeutils.py +++ b/nibabel/volumeutils.py @@ -1200,7 +1200,7 @@ def int_scinter_ftype(ifmt, slope=1.0, inter=0.0, default=np.float32): >>> arr = np.array([np.finfo(np.float32).max], dtype=np.float32) >>> res = arr + np.iinfo(np.int16).max >>> arr == res - array([ True], dtype=bool) + array([ True]) """ ii = np.iinfo(ifmt) tst_arr = np.array([ii.min, ii.max], dtype=ifmt)