Skip to content

Commit 0133dba

Browse files
committed
Merge branch 'numpy-114-fixes' into integration
* numpy-114-fixes: MAINT: try fixing latex doc build error MAINT: Use sympy master for doc build TST: adapt nipy doctests to numpy 1.14 NF: add np.allclose doctest modifier DOC: various docstring reformats
2 parents 21fd823 + b27b1e2 commit 0133dba

File tree

20 files changed

+132
-51
lines changed

20 files changed

+132
-51
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ matrix:
8080
- texlive-latex-extra
8181
- texlive-fonts-recommended
8282
- texlive-latex-recommended
83+
- latexmk
8384

8485
before_install:
8586
- source tools/travis_tools.sh
@@ -128,6 +129,9 @@ script:
128129
- |
129130
if [ "$DOC_BUILD" ]; then # doc build
130131
pip install -r doc-requirements.txt
132+
# Work round bug in Sympy atoms docstring as of 1.1.0
133+
# https://github.com/sympy/sympy/pull/12900
134+
pip install git+https://github.com/sympy/sympy.git
131135
make html-stamp pdf-stamp
132136
else
133137
# Change into an innocuous directory and find tests from installation

nipy/algorithms/registration/affine.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from ...externals.transforms3d.quaternions import mat2quat, quat2axangle
1010
from .transform import Transform
1111

12+
# Legacy repr printing from numpy.
13+
from nipy.testing import legacy_printing as setup_module # noqa
14+
1215
# Globals
1316
RADIUS = 100
1417
MAX_ANGLE = 1e10 * 2 * np.pi

nipy/algorithms/slicetiming/timefuncs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
import numpy as np
3232

33+
# Legacy repr printing from numpy.
34+
from nipy.testing import legacy_printing as setup_module # noqa
35+
3336
# Dictionary (key, value) == (name, function) for slice timing functions
3437
SLICETIME_FUNCTIONS = {}
3538

nipy/algorithms/statistics/formula/formulae.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@
128128

129129
from nipy.algorithms.utils.matrices import matrix_rank, full_rank
130130

131+
# Legacy repr printing from numpy.
132+
from nipy.testing import legacy_printing as setup_module # noqa
133+
134+
131135
@np.deprecate(message = "Please use sympy.Dummy instead of this function")
132136
def make_dummy(name):
133137
""" Make dummy variable of given name

nipy/algorithms/statistics/models/regression.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636

3737
from .model import LikelihoodModel, LikelihoodModelResults
3838

39+
# Legacy repr printing from numpy.
40+
from nipy.testing import legacy_printing as setup_module # noqa
41+
3942

4043
class OLSModel(LikelihoodModel):
4144
""" A simple ordinary least squares model.
@@ -342,9 +345,9 @@ class ARModel(OLSModel):
342345
AR coefficients: [-0.7220361 -1.05365352]
343346
AR coefficients: [-0.72229201 -1.05408193]
344347
AR coefficients: [-0.722278 -1.05405838]
345-
>>> results.theta #doctest: +FP_6DP
348+
>>> results.theta #doctest: +NP_ALLCLOSE
346349
array([ 1.59564228, -0.58562172])
347-
>>> results.t() #doctest: +FP_6DP
350+
>>> results.t() #doctest: +NP_ALLCLOSE
348351
array([ 38.0890515 , -3.45429252])
349352
>>> print(results.Tcontrast([0,1])) #doctest: +FP_6DP
350353
<T contrast: effect=-0.58562172384377043, sd=0.16953449108110835,

nipy/algorithms/statistics/models/utils.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
from __future__ import print_function
55
from __future__ import absolute_import
66

7+
__docformat__ = 'restructuredtext'
8+
79
import numpy as np
810
import scipy.interpolate
911

10-
__docformat__ = 'restructuredtext'
11-
1212

