8000 added tranimate to unit tests · suddrey-qut/spatialmath-python@28513e1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 28513e1

Browse files
committed
added tranimate to unit tests
1 parent 49b0330 commit 28513e1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

spatialmath/base/animate.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def trplot(self, T, **kwargs):
111111
# draw axes at the origin
112112
tr.trplot(np.eye(4), axes=self, **kwargs)
113113

114-
def run(self, movie=None, axes=None, repeat=True, interval=50, nframes=100, **kwargs):
114+
def run(self, movie=None, axes=None, repeat=True, interval=50, nframes=100, pause=None, **kwargs):
115115
"""
116116
Run the animation
117117
@@ -145,7 +145,12 @@ def update(frame, a):
145145
ani = animation.FuncAnimation(fig=plt.gcf(), func=update, frames=range(0, nframes), fargs=(self,), blit=False, interval=interval, repeat=repeat)
146146

147147
if movie is None:
148-
plt.show()
148+
149+
if pause is None:
150+
plt.show()
151+
else:
152+
plt.pause(pause)
153+
149154
else:
150155
# Set up formatting for the movie files
151156
print('creating movie', movie)

spatialmath/base/test_transforms.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,10 @@ def test_plot(self):
780780
trplot(transl(3, 1, 2), color='red', width=3, frame='B')
781781
trplot(transl(4, 3, 1)@trotx(math.pi / 3), color='green', frame='c', dims=[0, 4, 0, 4, 0, 4])
782782

783+
plt.clf()
784+
tranimate(transl(1, 2, 3), repeat=False, pause=2)
785+
# run again, with axes already created
786+
tranimate(transl(1, 2, 3), repeat=False, pause=2, dims=[0, 10, 0, 10, 0, 10])
783787

784788
class TestLie(unittest.TestCase):
785789

0 commit comments

Comments
 (0)
0