matplotlib icon indicating copy to clipboard operation
matplotlib copied to clipboard

image compare animations for testing

Open t-makaro opened this issue 7 years ago • 5 comments

I'm currently trying to create pytests for animations over in animatplot. Now, I know that people here have talked about writing image comparison tests for animations, so I thought I would open an issue here to track progress, and to share what I am doing.

Now my needs for animatplot are fairly different, but essentially I'm going to wrap around matplotlib.testing.compare.compare_images, and use a custom file writer (which you can see here) to output a set of images. This file writer was inspired by @tacaswell's stackoverflow answer.

Once I get stuff working over there, I will be willing to help create these types of tests here.

t-makaro avatar Aug 10 '18 03:08 t-makaro

https://github.com/matplotlib/pytest-mpl might also be interested in this feature.

tacaswell avatar Aug 11 '18 20:08 tacaswell

I'm very close to having everything working, but I'm having to remove the text to get things to compare properly on circleci. Which is fine for the most part, but for one of my tests I can't remove the text. I am getting a:

Could not set locale to English/United States. Some date-related tests may fail
    "Could not set locale to English/United States. "

message, but I don't think that is the issue.

I'm not sure what's causing the test to render so differently. image

I am using matplotlib.testing.setup() which should set the font....

t-makaro avatar Aug 11 '18 20:08 t-makaro

Might be a freetype issue, see https://matplotlib.org/devel/contributing.html#building-matplotlib-for-image-comparison-tests

tacaswell avatar Aug 11 '18 23:08 tacaswell

Alright, I have something that works for me over at animatplot. You can see my implementation here. It's as simple as using a decorator on a function that returns an animation. Internally, it will use the BunchOFiles writer to save the animation, and then loop over the images for comparison. Unfortunately, it does require specifying how many frames to expect.

This would require some additional work to suit matplotlib's needs.

t-makaro avatar Aug 23 '18 18:08 t-makaro

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

github-actions[bot] avatar Aug 21 '24 01:08 github-actions[bot]