1313
def mad(a, c=0.6745, axis=0):
1414
"""
@@ -24,22 +24,24 @@ def mad(a, c=0.6745, axis=0):
2424

2525

2626
class StepFunction(object):
27-
"""
28-
A basic step function: values at the ends are handled in the simplest
29-
way possible: everything to the left of x[0] is set to ival; everything
30-
to the right of x[-1] is set to y[-1].
27+
""" A basic step function
28+
29+
Values at the ends are handled in the simplest way possible: everything to
30+
the left of ``x[0]`` is set to `ival`; everything to the right of ``x[-1]``
31+
is set to ``y[-1]``.
3132
3233
Examples
3334
--------
3435
>>> x = np.arange(20)
3536
>>> y = np.arange(20)
3637
>>> f = StepFunction(x, y)
3738
>>>
38-
>>> print(f(3.2))
39+
>>> f(3.2)
3940
3.0
40-
>>> print(f([[3.2,4.5],[24,-3.1]]))
41-
[[ 3. 4.]
42-
[ 19. 0.]]
41+
>>> res = f([[3.2, 4.5],[24, -3.1]])
42+
>>> np.all(res == [[ 3, 4],
43+
... [19, 0]])
44+
True
4345
"""
4446

4547
def __init__(self, x, y, ival=0., sorted=False):

nipy/algorithms/statistics/rft.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@
1717
from __future__ import absolute_import
1818

1919
import numpy as np
20-
from numpy.linalg import pinv
20+
from numpy.linalg import pinv
2121

2222
from scipy import stats
2323
from scipy.misc import factorial
2424
from scipy.special import gamma, gammaln, beta, hermitenorm
2525

26+
# Legacy repr printing from numpy.
27+
from nipy.testing import legacy_printing as setup_module # noqa
28+
29+
2630
def binomial(n, k):
2731
""" Binomial coefficient
2832

nipy/core/image/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
input_axis_index)
2828
from ..reference.array_coords import ArrayCoordMap
2929

30+
# Legacy repr printing from numpy.
31+
from nipy.testing import legacy_printing as setup_module # noqa
32+
3033

3134
class Image(object):
3235
""" The `Image` class provides the core object type used in nipy.

nipy/core/image/image_spaces.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
from ..reference import spaces as rsp
8181
from ..reference.coordinate_map import AffineTransform
8282

83+
# Legacy repr printing from numpy.
84+
from nipy.testing import legacy_printing as setup_module # noqa
85+
8386

8487
def xyz_affine(img, name2xyz=None):
8588
""" Return xyz affine from image `img` if possible, or raise error

nipy/core/reference/__init__.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
66
Mathematical model
77
==================
8-
The idea of a chart :lm:`\\phi` : I{U} S{sub} I{M} S{->} B{R}^k
9-
on a "manifold" I{M}. For a chart both input (I{M}) and output coordinates
10-
(B{R}^k) must be defined and a map relating the two coordinate systems.
8+
9+
The idea is of a chart $\phi : I{U} S{sub} I{M} S{->} B{R}^k$ on a "manifold"
10+
$I{M}$. For a chart, both input ($I{M}$) and output coordinates ($B{R}^k$)
11+
must be defined and there must be a map relating the two coordinate systems.
1112
1213
Description
1314
===========
15+
1416
The modules in this package contains classes which define the space in which an
1517
image exists and also functions for manipulating and traversing this space.
1618
@@ -19,22 +21,23 @@
1921
output CoordinateSystem, and a mapping which converts points in the
2022
input space to points in the output space.
2123
22-
A `CoordinateSystem` consists of a set of ordered `Coordinate` objects. Each
24+
A ``CoordinateSystem`` consists of a set of ordered ``Coordinate`` objects. Each
2325
Coordinate has a name and a builtin dtype.
2426
25-
The typical use of a `CoordinateMap` is to define how voxels in an `Image`
26-
(core.image.__init__.py) object's raw data map into real space.
27+
The typical use of a ``CoordinateMap`` is to define how voxels in an ``Image``
28+
(``core.image.__init__.py``) object's raw data map into real space.
2729
28-
`Image` traversal is general done in terms of the underlying coordinate_map, and a number of
29-
iterators are provided to traverse points in the coordinate_map (iterators.py). Access to
30-
available iterators is done through the CoordinateMap interface, rather than
31-
accessing the iterator classes directly.
32-
33-
The other common image access method is to take slices through the coordinate_map. In
34-
slices.py functions are presented which will return a `CoordinateMap` representing
35-
a single slice through a larger coordinate_map.
30+
``Image`` traversal is in general done in terms of the underlying
31+
coordinate_map, and a number of iterators are provided to traverse points in
32+
the coordinate_map (iterators.py). Access to available iterators is done
33+
through the CoordinateMap interface, rather than accessing the iterator classes
34+
directly.
3635
36+
The other common image access method is to take slices through the
37+
coordinate_map. In slices.py functions are presented which will return a
38+
``CoordinateMap`` representing a single slice through a larger coordinate_map.
3739
"""
40+
3841
from __future__ import absolute_import
3942
__docformat__ = 'restructuredtext'
4043

