From d1902a52db017dca5fe9c9eb68ff7457e559e6fd Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Fri, 26 Jun 2026 18:29:43 +0200 Subject: [PATCH] Backport PR #31946: TST: Increase some tolerances for non-x86_64 architectures --- lib/matplotlib/tests/test_axes.py | 10 +++++----- lib/matplotlib/tests/test_figure.py | 2 +- lib/matplotlib/tests/test_legend.py | 5 ++--- lib/matplotlib/tests/test_patheffects.py | 6 +++--- lib/matplotlib/tests/test_polar.py | 6 +++--- lib/mpl_toolkits/mplot3d/tests/test_axes3d.py | 2 +- lib/mpl_toolkits/mplot3d/tests/test_legend3d.py | 4 ++-- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 911d2a63f4ed..a1dce857b4ef 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -240,7 +240,7 @@ def test_matshow(fig_test, fig_ref): @image_comparison([f'formatter_ticker_{i:03d}.png' for i in range(1, 6)], style='mpl20', - tol=0.03 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.03) def test_formatter_ticker(): import matplotlib.testing.jpl_units as units units.register() @@ -5611,7 +5611,7 @@ def test_marker_styles(): @image_comparison(['rc_markerfill.png'], style='mpl20', - tol=0.033 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.033) def test_markers_fillstyle_rcparams(): fig, ax = plt.subplots() x = np.arange(7) @@ -5634,7 +5634,7 @@ def test_vertex_markers(): @image_comparison(['vline_hline_zorder.png', 'errorbar_zorder.png'], style='mpl20', - tol=0.02 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.02) def test_eb_line_zorder(): x = list(range(10)) @@ -6666,7 +6666,7 @@ def test_pie_linewidth_0(): @image_comparison(['pie_center_radius.png'], style='mpl20', - tol=0.01 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.01) def test_pie_center_radius(): # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' @@ -9857,7 +9857,7 @@ def test_zorder_and_explicit_rasterization(): @image_comparison(["preset_clip_paths.png"], remove_text=True, style="mpl20", - tol=0.01 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.01) def test_preset_clip_paths(): fig, ax = plt.subplots() diff --git a/lib/matplotlib/tests/test_figure.py b/lib/matplotlib/tests/test_figure.py index fbfb2515f42e..8391bda62e3c 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -1397,7 +1397,7 @@ def test_subfigure_dpi(): @image_comparison(['test_subfigure_ss.png'], style='mpl20', savefig_kwarg={'facecolor': 'teal'}, - tol=0.022 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.022) def test_subfigure_ss(): # test assigning the subfigure via subplotspec np.random.seed(19680801) diff --git a/lib/matplotlib/tests/test_legend.py b/lib/matplotlib/tests/test_legend.py index 67b433fe7447..84d3b7c4f09d 100644 --- a/lib/matplotlib/tests/test_legend.py +++ b/lib/matplotlib/tests/test_legend.py @@ -2,7 +2,6 @@ import io import itertools import platform -import sys import time from unittest import mock import warnings @@ -203,7 +202,7 @@ def test_alpha_rcparam(): @image_comparison(['fancy.png'], remove_text=True, style='mpl20', - tol=0.01 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.01) def test_fancy(): # using subplot triggers some offsetbox functionality untested elsewhere plt.subplot(121) @@ -665,7 +664,7 @@ def test_empty_bar_chart_with_legend(): @image_comparison(['shadow_argument_types.png'], remove_text=True, style='mpl20', - tol=0.028 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.028) def test_shadow_argument_types(): # Test that different arguments for shadow work as expected fig, ax = plt.subplots() diff --git a/lib/matplotlib/tests/test_patheffects.py b/lib/matplotlib/tests/test_patheffects.py index 7095f6b3855b..d8dfee3c1b94 100644 --- a/lib/matplotlib/tests/test_patheffects.py +++ b/lib/matplotlib/tests/test_patheffects.py @@ -1,4 +1,4 @@ -import sys +import platform import numpy as np @@ -30,7 +30,7 @@ def test_patheffect1(): @image_comparison(['patheffect2'], remove_text=True, style='mpl20', - tol=0.051 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.051) def test_patheffect2(): ax2 = plt.subplot() @@ -46,7 +46,7 @@ def test_patheffect2(): @image_comparison(['patheffect3'], style='mpl20', - tol=0.02 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.02) def test_patheffect3(): plt.figure(figsize=(8, 6)) p1, = plt.plot([1, 3, 5, 4, 3], 'o-b', lw=4) diff --git a/lib/matplotlib/tests/test_polar.py b/lib/matplotlib/tests/test_polar.py index 168047d0c07e..b7c55335aaa7 100644 --- a/lib/matplotlib/tests/test_polar.py +++ b/lib/matplotlib/tests/test_polar.py @@ -1,4 +1,4 @@ -import sys +import platform import numpy as np from numpy.testing import assert_allclose @@ -12,7 +12,7 @@ @image_comparison(['polar_axes.png'], style='default', - tol=0.009 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.009) def test_polar_annotations(): # You can specify the xypoint and the xytext in different positions and # coordinate systems, and optionally turn on a connecting line and mark the @@ -47,7 +47,7 @@ def test_polar_annotations(): @image_comparison(['polar_coords.png'], style='default', remove_text=True, - tol=0.013 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.013) def test_polar_coord_annotations(): # You can also use polar notation on a cartesian axes. Here the native # coordinate system ('data') is cartesian, so you need to specify the diff --git a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py index 14bb1bbd9ba5..9d6b094ce005 100644 --- a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py +++ b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py @@ -1724,7 +1724,7 @@ def test_errorbar3d_errorevery(): @mpl3d_image_comparison(['errorbar3d.png'], style='mpl20', - tol=0.015 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.015) def test_errorbar3d(): """Tests limits, color styling, and legend for 3D errorbars.""" fig = plt.figure() diff --git a/lib/mpl_toolkits/mplot3d/tests/test_legend3d.py b/lib/mpl_toolkits/mplot3d/tests/test_legend3d.py index a46c958222d8..86e0017699fb 100644 --- a/lib/mpl_toolkits/mplot3d/tests/test_legend3d.py +++ b/lib/mpl_toolkits/mplot3d/tests/test_legend3d.py @@ -1,4 +1,4 @@ -import sys +import platform import numpy as np @@ -28,7 +28,7 @@ def test_legend_bar(): @image_comparison(['fancy.png'], remove_text=True, style='mpl20', - tol=0.01 if sys.platform == 'darwin' else 0) + tol=0 if platform.machine() == 'x86_64' else 0.01) def test_fancy(): fig, ax = plt.subplots(subplot_kw=dict(projection='3d')) ax.plot(np.arange(10), np.full(10, 5), np.full(10, 5), 'o--', label='line')