File tree 6 files changed +20
-14
lines changed
6 files changed +20
-14
lines changed Original file line number Diff line number Diff line change 35
35
For more detailed information see the :ref:`manual`.
36
36
"""
37
37
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
45
48
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' ))
48
59
49
60
50
61
# module imports
Original file line number Diff line number Diff line change 6
6
import numpy as np
7
7
8
8
from six .moves import reduce
9
- from . import setup_test # noqa
10
9
11
10
12
11
class AffineError (ValueError ):
Original file line number Diff line number Diff line change 8
8
from platform import processor , machine
9
9
10
10
import numpy as np
11
- from . import setup_test # noqa
12
11
13
12
14
13
class CastingError (Exception ):
Original file line number Diff line number Diff line change 21
21
'''
22
22
import numpy as np
23
23
import numpy .linalg as npl
24
- from .. import setup_test as setup_module # noqa
25
24
26
25
27
26
def B2q (B , tol = None ):
Original file line number Diff line number Diff line change 28
28
from .spm99analyze import SpmAnalyzeHeader
29
29
from .casting import have_binary128
30
30
from .pydicom_compat import have_dicom , pydicom as pdcm
31
- from . import setup_test # noqa
32
31
33
32
# nifti1 flat header definition for Analyze-like first 348 bytes
34
33
# first number in comments indicates offset in file header in bytes
Original file line number Diff line number Diff line change 27
27
28
28
import math
29
29
import numpy as np
30
- from . import setup_test # noqa
31
30
32
31
MAX_FLOAT = np .maximum_sctype (np .float )
33
32
FLOAT_EPS = np .finfo (np .float ).eps
You can’t perform that action at this time.
0 commit comments