File tree Expand file tree Collapse file tree 6 files changed +20
-14
lines changed Expand file tree Collapse file tree 6 files changed +20
-14
lines changed Original file line number Diff line number Diff line change 3535For 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
Original file line number Diff line number Diff line change 66import numpy as np
77
88from six .moves import reduce
9- from . import setup_test # noqa
109
1110
1211class AffineError (ValueError ):
Original file line number Diff line number Diff line change 88from platform import processor , machine
99
1010import numpy as np
11- from . import setup_test # noqa
1211
1312
1413class CastingError (Exception ):
Original file line number Diff line number Diff line change 2121'''
2222import numpy as np
2323import numpy .linalg as npl
24- from .. import setup_test as setup_module # noqa
2524
2625
2726def B2q (B , tol = None ):
Original file line number Diff line number Diff line change 2828from .spm99analyze import SpmAnalyzeHeader
2929from .casting import have_binary128
3030from .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
Original file line number Diff line number Diff line change 2727
2828import math
2929import numpy as np
30- from . import setup_test # noqa
3130
3231MAX_FLOAT = np .maximum_sctype (np .float )
3332FLOAT_EPS = np .finfo (np .float ).eps
You can’t perform that action at this time.
0 commit comments