Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33da7a5

Browse files
committed
FIX: not all init/draw function return artists
For blitted animations in is essential to return a list of the animated artists. However, is other cases you can get away with out returning such a list. In the case of blitting it is important to make sure that the animation flags on the animated artist are set correctly, t his commit makes sure that we check that we actually got an iterable before trying to iterate over it.
1 parent f25acff commit 33da7a5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/animation.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,8 +1156,9 @@ def _init_draw(self):
11561156
self._draw_frame(next(self.new_frame_seq()))
11571157
else:
11581158
self._drawn_artists = self._init_func()
1159-
for a in self._drawn_artists:
1160-
a.set_animated(self._blit)
1159+
if iterable(self._drawn_artists):
1160+
for a in self._drawn_artists:
1161+
a.set_animated(self._blit)
11611162

11621163
def _draw_frame(self, framedata):
11631164
# Save the data for potential saving of movies.
@@ -1170,5 +1171,6 @@ def _draw_frame(self, framedata):
11701171
# Call the func with framedata and args. If blitting is desired,
11711172
# func needs to return a sequence of any artists that were modified.
11721173
self._drawn_artists = self._func(framedata, *self._args)
1173-
for a in self._drawn_artists:
1174-
a.set_animated(self._blit)
1174+
if iterable(self._drawn_artists):
1175+
for a in self._drawn_artists:
1176+
a.set_animated(self._blit)

0 commit comments

Comments
 (0)