nipy/core/reference/array_coords.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
from .coordinate_map import shifted_range_origin
2525
from .coordinate_system import CoordinateSystem
2626

27+
# Legacy repr printing from numpy.
28+
from nipy.testing import legacy_printing as setup_module # noqa
29+
2730

2831
class ArrayCoordMap(object):
2932
""" Class combining coordinate map and array shape
@@ -187,6 +190,7 @@ def __repr__(self):
187190
return "ArrayCoordMap(\n coordmap=" + \
188191
'\n '.join(repr(self.coordmap).split('\n')) + ',\n shape=%s' % repr(self.shape) + '\n)'
189192

193+
190194
def _slice(coordmap, shape, *slices):
191195
"""
192196
Slice a 'voxel' CoordinateMap's function_domain with slices. A
@@ -264,7 +268,6 @@ def _slice(coordmap, shape, *slices):
264268
A = A.astype(function_domain.coord_dtype)
265269
slice_cmap = AffineTransform(function_domain, coordmap.function_domain, A)
266270
return ArrayCoordMap(compose(coordmap, slice_cmap), tuple(newshape))
267-
268271

269272

270273
class Grid(object):

nipy/core/reference/coordinate_map.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
This module describes two types of *mappings*:
55
66
* CoordinateMap: a general function from a domain to a range, with a possible
7-
inverse function.
8-
7+
inverse function;
98
* AffineTransform: an affine function from a domain to a range, not
10-
necessarily of the same dimension, hence not always invertible.
9+
necessarily of the same dimension, hence not always invertible.
1110
12-
Each of these objects is meant to encapsulate a tuple of
13-
(domain, range, function).
14-
Each of the mapping objects contain all the details about their domain
15-
CoordinateSystem, their range CoordinateSystem and the mapping between
11+
Each of these objects is meant to encapsulate a tuple of (domain, range,
12+
function). Each of the mapping objects contain all the details about their
13+
domain CoordinateSystem, their range CoordinateSystem and the mapping between
1614
them.
1715
1816
Common API
@@ -21,13 +19,16 @@
2119
They are separate classes, neither one inheriting from the other.
2220
They do, however, share some parts of an API, each having methods:
2321
24-
* renamed_domain : rename on the coordinates of the domain (returns a new mapping)
22+
* renamed_domain : rename on the coordinates of the domain (returns a new
23+
mapping)
2524
2625
* renamed_range : rename the coordinates of the range (returns a new mapping)
2726
28-
* reordered_domain : reorder the coordinates of the domain (returns a new mapping)
27+
* reordered_domain : reorder the coordinates of the domain (returns a new
28+
mapping)
2929
30-
* reordered_range : reorder the coordinates of the range (returns a new mapping)
30+
* reordered_range : reorder the coordinates of the range (returns a new
31+
mapping)
3132
3233
* inverse : when appropriate, return the inverse *mapping*
3334
@@ -45,20 +46,19 @@
4546
-----------------------------------------------
4647
4748
* compose : Take a sequence of mappings (either CoordinateMaps or
48-
AffineTransforms) and return their composition. If they are all
49-
AffineTransforms, an AffineTransform is returned. This checks to
50-
ensure that domains and ranges of the various mappings agree.
49+
AffineTransforms) and return their composition. If they are all
50+
AffineTransforms, an AffineTransform is returned. This checks to ensure that
51+
domains and ranges of the various mappings agree.
5152
* product : Take a sequence of mappings (either CoordinateMaps or
52-
AffineTransforms) and return a new mapping that has domain and range
53-
given by the concatenation of their domains and ranges, and the
54-
mapping simply concatenates the output of each of the individual
55-
mappings. If they are all AffineTransforms, an AffineTransform is
56-
returned. If they are all AffineTransforms that are in fact linear
57-
(i.e. origin=0) then can is represented as a block matrix with the
58-
size of the blocks determined by
53+
AffineTransforms) and return a new mapping that has domain and range given by
54+
the concatenation of their domains and ranges, and the mapping simply
55+
concatenates the output of each of the individual mappings. If they are all
56+
AffineTransforms, an AffineTransform is returned. If they are all
57+
AffineTransforms that are in fact linear (i.e. origin=0) then can is
58+
represented as a block matrix with the size of the blocks determined by
5959
* concat : Take a mapping and prepend a coordinate to its domain and
60-
range. For mapping `m`, this is the same as
61-
product(AffineTransform.identity('concat'), `m`)
60+
range. For mapping ``m``, this is the same as
61+
``product(AffineTransform.identity('concat'), m)``
6262
"""
6363
from __future__ import absolute_import
6464

@@ -76,6 +76,9 @@
7676
product as coordsys_product
7777
)
7878

79+
# Legacy repr printing from numpy.
80+
from nipy.testing import legacy_printing as setup_module # noqa
81+
7982
# shorthand
8083
CS = CoordinateSystem
8184

nipy/core/reference/spaces.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
from ...externals.six import string_types
1515

16+
# Legacy repr printing from numpy.
17+
from nipy.testing import legacy_printing as setup_module # noqa
18+
19+
1620
class XYZSpace(object):
1721
""" Class contains logic for spaces with XYZ coordinate systems
1822

