Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 57a9d52

Browse filesBrowse files
committed
Rotate around test wip [skip ci]
1 parent a8726b2 commit 57a9d52
Copy full SHA for 57a9d52

File tree

Expand file treeCollapse file tree

1 file changed

+48
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+48
-4
lines changed

‎lib/matplotlib/tests/test_transforms.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_transforms.py
+48-4Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,54 @@ def test_rotate(self):
426426
[0, -2, 0], [3, 0, 0], [0, 0, 4], [5, -5, 0], [6, -6, 6]])
427427

428428
for dim in range(3):
429-
assert_array_equal((r90[dim] + r90[dim]).get_matrix(),
430-
r180[dim].get_matrix())
431-
assert_array_equal((r90[dim] + r180[dim]).get_matrix(),
432-
r270[dim].get_matrix())
429+
assert_array_almost_equal(
430+
(r90[dim] + r90[dim]).get_matrix(), r180[dim].get_matrix())
431+
assert_array_almost_equal(
432+
(r90[dim] + r180[dim]).get_matrix(), r270[dim].get_matrix())
433+
434+
def test_rotate_around(self):
435+
r_pi_2 = [Affine3D().rotate_around(*self.pivot, np.pi / 2, dim)
436+
for dim in range(3)]
437+
r90 = [Affine3D().rotate_deg_around(*self.pivot, 90, dim) for dim in range(3)]
438+
439+
for dim in range(3):
440+
assert_array_equal(r_pi_2[dim].get_matrix(), r90[dim].get_matrix())
441+
442+
# assert_array_almost_equal(r90.transform(self.single_point), [1, 1])
443+
# assert_array_almost_equal(r90.transform(self.multiple_points),
444+
# [[0, 0], [-1, 3], [2, 4]])
445+
446+
r_pi = [Affine3D().rotate_around(*self.pivot, np.pi, dim) for dim in range(3)]
447+
r180 = [Affine3D().rotate_deg_around(*self.pivot, 180, dim) for dim in range(3)]
448+
449+
for dim in range(3):
450+
assert_array_equal(r_pi[dim].get_matrix(), r180[dim].get_matrix())
451+
452+
# assert_array_almost_equal(r180.transform(self.single_point), [1, 1])
453+
# assert_array_almost_equal(r180.transform(self.multiple_points),
454+
# [[2, 0], [-1, -1], [-2, 2]])
455+
456+
r_pi_3_2 = [Affine3D().rotate_around(*self.pivot, 3 * np.pi / 2, dim)
457+
for dim in range(3)]
458+
r270 = [Affine3D().rotate_deg_around(*self.pivot, 270, dim) for dim in range(3)]
459+
460+
for dim in range(3):
461+
assert_array_equal(r_pi_3_2[dim].get_matrix(), r270[dim].get_matrix())
462+
463+
# assert_array_almost_equal(r270.transform(self.single_point), [1, 1])
464+
# assert_array_almost_equal(r270.transform(self.multiple_points),
465+
# [[2, 2], [3, -1], [0, -2]])
466+
467+
# raise TypeError(np.array_str((r90[2]+r90[2]).get_matrix(),
468+
# precision=2, suppress_small=True))
469+
# raise TypeError(np.array_str(r180[2].get_matrix(),
470+
# precision=2, suppress_small=True))
471+
472+
for dim in range(3):
473+
assert_array_almost_equal(
474+
(r90[dim] + r90[dim]).get_matrix(), r180[dim].get_matrix())
475+
assert_array_almost_equal(
476+
(r90[dim] + r180[dim]).get_matrix(), r270[dim].get_matrix())
433477

434478

435479
def test_non_affine_caching():

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.