8000 Workaround for islice int error in animation.py (#8984) · matplotlib/matplotlib@1da7f4b · GitHub
[go: up one dir, main page]

Skip to content

Commit 1da7f4b

Browse files
braaannigantacaswell
authored andcommitted
Workaround for islice int error in animation.py (#8984)
* workaround for islice int error * changed position of int conversion * added self * move into if statement * added save_count assignment back in * remove period * shorten line to < 80
1 parent 2c90227 commit 1da7f4b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/matplotlib/animation.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,6 @@ def __init__(self, fig, func, frames=None, init_func=None, fargs=None,
15441544
# used if we don't know how many frames there will be: in the case
15451545
# of no generator or in the case of a callable.
15461546
self.save_count = save_count
1547-
15481547
# Set up a function that creates a new iterable when needed. If nothing
15491548
# is passed in for frames, just use itertools.count, which will just
15501549
# keep counting from 0. A callable passed in for frames is assumed to
@@ -1562,9 +1561,15 @@ def __init__(self, fig, func, frames=None, init_func=None, fargs=None,
15621561
self._iter_gen = lambda: iter(xrange(frames))
15631562
self.save_count = frames
15641563

1565-
# If we're passed in and using the default, set it to 100.
1564+
# If we're passed in and using the default, set save_count to 100.
1565+
# itertools.islice can return an error when passed a numpy int instead
1566+
# of a native python int. This is a known issue:
1567+
# http://bugs.python.org/issue30537
1568+
# As a workaround, convert save_count to native python int
15661569
if self.save_count is None:
15671570
self.save_count = 100
1571+
else:
1572+
self.save_count = int(self.save_count)
15681573

15691574
self._init_func = init_func
15701575

0 commit comments

Comments
 (0)
0