8000 Workaround for islice int error in animation.py by braaannigan · Pull Request #8984 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 7 commits into from
Aug 8, 2017
Merged

Workaround for islice int error in animation.py #8984

merged 7 commits into from
Aug 8, 2017

Conversation

braaannigan
Copy link
Contributor

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)

# 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)
Copy link
Contributor

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.

@braaannigan
Copy link
Contributor Author

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.

@anntzer
Copy link
Contributor
anntzer commented Aug 3, 2017

self.save_count = int(self.save_count)

@dopplershift
Copy link
Contributor

To make @anntzer 's comment a bit clearer 😁, you're missing self on line 1571.

Copy link
Contributor
@dopplershift dopplershift left a 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.

# 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)
Copy link
Contributor

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)

@dstansby dstansby added this to the 2.1.1 (next bug fix release) milestone Aug 4, 2017
Copy link
Contributor
@dopplershift dopplershift left a 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.

@@ -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
Copy link
Contributor

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.

@tacaswell tacaswell merged commit 1da7f4b into matplotlib:master Aug 8, 2017
@tacaswell
Copy link
Member

@braaannigan Thanks and congratulations on your first Matplotilb PR 🎉

Hopefully we will hear from you again!

@braaannigan
Copy link
Contributor Author

Thanks for your patience guys, took me a while to find the errors in the test reports.

@braaannigan braaannigan deleted the islice_int_bug_workaround branch August 8, 2017 17:25
@tacaswell
Copy link
Member

@braaannigan No worries, we have all been there.

@QuLogic QuLogic modified the milestones: 2.1 (next point release), 2.1.1 (next bug fix release) Aug 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0