Skip to content

Commit 86303e8

Browse files
committed
split 3D plot tests into separate function, kind of slow to run
1 parent a41349e commit 86303e8

File tree

2 files changed

+83
-55
lines changed

2 files changed

+83
-55
lines changed

tests/base/test_transforms3d.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
from spatialmath.base.transforms3d import *
1919
from spatialmath.base.transformsNd import isR, t2r, r2t, rt2tr
20-
21-
import matplotlib.pyplot as plt
22-
23-
2420
class Test3D(unittest.TestCase):
2521
def test_checks(self):
2622
# 2D case, with rotation matrix
@@ -496,57 +492,6 @@ def test_print(self):
496492
self.assertTrue("eul" in s)
497493
self.assertFalse("zyx" in s)
498494

499-
def test_plot(self):
500-
plt.figure()
501-
# test options
502-
trplot(
503-
transl(1, 2, 3),
504-
block=False,
505-
frame="A",
506-
style="line",
507-
width=1,
508-
dims=[0, 10, 0, 10, 0, 10],
509-
)
510-
trplot(
511-
transl(1, 2, 3),
512-
block=False,
513-
frame="A",
514-
style="arrow",
515-
width=1,
516-
dims=[0, 10, 0, 10, 0, 10],
517-
)
518-
trplot(
519-
transl(1, 2, 3),
520-
block=False,
521-
frame="A",
522-
style="rgb",
523-
width=1,
524-
dims=[0, 10, 0, 10, 0, 10],
525-
)
526-
trplot(transl(3, 1, 2), block=False, color="red", width=3, frame="B")
527-
trplot(
528-
transl(4, 3, 1) @ trotx(math.pi / 3),
529-
block=False,
530-
color="green",
531-
frame="c",
532-
dims=[0, 4, 0, 4, 0, 4],
533-
)
534-
535-
# test for iterable
536-
plt.clf()
537-
T = [transl(1, 2, 3), transl(2, 3, 4), transl(3, 4, 5)]
538-
trplot(T)
539-
540-
plt.clf()
541-
tranimate(transl(1, 2, 3), repeat=False, wait=True)
542-
543-
tranimate(transl(1, 2, 3), repeat=False, wait=True)
544-
# run again, with axes already created
545-
tranimate(transl(1, 2, 3), repeat=False, wait=True, dims=[0, 10, 0, 10, 0, 10])
546-
547-
plt.close("all")
548-
# test animate with line not arrow, text, test with SO(3)
549-
550495
def test_trinterp(self):
551496
T0 = trotx(-0.3)
552497
T1 = trotx(0.3)

tests/base/test_transforms3d_plot.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
Created on Fri Apr 10 14:19:04 2020
5+
6+
@author: corkep
7+
8+
"""
9+
10+
11+
import numpy as np
12+
import numpy.testing as nt
13+
import unittest
14+
from math import pi
15+
import math
16+
from scipy.linalg import logm, expm
17+
18+
from spatialmath.base.transforms3d import *
19+
from spatialmath.base.transformsNd import isR, t2r, r2t, rt2tr
20+
21+
import matplotlib.pyplot as plt
22+
23+
24+
class Test3D(unittest.TestCase):
25+
26+
27+
def test_plot(self):
28+
plt.figure()
29+
# test options
30+
trplot(
31+
transl(1, 2, 3),
32+
block=False,
33+
frame="A",
34+
style="line",
35+
width=1,
36+
dims=[0, 10, 0, 10, 0, 10],
37+
)
38+
trplot(
39+
transl(1, 2, 3),
40+
block=False,
41+
frame="A",
42+
style="arrow",
43+
width=1,
44+
dims=[0, 10, 0, 10, 0, 10],
45+
)
46+
trplot(
47+
transl(1, 2, 3),
48+
block=False,
49+
frame="A",
50+
style="rgb",
51+
width=1,
52+
dims=[0, 10, 0, 10, 0, 10],
53+
)
54+
trplot(transl(3, 1, 2), block=False, color="red", width=3, frame="B")
55+
trplot(
56+
transl(4, 3, 1) @ trotx(math.pi / 3),
57+
block=False,
58+
color="green",
59+
frame="c",
60+
dims=[0, 4, 0, 4, 0, 4],
61+
)
62+
63+
# test for iterable
64+
plt.clf()
65+
T = [transl(1, 2, 3), transl(2, 3, 4), transl(3, 4, 5)]
66+
trplot(T)
67+
68+
plt.clf()
69+
tranimate(transl(1, 2, 3), repeat=False, wait=True)
70+
71+
tranimate(transl(1, 2, 3), repeat=False, wait=True)
72+
# run again, with axes already created
73+
tranimate(transl(1, 2, 3), repeat=False, wait=True, dims=[0, 10, 0, 10, 0, 10])
74+
75+
plt.close("all")
76+
# test animate with line not arrow, text, test with SO(3)
77+
78+
79+
80+
# ---------------------------------------------------------------------------------------#
81+
if __name__ == "__main__":
82+
83+
unittest.main()

0 commit comments

Comments
 (0)