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

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/behavior/29827-ES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
``matplotlib.testing.check_figures_equal`` defaults to PNG only
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In most cases, checking that figures are equal with `.check_figures_equal` does not
depend on the file format. Consequently, the *extensions* parameter now defaults to
``['png']`` instead of ``['png', 'pdf', 'svg']``, reducing default test requirements.
4 changes: 2 additions & 2 deletions doc/devel/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ vs plotting the circle using the parametric equation of a circle ::
@check_figures_equal()
def test_parametric_circle_plot(fig_test, fig_ref):

xo, yo= (.5, .5)
xo = yo = 0.5
radius = 0.4

ax_test = fig_test.subplots()
Expand All @@ -205,7 +205,7 @@ vs plotting the circle using the parametric equation of a circle ::
ax_ref.add_artist(red_circle_ref)

for ax in [ax_ref, ax_test]:
ax.set(xlim=(0,1), ylim=(0,1), aspect='equal')
ax.set(xlim=(0, 1), ylim=(0, 1), aspect='equal')

Both comparison decorators have a tolerance argument ``tol`` that is used to specify the
tolerance for difference in color value between the two images, where 255 is the maximal
Expand Down
11 changes: 8 additions & 3 deletions lib/matplotlib/testing/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def image_comparison(baseline_images, extensions=None, tol=0,
savefig_kwargs=savefig_kwarg, style=style)


def check_figures_equal(*, extensions=("png", "pdf", "svg"), tol=0):
def check_figures_equal(*, extensions=("png", ), tol=0):
"""
Decorator for test cases that generate and compare two figures.

Expand All @@ -360,8 +360,13 @@ def check_figures_equal(*, extensions=("png", "pdf", "svg"), tol=0):

Parameters
----------
extensions : list, default: ["png", "pdf", "svg"]
The extensions to test.
extensions : list, default: ["png"]
The extensions to test. Supported extensions are "png", "pdf", "svg".

Testing with the one default extension is sufficient if the output is not
format dependent, e.g. if you test that a ``bar()`` plot yields the same
result as some manually placed Rectangles. You should use all extensions
if a renderer property is involved, e.g. correct alpha blending.
tol : float
The RMS threshold above which the test is considered failed.

Expand Down
Binary file not shown.
Loading
Loading