Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Alternative fix for passing iterator as frames to FuncAnimation #14068

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

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Apr 28, 2019

PR Summary

Fixes #13676. Replaces #13679.

This was proposed in #13679 (comment) it's clearly the better approach as it's simpler and can handle generators. Thanks @anntzer.

I do not really know how to add a test for this. Can't have an infinite loop in a unittest 😄. Works fine as a standalone test with the following code

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.animation import FuncAnimation

fig, ax = plt.subplots()
s = ax.set_title('0')
plt.plot([1,2,3],[2,4,3])
def update(frame):
    print(frame)
    s.set_text(str(frame))
    return []
animation = FuncAnimation(fig, update, frames=(i for i in range(5)), blit=True, interval=100)
plt.show()

@efiring efiring requested a review from dopplershift May 22, 2019 20:08
@efiring
Copy link
Member

efiring commented May 22, 2019

@dopplershift Would you like to have final say on this? It's a small and localized change.

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.

👍

@dopplershift dopplershift merged commit 56581cb into matplotlib:master May 22, 2019
@timhoffm timhoffm deleted the fix-funcantimation-frames-iter-repeat branch May 22, 2019 21:44
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.

FuncAnimation with generator causes crash on StopIteration
4 participants