Skip to content

DOCTEST: Use legacy float array printing for now #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nibabel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
from . import mriutils
from . import streamlines
from . import viewers
from .testing import setup_test

# Note test requirement for "mock". Requirement for "nose" tested by numpy.
try:
Expand Down
1 change: 1 addition & 0 deletions nibabel/affines.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np

from six.moves import reduce
from .testing import setup_test # flake8: noqa F401


class AffineError(ValueError):
Expand Down
1 change: 1 addition & 0 deletions nibabel/casting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from platform import processor, machine

import numpy as np
from .testing import setup_test # flake8: noqa F401


class CastingError(Exception):
Expand Down
1 change: 1 addition & 0 deletions nibabel/nicom/dwiparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'''
import numpy as np
import numpy.linalg as npl
from ..testing import setup_test # flake8: noqa F401


def B2q(B, tol=None):
Expand Down
1 change: 1 addition & 0 deletions nibabel/nifti1.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .spm99analyze import SpmAnalyzeHeader
from .casting import have_binary128
from .pydicom_compat import have_dicom, pydicom as pdcm
from .testing import setup_test # flake8: noqa F401

# nifti1 flat header definition for Analyze-like first 348 bytes
# first number in comments indicates offset in file header in bytes
Expand Down
1 change: 1 addition & 0 deletions nibabel/quaternions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import math
import numpy as np
from .testing import setup_test # flake8: noqa F401

MAX_FLOAT = np.maximum_sctype(np.float)
FLOAT_EPS = np.finfo(np.float).eps
Expand Down
10 changes: 10 additions & 0 deletions nibabel/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,13 @@ def assert_arr_dict_equal(dict1, dict2):
for key, value1 in dict1.items():
value2 = dict2[key]
assert_array_equal(value1, value2)


def setup_test():
""" Set numpy print options to "legacy" for new versions of numpy

If imported into a file, nosetest will run this before any doctests.
"""
from distutils.version import LooseVersion
if LooseVersion(np.__version__) >= LooseVersion('1.14'):
np.set_printoptions(sign='legacy')