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

Skip to content

ENH: Add support for FuncAnimation #687

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 3 commits into from
May 14, 2020
Merged

Conversation

larsoner
Copy link
Contributor

Closes #150.

@choldgraf @lucyleeow do you want to take a first look at these? Once you're happy I'll ping the folks from #150 to take a look. (Anyone else can feel free to comment as well, just don't want to spam everyone if this is still half-baked/experimental!) But at least it seems to work for MNE-Python:

They both show animations when built with this branch.

@larsoner
Copy link
Contributor Author

And here are our built docs:

@larsoner
Copy link
Contributor Author

Bumping AppVeyor to 3.6 from 3.5. The matplotlib for 3.5 appears to be too old to support animations without bugs. 3.5 is already tested on Travis anyway, and we'll probably kill support soon anyway (EOL in August) so this seems like the easiest solution.

Copy link
Contributor

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

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

You're a wizard Eric! 🧙

It looks quite nice to me - a few comments in there. The GIF even works in the thumbnail! So cool! https://1535-25860190-gh.circle-artifacts.com/0/rtd_html/auto_examples/index.html

# if it's the file thumbnail
fig = ani._fig
image_path_iterator = block_vars['image_path_iterator']
img_fname = next(image_path_iterator).replace('.png', '.gif')
Copy link
Contributor

Choose a reason for hiding this comment

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

We should really relax the assumptions about .png extensions in the codebase :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Someday probably :) But in the meantime, knowing it ends with png and .replaceing works okay

if ImageMagickWriter.isAvailable():
writer = 'imagemagick'
else:
writer = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we assume this will default to FFmpeg then? And if we know it's buggy, maybe we raise a warning here about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know enough about matplotlib to know what all the options are, or if FFmpeg can be fixed to work better than it did in my original testing. So I'd rather not emit a warning unless someone with expertise can comment.

@lucyleeow
Copy link
Contributor

LGTM but it's unfamiliar territory for me.

@codecov-io
Copy link

codecov-io commented May 14, 2020

Codecov Report

Merging #687 into master will increase coverage by 0.01%.
The diff coverage is 97.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #687      +/-   ##
==========================================
+ Coverage   97.77%   97.79%   +0.01%     
==========================================
  Files          31       32       +1     
  Lines        3288     3405     +117     
==========================================
+ Hits         3215     3330     +115     
- Misses         73       75       +2     
Impacted Files Coverage Δ
sphinx_gallery/gen_gallery.py 96.94% <ø> (+0.01%) ⬆️
sphinx_gallery/utils.py 100.00% <ø> (ø)
sphinx_gallery/scrapers.py 97.72% <96.87%> (-0.21%) ⬇️
sphinx_gallery/gen_rst.py 97.46% <100.00%> (ø)
sphinx_gallery/tests/test_full.py 100.00% <100.00%> (ø)
sphinx_gallery/backreferences.py 96.29% <0.00%> (ø)
sphinx_gallery/directives.py 96.87% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc3b32c...b762a43. Read the comment docs.

@larsoner
Copy link
Contributor Author

@choldgraf feel free to merge if you're happy

@choldgraf choldgraf merged commit b6ea512 into sphinx-gallery:master May 14, 2020
@choldgraf
Copy link
Contributor

I'm happy!

@larsoner larsoner deleted the anim branch May 14, 2020 15:20
thumb_size = gallery_conf['thumbnail_size']
use_dpi = round(
min(t_s / f_s for t_s, f_s in zip(thumb_size, fig_size)))
# FFmpeg is buggy for GIFs
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to see matplotlib/matplotlib#18093

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dopplershift would you be up for making a quick PR to triage based on the LooseVersion of matplotlib which backend to use?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. #733

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.

matplotlib animations support
5 participants