Skip to content

Workaround for islice int error in animation.py - #8984

Merged
tacaswell merged 7 commits into
matplotlib:masterfrom
braaannigan:islice_int_bug_workaround
Aug 8, 2017
Merged

tacaswell merged 7 commits into
matplotlib:masterfrom
braaannigan:islice_int_bug_workaround

Conversation

@braaannigan

Copy link
Copy Markdown
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)

Comment thread 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)

Copy link
Copy Markdown
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
Copy Markdown
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

anntzer commented Aug 3, 2017

Copy link
Copy Markdown
Contributor

self.save_count = int(self.save_count)

@dopplershift

Copy link
Copy Markdown
Contributor

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

@dopplershift dopplershift left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread 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)

Copy link
Copy Markdown
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

@dopplershift dopplershift left a comment

Copy link
Copy Markdown
Contributor

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.

# 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
Copy Markdown
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
Copy Markdown
Member

@braaannigan Thanks and congratulations on your first Matplotilb PR 🎉

Hopefully we will hear from you again!

@braaannigan

Copy link
Copy Markdown
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
Copy Markdown
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