Skip to content

Commit 118b0b1

Browse files
authored
Merge pull request #171 from AllenInstitute/numpy_fix
test_transform: update to numpy.ptp and numpy.float64 for numpy2
2 parents bcfaed8 + 21276aa commit 118b0b1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test/test_transform.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def test_fail_bad_tform():
6565
def test_similarity_rot_90():
6666
am = renderapi.transform.SimilarityModel()
6767
# setup a 90 degree clockwise rotation
68-
points_in = np.array([[0, 0], [0, 1], [1, 0], [1, 1]], np.float)
69-
points_out = np.array([[0, 0], [1, 0], [0, -1], [1, -1]], np.float)
68+
points_in = np.array([[0, 0], [0, 1], [1, 0], [1, 1]], np.float64)
69+
points_out = np.array([[0, 0], [1, 0], [0, -1], [1, -1]], np.float64)
7070
am.estimate(points_in, points_out)
7171

7272
assert(np.abs(am.scale[0] - 1.0) < .00001)
@@ -98,8 +98,8 @@ def test_similarity_rot_90():
9898
def test_affine_fail():
9999
am = renderapi.transform.AffineModel()
100100
# setup a 90 degree clockwise rotation
101-
points_in = np.array([[0, 0], [0, 1], [1, 0], [1, 1]], np.float)
102-
points_out = np.array([[0, 0], [1, 0], [0, -1], [1, -1]], np.float)
101+
points_in = np.array([[0, 0], [0, 1], [1, 0], [1, 1]], np.float64)
102+
points_out = np.array([[0, 0], [1, 0], [0, -1], [1, -1]], np.float64)
103103
# catch error
104104
with pytest.raises(renderapi.errors.EstimationError):
105105
am.estimate(points_in, points_out[0:-2, :])
@@ -525,7 +525,7 @@ def test_non_linear_transform():
525525
"9.885988268659214E18 1.1051253229808925E19 1.6002173610912907E19 "
526526
"0.0 2048 2048 "), transformId="testing")
527527

528-
ticks = np.arange(0, 2048, 64, np.float)
528+
ticks = np.arange(0, 2048, 64, np.float64)
529529
xx, yy = np.meshgrid(ticks, ticks)
530530
x = np.ravel(xx).T
531531
y = np.ravel(yy).T
@@ -626,7 +626,7 @@ def referenced_tilespecs_and_transforms():
626626
def test_estimate_dstpoints_reference(referenced_tilespecs_and_transforms):
627627
tilespecs, transforms = referenced_tilespecs_and_transforms
628628

629-
ticks = np.arange(0, 2048, 64, np.float)
629+
ticks = np.arange(0, 2048, 64, np.float64)
630630
xx, yy = np.meshgrid(ticks, ticks)
631631
x = np.ravel(xx).T
632632
y = np.ravel(yy).T
@@ -643,7 +643,7 @@ def test_estimate_dstpoints_reference(referenced_tilespecs_and_transforms):
643643

644644

645645
def test_fail_convert_points():
646-
points_in = np.array([[0, 0], [0, 1], [1, 0], [1, 1]], np.float)
646+
points_in = np.array([[0, 0], [0, 1], [1, 0], [1, 1]], np.float64)
647647
with pytest.raises(renderapi.errors.ConversionError):
648648
renderapi.transform.AffineModel.convert_to_point_vector(points_in.T)
649649

@@ -928,8 +928,8 @@ def thinplate_estimate_nojson(computeAffine=True):
928928

929929
def poly2d(src):
930930
dst = np.zeros_like(src)
931-
dx = (src[:, 0] - src[:, 0].mean()) / (src[:, 0].ptp())
932-
dy = (src[:, 1] - src[:, 1].mean()) / (src[:, 1].ptp())
931+
dx = (src[:, 0] - src[:, 0].mean()) / (np.ptp(src[:, 0]))
932+
dy = (src[:, 1] - src[:, 1].mean()) / (np.ptp(src[:, 1]))
933933
dst[:, 0] = src[:, 0] + 0.5 * dx * dy + 7.0 * dx * dy * dy
934934
dst[:, 1] = src[:, 1] + 0.7 * dy * dy - 4.0 * dx * dx * dy
935935
a = np.array([[1.1, -0.04], [-0.02, 0.95]])
@@ -1069,7 +1069,7 @@ def test_scale_thinplate(factor, computeAffine, preserve_srcPts, ngrid):
10691069
dst_scaled = scaled_tform.tform(src * factor)
10701070

10711071
delta = np.linalg.norm(dst_scaled - dst * factor, axis=1)
1072-
scale = dst_scaled.ptp(axis=0).mean()
1072+
scale = np.ptp(dst_scaled, axis=0).mean()
10731073
tol = 1e-4
10741074
if ngrid == 5:
10751075
tol = 1e-3

0 commit comments

Comments
 (0)