8000 MNT: be explicitly strict in FunctionAnimation · matplotlib/matplotlib@65507a0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 65507a0

Browse files
committed
MNT: be explicitly strict in FunctionAnimation
If the user functions return None, raise RuntimeError. Suggested in #6332
1 parent 38d9638 commit 65507a0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/animation.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,8 +1113,8 @@ class FuncAnimation(TimedAnimation):
11131113
results of drawing from the first item in the frames sequence will be
11141114
used. This function will be called once before the first frame.
11151115
1116-
If blit=True, *func* and *init_func* should return an iterable of
1117-
drawables to clear.
1116+
If blit=True, *func* and *init_func* must return an iterable of
1117+
artists to be re-drawn.
11181118
11191119
*kwargs* include *repeat*, *repeat_delay*, and *interval*:
11201120
*interval* draws a new frame every *interval* milliseconds.
@@ -1195,6 +1195,9 @@ def _init_draw(self):
11951195
else:
11961196
self._drawn_artists = self._init_func()
11971197
if self._blit:
1198+
if self._drawn_artists is None:
1199+
raise RuntimeError('The init_func must return a '
1200+
'sequence of Artist objects.')
11981201
for a in self._drawn_artists:
11991202
a.set_animated(self._blit)
12001203
self._save_seq = []
@@ -1211,5 +1214,8 @@ def _draw_frame(self, framedata):
12111214
# func needs to return a sequence of any artists that were modified.
12121215
self._drawn_artists = self._func(framedata, *self._args)
12131216
if self._blit:
1217+
if self._drawn_artists is None:
1218+
raise RuntimeError('The animation function must return a '
1219+
'sequence of Artist objects.')
12141220
for a in self._drawn_artists:
12151221
a.set_animated(self._blit)

0 commit comments

Comments
 (0)
0