Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: Convert from str to writer on 3.2.x#17759

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tacaswell merged 2 commits intomatplotlib:v3.2.xfromlarsoner:str
Jun 26, 2020

Conversation

larsoner
Copy link
Contributor

Just taking a simpleanimation example and trying to useanim.save(..., writer='imagemagick') when it's not available on the platform produces on v3.2.x (it's fine onmaster but isbreaking some CIs currently that use 3.2):

Traceback (most recent call last):  File "ani.py", line 45, in <module>    ani.save('temp.gif', writer='imagemagick')  File "/home/larsoner/python/matplotlib/lib/matplotlib/animation.py", line 1109, in save    writer = alt_writer(TypeError: 'str' object is not callable

On this PR:

MovieWriter imagemagick unavailable; trying to use pillow instead.

Code I used to test:

import numpy as npimport matplotlib.pyplot as pltimport matplotlib.animation as animationfrom matplotlib.animation import ImageMagickWriterdef data_gen():    for cnt in range(10):        t = cnt / 10        yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)def init():    ax.set_ylim(-1.1, 1.1)    ax.set_xlim(0, 10)    del xdata[:]    del ydata[:]    line.set_data(xdata, ydata)    return line,fig, ax = plt.subplots()line, = ax.plot([], [], lw=2)ax.grid()xdata, ydata = [], []def run(data):    # update the data    t, y = data    xdata.append(t)    ydata.append(y)    xmin, xmax = ax.get_xlim()    if t >= xmax:        ax.set_xlim(xmin, 2*xmax)        ax.figure.canvas.draw()    line.set_data(xdata, ydata)    return line,ImageMagickWriter.isAvailable = lambda: False  # emulate not available on the platformani = animation.FuncAnimation(fig, run, data_gen, blit=False, interval=10,                              repeat=False, init_func=init)ani.save('temp.gif', writer='imagemagick')

@@ -1106,6 +1106,8 @@ def func(current_frame: int, total_frames: int) -> Any
"save animations.")
_log.warning("MovieWriter %s unavailable; trying to use %s "
"instead.", writer, alt_writer)
if isinstance(alt_writer, str):
alt_writer = writers[alt_writer]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

alt_writer is actually always a key inwriters, so theif check could (should) be dropped.

@anntzeranntzer added topic: animation Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelsJun 25, 2020
@QuLogic
Copy link
Member

I'm not sure this should target v3.2.x; I don't know if we have any plans for another bugfix release.@tacaswell

@larsoner
Copy link
ContributorAuthor

It's not a problem onmaster and the codepathon 3.3 looks very different, so feel free to close if you want

@tacaswelltacaswell merged commit516c810 intomatplotlib:v3.2.xJun 26, 2020
@tacaswell
Copy link
Member

Even if we are not planning to do a 3.2.3, the work is done to fix this so we might as well merge it. If we need to do a 3.2.3 to address a show-stopping issue this fix will also go out.

@QuLogicQuLogic added this to thev3.2.3 milestoneJun 26, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer approved these changes

Assignees
No one assigned
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: animation
Projects
None yet
Milestone
v3.2.3
Development

Successfully merging this pull request may close these issues.

4 participants
@larsoner@QuLogic@tacaswell@anntzer

[8]ページ先頭

©2009-2025 Movatter.jp