nipy/core/reference/tests/test_coordinate_map.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
from numpy.testing import (assert_array_equal, assert_almost_equal, dec)
2626

27+
# Legacy repr printing from numpy.
28+
from nipy.testing import legacy_printing
2729

2830
# Dtypes for testing coordinate map creation / processing
2931
_SYMPY_SAFE_DTYPES = (np.sctypes['int'] + np.sctypes['uint'] +
@@ -62,6 +64,7 @@ def g(x):
6264
[ 8, 9, 10, 11],
6365
[ 8, 9, 10, 11],
6466
[ 0, 0, 0, 1]]))
67+
legacy_printing()
6568

6669

6770
def test_shift_origin():

nipy/core/utils/generators.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
from nipy.utils import seq_prod
2525

26+
# Legacy repr printing from numpy.
27+
from nipy.testing import legacy_printing as setup_module # noqa
28+
2629

2730
def parcels(data, labels=None, exclude=()):
2831
""" Return a generator for ``[data == label for label in labels]``

nipy/externals/transforms3d/quaternions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
from __future__ import absolute_import
1919

2020
import math
21+
2122
import numpy as np
2223

24+
# Legacy repr printing from numpy.
25+
from nipy.testing import legacy_printing as setup_module # noqa
26+
2327
_MAX_FLOAT = np.maximum_sctype(np.float)
2428
_FLOAT_EPS = np.finfo(np.float).eps
2529

nipy/modalities/fmri/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131

3232
from nipy.algorithms.statistics.formula.formulae import Term, Formula
3333

34+
# Legacy repr printing from numpy.
35+
from nipy.testing import legacy_printing as setup_module # noqa
36+
3437
T = Term('t')
3538

3639

0 commit comments

Comments
 (0)