-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Workaround for islice int error in animation.py #8984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workaround for islice int error in animation.py #8984
Conversation
lib/matplotlib/animation.py
Outdated
# itertools.islice can return an error when passed a numpy int instead | ||
# of a native python int. This is a known issue:http://bugs.python.org/issue30537 | ||
# As a workaround, enforce conversion to native python int | ||
self.save_count = int(self.save_count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would do the conversion in __init__
(after the check for None). Also needs a space after the colon in the comment just above.
The travis test is confused by save_count being None type at the outset, but then changing to some kind of number before the int conversion happens. I'm not sure what's happening with the other ones. |
|
To make @anntzer 's comment a bit clearer 😁, you're missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still have some issues on where the attribute is set on self
. I've suggested a different way that should work.
lib/matplotlib/animation.py
Outdated
# of a native python int. This is a known issue: | ||
# http://bugs.python.org/issue30537 | ||
# As a workaround, enforce conversion to native python int. | ||
self.save_count = int(self.save_count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to do the whole block, like:
if save_count is None:
self.save_count = 100
else:
self.save_count = int(save_count)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are still failing since there are code paths where self.save_count
hasn't been set.
lib/matplotlib/animation.py
Outdated
@@ -1543,7 +1543,6 @@ def __init__(self, fig, func, frames=None, init_func=None, fargs=None, | |||
# Amount of framedata to keep around for saving movies. This is only | |||
# used if we don't know how many frames there will be: in the case | |||
# of no generator or in the case of a callable. | |||
self.save_count = save_count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be easiest just to leave this line, and then do the forced conversion where you do it below.
@braaannigan Thanks and congratulations on your first Matplotilb PR 🎉 Hopefully we will hear from you again! |
Thanks for your patience guys, took me a while to find the errors in the test reports. |
@braaannigan No worries, we have all been there. |
itertools.islice may raise an error when passed a numpy int instead of a native python int.
This is a known issue:http://bugs.python.org/issue30537
As a workaround, enforce conversion of self.save_count to native python int in new_saved_frame_seq():
self.save_count = int(self.save_count)