@@ -1069,7 +1069,7 @@ def func(current_frame: int, total_frames: int) -> Any
1069
1069
frame_number = 0
1070
1070
# TODO: Currently only FuncAnimation has a save_count
1071
1071
# attribute. Can we generalize this to all Animations?
1072
- save_count_list = [getattr (a , 'save_count ' , None )
1072
+ save_count_list = [getattr (a , '_save_count ' , None )
1073
1073
for a in all_anim ]
1074
1074
if None in save_count_list :
1075
1075
total_frames = None
@@ -1222,7 +1222,7 @@ def to_html5_video(self, embed_limit=None):
1222
1222
This saves the animation as an h264 video, encoded in base64
1223
1223
directly into the HTML5 video tag. This respects :rc:`animation.writer`
1224
1224
and :rc:`animation.bitrate`. This also makes use of the
1225
- `` interval`` to control the speed, and uses the `` repeat``
1225
+ * interval* to control the speed, and uses the * repeat*
1226
1226
parameter to decide whether to loop.
1227
1227
1228
1228
Parameters
@@ -1285,7 +1285,7 @@ def to_html5_video(self, embed_limit=None):
1285
1285
options = ['controls' , 'autoplay' ]
1286
1286
1287
1287
# If we're set to repeat, make it loop
1288
- if hasattr (self , 'repeat' ) and self . repeat :
1288
+ if getattr (self , '_repeat' , False ) :
1289
1289
options .append ('loop' )
1290
1290
1291
1291
return VIDEO_TAG .format (video = self ._base64_video ,
@@ -1306,8 +1306,8 @@ def to_jshtml(self, fps=None, embed_frames=True, default_mode=None):
1306
1306
embed_frames : bool, optional
1307
1307
default_mode : str, optional
1308
1308
What to do when the animation ends. Must be one of ``{'loop',
1309
- 'once', 'reflect'}``. Defaults to ``'loop'`` if ``self. repeat``
1310
- is True, otherwise ``'once'``.
1309
+ 'once', 'reflect'}``. Defaults to ``'loop'`` if the * repeat*
1310
+ parameter is True, otherwise ``'once'``.
1311
1311
"""
1312
1312
if fps is None and hasattr (self , '_interval' ):
1313
1313
# Convert interval in ms to frames per second
@@ -1316,7 +1316,8 @@ def to_jshtml(self, fps=None, embed_frames=True, default_mode=None):
1316
1316
# If we're not given a default mode, choose one base on the value of
1317
1317
# the repeat attribute
1318
1318
if default_mode is None :
1319
- default_mode = 'loop' if self .repeat else 'once'
1319
+ default_mode = 'loop' if getattr (self , '_repeat' ,
1320
+ False ) else 'once'
1320
1321
1321
1322
if not hasattr (self , "_html_representation" ):
1322
1323
# Can't open a NamedTemporaryFile twice on Windows, so use a
@@ -1381,12 +1382,14 @@ class TimedAnimation(Animation):
1381
1382
Whether blitting is used to optimize drawing.
1382
1383
"""
1383
1384
1385
+ repeat = _api .deprecate_privatize_attribute ("3.7" )
1386
+
1384
1387
def __init__ (self , fig , interval = 200 , repeat_delay = 0 , repeat = True ,
1385
1388
event_source = None , * args , ** kwargs ):
1386
1389
self ._interval = interval
1387
1390
# Undocumented support for repeat_delay = None as backcompat.
1388
1391
self ._repeat_delay = repeat_delay if repeat_delay is not None else 0
1389
- self .repeat = repeat
1392
+ self ._repeat = repeat
1390
1393
# If we're not given an event source, create a new timer. This permits
1391
1394
# sharing timers between animation objects for syncing animations.
1392
1395
if event_source is None :
@@ -1403,7 +1406,7 @@ def _step(self, *args):
1403
1406
# back.
1404
1407
still_going = super ()._step (* args )
1405
1408
if not still_going :
1406
- if self .repeat :
1409
+ if self ._repeat :
1407
1410
# Restart the draw loop
1408
1411
self ._init_draw ()
1409
1412
self .frame_seq = self .new_frame_seq ()
@@ -1589,9 +1592,10 @@ def init_func() -> iterable_of_artists
1589
1592
Whether frame data is cached. Disabling cache might be helpful when
1590
1593
frames contain large objects.
1591
1594
"""
1595
+ save_count = _api .deprecate_privatize_attribute ("3.7" )
1592
1596
1593
1597
def __init__ (self , fig , func , frames = None , init_func = None , fargs = None ,
1594
- save_count = None , * , cache_frame_data = True , ** kwargs ):
1598
+ save_count = 100 , * , cache_frame_data = True , ** kwargs ):
1595
1599
if fargs :
1596
1600
self ._args = fargs
1597
1601
else :
@@ -1602,7 +1606,7 @@ def __init__(self, fig, func, frames=None, init_func=None, fargs=None,
1602
1606
# Amount of framedata to keep around for saving movies. This is only
1603
1607
# used if we don't know how many frames there will be: in the case
1604
1608
# of no generator or in the case of a callable.
1605
- self .save_count = save_count
1609
+ self ._save_count = save_count
1606
1610
# Set up a function that creates a new iterable when needed. If nothing
1607
1611
# is passed in for frames, just use itertools.count, which will just
1608
1612
# keep counting from 0. A callable passed in for frames is assumed to
@@ -1622,19 +1626,10 @@ def iter_frames(frames=frames):
1622
1626
else :
1623
1627
self ._iter_gen = lambda : iter (frames )
1624
1628
if hasattr (frames , '__len__' ):
1625
- self .save_count = len (frames )
1629
+ self ._save_count = len (frames )
1626
1630
else :
1627
1631
self ._iter_gen = lambda : iter (range (frames ))
1628
- self .save_count = frames
1629
-
1630
- if self .save_count is None :
1631
- # If we're passed in and using the default, set save_count to 100.
1632
- self .save_count = 100
1633
- else :
1634
- # itertools.islice returns an error when passed a numpy int instead
1635
- # of a native python int (https://bugs.python.org/issue30537).
1636
- # As a workaround, convert save_count to a native python int.
1637
- self .save_count = int (self .save_count )
1632
+ self ._save_count = frames
1638
1633
1639
1634
self ._cache_frame_data = cache_frame_data
1640
1635
@@ -1661,26 +1656,7 @@ def new_saved_frame_seq(self):
1661
1656
self ._old_saved_seq = list (self ._save_seq )
1662
1657
return iter (self ._old_saved_seq )
1663
1658
else :
1664
- if self .save_count is not None :
1665
- return itertools .islice (self .new_frame_seq (), self .save_count )
1666
-
1667
- else :
1668
- frame_seq = self .new_frame_seq ()
1669
-
1670
- def gen ():
1671
- try :
1672
- for _ in range (100 ):
1673
- yield next (frame_seq )
1674
- except StopIteration :
1675
- pass
1676
- else :
1677
- _api .warn_deprecated (
1678
- "2.2" , message = "FuncAnimation.save has truncated "
1679
- "your animation to 100 frames. In the future, no "
1680
- "such truncation will occur; please pass "
1681
- "'save_count' accordingly." )
1682
-
1683
- return gen ()
1659
+ return itertools .islice (self .new_frame_seq (), self ._save_count )
1684
1660
1685
1661
def _init_draw (self ):
1686
1662
super ()._init_draw ()
@@ -1721,7 +1697,7 @@ def _draw_frame(self, framedata):
1721
1697
1722
1698
# Make sure to respect save_count (keep only the last save_count
1723
1699
# around)
1724
- self ._save_seq = self ._save_seq [- self .save_count :]
1700
+ self ._save_seq = self ._save_seq [- self ._save_count :]
1725
1701
1726
1702
# Call the func with framedata and args. If blitting is desired,
1727
1703
# func needs to return a sequence of any artists that were modified.
0 commit comments