8000 MNT: be explicitly strict in FunctionAnimation by tacaswell · Pull Request #6336 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,8 +1113,8 @@ class FuncAnimation(TimedAnimation):
results of drawing from the first item in the frames sequence will be
used. This function will be called once before the first frame.

If blit=True, *func* and *init_func* should return an iterable of
drawables to clear.
If blit=True, *func* and *init_func* must return an iterable of
artists to be re-drawn.

*kwargs* include *repeat*, *repeat_delay*, and *interval*:
*interval* draws a new frame every *interval* milliseconds.
Expand Down Expand Up @@ -1195,6 +1195,9 @@ def _init_draw(self):
else:
self._drawn_artists = self._init_func()
if self._blit:
if self._drawn_artists is None:
raise RuntimeError('The init_func must return a '
'sequence of Artist objects.')
for a in self._drawn_artists:
a.set_animated(self._blit)
self._save_seq = []
Expand All @@ -1211,5 +1214,8 @@ def _draw_frame(self, framedata):
# func needs to return a sequence of any artists that were modified.
self._drawn_artists = self._func(framedata, *self._args)
if self._blit:
if self._drawn_artists is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition will never be True.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, did it one way, and then the other and forgot to remove the old version.

raise RuntimeError('The animation function must return a '
'sequence of Artist objects.')
for a in self._drawn_artists:
a.set_animated(self._blit)
0