|
38 | 38 |
|
39 | 39 | from matplotlib._animation_data import (DISPLAY_TEMPLATE, INCLUDED_FRAMES,
|
40 | 40 | JS_INCLUDE)
|
41 |
| -from matplotlib.cbook import iterable, deprecated |
42 | 41 | from matplotlib.compat import subprocess
|
43 |
| -from matplotlib import rcParams, rcParamsDefault, rc_context |
| 42 | +from matplotlib import cbook, rcParams, rcParamsDefault, rc_context |
44 | 43 |
|
45 | 44 | if six.PY2:
|
46 | 45 | from base64 import encodestring as encodebytes
|
@@ -1679,7 +1678,7 @@ def __init__(self, fig, func, frames=None, init_func=None, fargs=None,
|
1679 | 1678 | self._iter_gen = itertools.count
|
1680 | 1679 | elif callable(frames):
|
1681 | 1680 | self._iter_gen = frames
|
1682 |
| - elif iterable(frames): |
| 1681 | + elif cbook.iterable(frames): |
1683 | 1682 | self._iter_gen = lambda: iter(frames)
|
1684 | 1683 | if hasattr(frames, '__len__'):
|
1685 | 1684 | self.save_count = len(frames)
|
@@ -1721,7 +1720,26 @@ def new_saved_frame_seq(self):
|
1721 | 1720 | self._old_saved_seq = list(self._save_seq)
|
1722 | 1721 | return iter(self._old_saved_seq)
|
1723 | 1722 | else:
|
1724 |
| - return itertools.islice(self.new_frame_seq(), self.save_count) |
| 1723 | + if self.save_count is not None: |
| 1724 | + return itertools.islice(self.new_frame_seq(), self.save_count) |
| 1725 | + |
| 1726 | + else: |
| 1727 | + frame_seq = self.new_frame_seq() |
| 1728 | + |
| 1729 | + def gen(): |
| 1730 | + try: |
| 1731 | + for _ in range(100): |
| 1732 | + yield next(frame_seq) |
| 1733 | + except StopIteration: |
| 1734 | + pass |
| 1735 | + else: |
| 1736 | + cbook.warn_deprecated( |
| 1737 | + "2.2", "FuncAnimation.save has truncated your " |
| 1738 | + "animation to 100 frames. In the future, no such " |
| 1739 | + "truncation will occur; please pass 'save_count' " |
| 1740 | + "accordingly.") |
| 1741 | + |
| 1742 | + return gen() |
1725 | 1743 |
|
1726 | 1744 | def _init_draw(self):
|
1727 | 1745 | # Initialize the drawing either using the given init_func or by
|
|
0 commit comments