1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
Description: fix test failures with sympy 1.13
Since version 1.13, SymPy makes a hard distinction between integers and
floats. This causes a couple of tests to fail, with the most relevant
part of the error showing:
.
self = AffineTransform(
function_domain=CoordinateSystem(coord_names=('x', 'y', 'z'), name='', coord_dtype=object),
fun...ne=array([[3, 0, 0, 0],
[0, 4, 0, 0],
[0, 0, 5, 0],
[0, 0, 0, 1]])
)
function_domain = CoordinateSystem(coord_names=('x', 'y', 'z'), name='', coord_dtype=object)
function_range = CoordinateSystem(coord_names=('i', 'j', 'k'), name='', coord_dtype=object)
affine = array([[1.00000000000000, 0, 0, 0],
[0, 0, 1.00000000000000, 0],
[0, 1.00000000000000, 0, 0],
[0, 0, 0, 1.00000000000000]], dtype=object)
def __init__(self, function_domain, function_range, affine):
""" Initialize AffineTransform
[…]
if not np.all(affine[-1] == bottom_row):
> raise ValueError('the homogeneous transform should have bottom=' + \
f'row {repr(bottom_row)}')
E ValueError: the homogeneous transform should have bottom=row array([0, 0, 0, 1])
.
This change implements a number of adjustments to fix the
AffineTransform constructor, and normalize the expected test output
where needed.
Author: Étienne Mollier <emollier@debian.org>
Forwarded: https://github.com/nipy/nipy/pull/569
Last-Update: 2024-09-04
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- nipy.orig/nipy/core/reference/coordinate_map.py
+++ nipy/nipy/core/reference/coordinate_map.py
@@ -558,10 +558,11 @@
'affine matrix shape')
# Test that it is actually an affine mapping in homogeneous
# form
- bottom_row = np.array([0]*self.ndims[0] + [1])
+ bottom_row = np.array([0]*self.ndims[0] + [1.], dtype=dtype)
if not np.all(affine[-1] == bottom_row):
raise ValueError('the homogeneous transform should have bottom=' + \
- f'row {repr(bottom_row)}')
+ f'row {repr(bottom_row)}' + ' but it has bottom=' \
+ + f'row {repr(affine[-1])}')
self.affine = affine
###################################################################
--- nipy.orig/nipy/core/reference/tests/test_coordinate_map.py
+++ nipy/nipy/core/reference/tests/test_coordinate_map.py
@@ -956,8 +956,8 @@
# Check that we can make functional inverses of AffineTransforms, and
# CoordinateMap versions of AffineTransforms
arr_p1 = np.eye(4)[:, [0, 2, 1, 3]]
- in_list = [0, 1, 2]
- out_list = [0, 2, 1]
+ in_list = [0, 1., 2.]
+ out_list = [0, 2., 1.]
for dt in _SYMPY_SAFE_DTYPES:
in_cs = CoordinateSystem('ijk', coord_dtype=dt)
out_cs = CoordinateSystem('xyz', coord_dtype=dt)
@@ -975,7 +975,7 @@
except:
1/0
res = r_cmap(out_coord)
- assert_array_equal(res, coord)
+ assert_array_equal(res, np.asarray(coord, dtype=exp_i_dt))
assert res.dtype == exp_i_dt
# Default behavior is preserve_type=False
r_cmap = cmap.inverse(preserve_dtype=False)
@@ -991,7 +991,7 @@
cm_cmap = _as_coordinate_map(cmap)
assert_array_equal(cm_cmap(coord), out_list)
rcm_cmap = cm_cmap.inverse()
- assert_array_equal(rcm_cmap(coord), out_list)
+ assert_array_equal(rcm_cmap(coord), np.asarray(out_list, dtype=dt))
res = rcm_cmap(out_coord)
assert_array_equal(res, coord)
assert res.dtype == dt
|