10000 TST: Remove unnecessary test images by QuLogic · Pull Request #29827 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

TST: Remove unnecessary test images #29827

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
Apr 4, 2025
Merged

Conversation

QuLogic
Copy link
Member
@QuLogic QuLogic commented Mar 29, 2025

PR summary

There's no need to test multiple file formats for tests that:

  • are for wrappers that simplify or combine other primitives, such as boxplot, eventplot, axhspan, or fill_between.
  • are for spine or tick settings, such as the autoscale_tiny_range, formatter_ticker_*.
  • are for alternate Axes projections, such as polar, Mollweide, or skewed Axes.

This is certainly not exhaustive; I did not remove any of the mathtext formats (seemed like a good glyph test), anything with hatching/clipping/alpha (probably could be pared down to just a few), markevery tests (don't recall if that required anything in the backend), or tight layout tests.

PR checklist

@QuLogic QuLogic mentioned this pull request Mar 29, 2025
5 tasks
@QuLogic
Copy link
Member Author
QuLogic commented Mar 29, 2025

If code coverage passes, that should be at least some indicator that we didn't drop anything relevant.

@QuLogic
Copy link
Member Author
QuLogic commented Mar 31, 2025

OK, I've also removed hist2d (because it is just a pcolormesh), and markevery (because it's just a line + scatter).

@tacaswell
Copy link
Member

Why prefer png over svg/pdf?

A spot check of sizes looks like the pdf's are the smallest (presumably because they are compressed by default) and svgs are the most "text like" so should play the best with git. I was going to assert that the vector layouts would be insensative to freetype but began to doubt that as I was typing (I am not sure if we rely on freetype to do any placement even in those cases).

The biggest upside I see of png is that it is no optional test-deps to run.

@tacaswell tacaswell added this to the v3.11.0 milestone Apr 1, 2025
@QuLogic
Copy link
Member Author
QuLogic commented Apr 1, 2025

A spot check of sizes looks like the pdf's are the smallest (presumably because they are compressed by default) and svgs are the most "text like" so should play the best with git. I was going to assert that the vector layouts would be insensative to freetype but began to doubt that as I was typing (I am not sure if we rely on freetype to do any placement even in those cases).

Unfortunately not, or this wouldn't have come up in #29816. Admittedly, I don't think it's all of them, though.

The biggest upside I see of png is that it is no optional test-deps to run.

This is definitely the main reason, but I have no issues with changing to SVG/PDF if we think that's okay.

@tacaswell
Copy link
Member

I also suspect (but have not measured) that the png tests are faster as we don't effectively render 2x and require a sub-process to be running.

Despite asking the question, I'm coming around to png being the right choice.

@timhoffm
Copy link
Member
timhoffm commented Apr 2, 2025

Should we change the default extensions of check_figures_equal to only png? Figure comparisons often create the same artists but with different code paths. Therefore rendering to any output should be sufficient. I believe it's quite the exception that we need more than one output.

@QuLogic
Copy link
Member Author
QuLogic commented Apr 2, 2025

Good idea, but it is in the public API right now. I seem to recall us saying that matplotlib.testing may not have the same API guarantees, but I can't find where that is.

@timhoffm
Copy link
Member
timhoffm commented Apr 3, 2025

I'd be so bold and just change it, documenting it in an API change note.

It should be "what users want" 99% of the time, and there's no simple deprecation/migration route.

@QuLogic
Copy link
Member Author
QuLogic commented Apr 3, 2025

OK, I've changed the default and removed the extraneous extensions arguments.

@@ -677,8 +677,7 @@ def test_contains_points():
assert np.all(result == expected)


# Currently fails with pdf/svg, probably because some parts assume a dpi of 72.
Copy link
Member

Choose a reason for hiding this comment

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

Should we leave this comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like it does still fail on PDF/SVG, so we can leave it in.

@timhoffm
Copy link
Member
timhoffm commented Apr 3, 2025

Not a 100% exact comparison but this test run is 9630 tests in 12:37min, where a test run on another recent PR is 9845 tests in 13:54min. So a rough estimate is that we have shaved off 200 tests and 1:20min test runtime. That's a significant improvement 🎉.

@tacaswell tacaswell modified the milestones: v3.11.0, v3.10.2 Apr 3, 2025
@tacaswell
Copy link
Member

This and #29816 will need to be backported to 3.10.x.

@@ -25,7 +25,7 @@
import matplotlib.dates as mdates


@image_comparison(['figure_align_labels'], extensions=['png', 'svg'],
@image_comparison(['figure_align_labels.png'],
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this one should stay. @anntzer 's comments in 19359c1 when the pdf version was removed suggest that this was testing some of the fixed-dpi issues we have with vector formats.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, can revert. That commit also has some backcompat stuff that maybe could be removed in #29816, looks like...

QuLogic and others added 3 commits April 4, 2025 02:34
There's no need to test multiple file formats for tests that:

- are for wrappers that simplify or combine other primitives, such as
  `boxplot`, `eventplot`, `axhspan`, or `fill_between`.
- are for spine or tick settings, such as the `autoscale_tiny_range`,
  `formatter_ticker_*`.
- are for alternate Axes projections, such as polar, Mollweide, or
  skewed Axes.
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
@timhoffm timhoffm merged commit 662239c into matplotlib:main Apr 4, 2025
39 of 41 checks passed
Copy link
lumberbot-app bot commented Apr 4, 2025

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v3.10.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 662239c31e3a080e9bcbe69cd51452a9c0506d97
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #29827: TST: Remove unnecessary test images'
  1. Push to a named branch:
git push YOURFORK v3.10.x:auto-backport-of-pr-29827-on-v3.10.x
  1. Create a PR against branch v3.10.x, I would have named this PR:

"Backport PR #29827 on branch v3.10.x (TST: Remove unnecessary test images)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@QuLogic QuLogic deleted the test-reduction branch April 4, 2025 22:15
QuLogic added a commit to QuLogic/matplotlib that referenced this pull request Apr 5, 2025
dstansby pushed a commit to QuLogic/matplotlib that referenced this pull request Apr 24, 2025
ksunden added a commit that referenced this pull request May 2, 2025
…3.10.x

Backport PR #29827 on branch v3.10.x (TST: Remove unnecessary test images)
@ksunden ksunden mentioned this pull request May 9, 2025
5 tasks
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.

3 participants
0