Skip to content

Commit d49e829

Browse files
committed
BF: remove another use of unsafe dtypes
Sympy going into an infinite recursion with use of np.longcomplex.
1 parent 29732b8 commit d49e829

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

nipy/core/reference/tests/test_coordinate_map.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
from numpy.testing import (assert_array_equal, assert_almost_equal, dec)
2626

2727

28+
# Dtypes for testing coordinate map creation / processing
29+
_SYMPY_SAFE_DTYPES = (np.sctypes['int'] + np.sctypes['uint'] +
30+
np.sctypes['float'] + np.sctypes['complex'] +
31+
[np.object])
32+
# Sympy <= 1.1 does not handle numpy longcomplex correctly. See:
33+
# https://github.com/sympy/sympy/pull/12901
34+
_SYMPY_SAFE_DTYPES.remove(np.longcomplex)
35+
36+
2837
class empty(object):
2938
pass
3039

@@ -939,15 +948,10 @@ def test_make_cmap():
939948
def test_dtype_cmap_inverses():
940949
# Check that we can make functional inverses of AffineTransforms, and
941950
# CoordinateMap versions of AffineTransforms
942-
dtypes = (np.sctypes['int'] + np.sctypes['uint'] + np.sctypes['float']
943-
+ np.sctypes['complex'] + [np.object])
944-
# Sympy <= 1.1 does not handle numpy longcomplex correctly. See:
945-
# https://github.com/sympy/sympy/pull/12901
946-
dtypes.remove(np.longcomplex)
947951
arr_p1 = np.eye(4)[:, [0, 2, 1, 3]]
948952
in_list = [0, 1, 2]
949953
out_list = [0, 2, 1]
950-
for dt in dtypes:
954+
for dt in _SYMPY_SAFE_DTYPES:
951955
in_cs = CoordinateSystem('ijk', coord_dtype=dt)
952956
out_cs = CoordinateSystem('xyz', coord_dtype=dt)
953957
cmap = AffineTransform(in_cs, out_cs, arr_p1.astype(dt))
@@ -1031,11 +1035,9 @@ def test_cmap_coord_types():
10311035
# Check that we can use full range of coordinate system types. The inverse
10321036
# of an AffineTransform should generate coordinates in the input coordinate
10331037
# system dtype
1034-
dtypes = (np.sctypes['int'] + np.sctypes['uint'] + np.sctypes['float']
1035-
+ np.sctypes['complex'] + [np.object])
10361038
arr_p1 = np.eye(4)
10371039
arr_p1[:3, 3] = 1
1038-
for dt in dtypes:
1040+
for dt in _SYMPY_SAFE_DTYPES:
10391041
in_cs = CoordinateSystem('ijk', coord_dtype=dt)
10401042
out_cs = CoordinateSystem('xyz', coord_dtype=dt)
10411043
# CoordinateMap

0 commit comments

Comments
 (0)