@@ -1661,49 +1661,34 @@ def __init__(self, fig, func, frames=None, init_func=None, fargs=None,
1661
1661
1662
1662
self ._init_func = init_func
1663
1663
1664
- # Needs to be initialized so the draw functions work without checking
1665
- self ._save_seq = []
1666
-
1667
1664
TimedAnimation .__init__ (self , fig , ** kwargs )
1668
1665
1669
- # Need to reset the saved seq, since right now it will contain data
1670
- # for a single frame from init, which is not what we want.
1671
- self ._save_seq = []
1672
-
1673
1666
def new_frame_seq (self ):
1674
1667
# Use the generating function to generate a new frame sequence
1675
1668
return self ._iter_gen ()
1676
1669
1677
1670
def new_saved_frame_seq (self ):
1678
- # Generate an iterator for the sequence of saved data. If there are
1679
- # no saved frames, generate a new frame sequence and take the first
1680
- # save_count entries in it.
1681
- if self ._save_seq :
1682
- # While iterating we are going to update _save_seq
1683
- # so make a copy to safely iterate over
1684
- self ._old_saved_seq = list (self ._save_seq )
1685
- return iter (self ._old_saved_seq )
1671
+ # Generate a new frame sequence
1672
+ # and take the first save_count entries in it.
1673
+ if self .save_count is not None :
1674
+ return itertools .islice (self .new_frame_seq (), self .save_count )
1686
1675
else :
1687
- if self .save_count is not None :
1688
- return itertools .islice (self .new_frame_seq (), self .save_count )
1676
+ frame_seq = self .new_frame_seq ()
1689
1677
1690
- else :
1691
- frame_seq = self .new_frame_seq ()
1692
-
1693
- def gen ():
1694
- try :
1695
- for _ in range (100 ):
1696
- yield next (frame_seq )
1697
- except StopIteration :
1698
- pass
1699
- else :
1700
- cbook .warn_deprecated (
1701
- "2.2" , "FuncAnimation.save has truncated your "
1702
- "animation to 100 frames. In the future, no such "
1703
- "truncation will occur; please pass 'save_count' "
1704
- "accordingly." )
1705
-
1706
- return gen ()
1678
+ def gen ():
1679
+ try :
1680
+ for _ in range (100 ):
1681
+ yield next (frame_seq )
1682
+ except StopIteration :
1683
+ pass
1684
+ else :
1685
+ cbook .warn_deprecated (
1686
+ "2.2" , "FuncAnimation.save has truncated your "
1687
+ "animation to 100 frames. In the future, no such "
1688
+ "truncation will occur; please pass 'save_count' "
1689
+ "accordingly." )
1690
+
1691
+ return gen ()
1707
1692
1708
1693
def _init_draw (self ):
1709
1694
# Initialize the drawing either using the given init_func or by
@@ -1721,16 +1706,8 @@ def _init_draw(self):
1721
1706
'sequence of Artist objects.' )
1722
1707
for a in self ._drawn_artists :
1723
1708
a .set_animated (self ._blit )
1724
- self ._save_seq = []
1725
1709
1726
1710
def _draw_frame (self , framedata ):
1727
- # Save the data for potential saving of movies.
1728
- self ._save_seq .append (framedata )
1729
-
1730
- # Make sure to respect save_count (keep only the last save_count
1731
- # around)
1732
- self ._save_seq = self ._save_seq [- self .save_count :]
1733
-
1734
1711
# Call the func with framedata and args. If blitting is desired,
1735
1712
# func needs to return a sequence of any artists that were modified.
1736
1713
self ._drawn_artists = self ._func (framedata , * self ._args )
0 commit comments