From 5feeb8bf35d2d9016bd55c794c41c62df6c042da Mon Sep 17 00:00:00 2001 From: Zhou Qiankang Date: Tue, 23 Jun 2026 17:40:29 +0800 Subject: [PATCH] Add loongarch64 image comparison tolerances Signed-off-by: Zhou Qiankang --- lib/matplotlib/tests/test_axes.py | 21 ++++++++++++------- lib/matplotlib/tests/test_figure.py | 3 ++- lib/matplotlib/tests/test_inset.py | 6 ++++-- lib/matplotlib/tests/test_legend.py | 6 ++++-- lib/matplotlib/tests/test_patheffects.py | 7 +++++-- lib/matplotlib/tests/test_polar.py | 7 +++++-- lib/mpl_toolkits/mplot3d/tests/test_axes3d.py | 3 ++- .../mplot3d/tests/test_legend3d.py | 4 +++- 8 files changed, 39 insertions(+), 18 deletions(-) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 7fedb1828cad..ddc9da29a5a6 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -239,8 +239,10 @@ def test_matshow(fig_test, fig_ref): ax_ref.xaxis.set_ticks_position('both') -@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) +@image_comparison([f'formatter_ticker_{i:03d}.png' for i in range(1, 6)], + style='mpl20', + tol=(0.03 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) def test_formatter_ticker(): import matplotlib.testing.jpl_units as units units.register() @@ -5608,7 +5610,8 @@ def test_marker_styles(): @image_comparison(['rc_markerfill.png'], style='mpl20', - tol=0.033 if sys.platform == 'darwin' else 0) + tol=(0.033 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) def test_markers_fillstyle_rcparams(): fig, ax = plt.subplots() x = np.arange(7) @@ -5630,8 +5633,10 @@ def test_vertex_markers(): ax.set_ylim(-1, 10) -@image_comparison(['vline_hline_zorder.png', 'errorbar_zorder.png'], style='mpl20', - tol=0.02 if sys.platform == 'darwin' else 0) +@image_comparison(['vline_hline_zorder.png', 'errorbar_zorder.png'], + style='mpl20', + tol=(0.02 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) def test_eb_line_zorder(): x = list(range(10)) @@ -6681,7 +6686,8 @@ def test_pie_linewidth_0(): @image_comparison(['pie_center_radius.png'], style='mpl20', - tol=0.01 if sys.platform == 'darwin' else 0) + tol=(0.01 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) def test_pie_center_radius(): # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' @@ -9901,7 +9907,8 @@ 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.01 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) 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..13fa70e92c6b 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -1397,7 +1397,8 @@ 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.022 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) def test_subfigure_ss(): # test assigning the subfigure via subplotspec np.random.seed(19680801) diff --git a/lib/matplotlib/tests/test_inset.py b/lib/matplotlib/tests/test_inset.py index 81528580c723..bbf481c23253 100644 --- a/lib/matplotlib/tests/test_inset.py +++ b/lib/matplotlib/tests/test_inset.py @@ -93,8 +93,10 @@ def test_inset_indicator_zorder(): assert inset.get_zorder() == 42 -@image_comparison(['zoom_inset_connector_styles.png'], remove_text=True, style='mpl20', - tol=0.024 if platform.machine() in ['aarch64', 'arm64'] else 0) +@image_comparison(['zoom_inset_connector_styles.png'], + remove_text=True, style='mpl20', + tol=(0.024 if platform.machine() in ['aarch64', 'arm64', + 'loongarch64'] else 0)) def test_zoom_inset_connector_styles(): fig, axs = plt.subplots(2) for ax in axs: diff --git a/lib/matplotlib/tests/test_legend.py b/lib/matplotlib/tests/test_legend.py index 67b433fe7447..b3c034a762db 100644 --- a/lib/matplotlib/tests/test_legend.py +++ b/lib/matplotlib/tests/test_legend.py @@ -203,7 +203,8 @@ def test_alpha_rcparam(): @image_comparison(['fancy.png'], remove_text=True, style='mpl20', - tol=0.01 if sys.platform == 'darwin' else 0) + tol=(0.01 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) def test_fancy(): # using subplot triggers some offsetbox functionality untested elsewhere plt.subplot(121) @@ -665,7 +666,8 @@ 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.028 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) 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..98ea2a707133 100644 --- a/lib/matplotlib/tests/test_patheffects.py +++ b/lib/matplotlib/tests/test_patheffects.py @@ -1,4 +1,5 @@ import sys +import platform import numpy as np @@ -30,7 +31,8 @@ def test_patheffect1(): @image_comparison(['patheffect2'], remove_text=True, style='mpl20', - tol=0.051 if sys.platform == 'darwin' else 0) + tol=(0.051 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) def test_patheffect2(): ax2 = plt.subplot() @@ -46,7 +48,8 @@ def test_patheffect2(): @image_comparison(['patheffect3'], style='mpl20', - tol=0.02 if sys.platform == 'darwin' else 0) + tol=(0.02 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) 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 3ff8769d3fad..45946b818fd2 100644 --- a/lib/matplotlib/tests/test_polar.py +++ b/lib/matplotlib/tests/test_polar.py @@ -1,4 +1,5 @@ import sys +import platform import numpy as np from numpy.testing import assert_allclose @@ -12,7 +13,8 @@ @image_comparison(['polar_axes.png'], style='default', - tol=0.009 if sys.platform == 'darwin' else 0) + tol=(0.009 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) 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 +49,8 @@ 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.013 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) 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 1e150f1c92c8..8a1b5acb0534 100644 --- a/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py +++ b/lib/mpl_toolkits/mplot3d/tests/test_axes3d.py @@ -1722,7 +1722,8 @@ def test_errorbar3d_errorevery(): @mpl3d_image_comparison(['errorbar3d.png'], style='mpl20', - tol=0.015 if sys.platform == 'darwin' else 0) + tol=(0.015 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) 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..3ce294e9a49f 100644 --- a/lib/mpl_toolkits/mplot3d/tests/test_legend3d.py +++ b/lib/mpl_toolkits/mplot3d/tests/test_legend3d.py @@ -1,4 +1,5 @@ import sys +import platform import numpy as np @@ -28,7 +29,8 @@ def test_legend_bar(): @image_comparison(['fancy.png'], remove_text=True, style='mpl20', - tol=0.01 if sys.platform == 'darwin' else 0) + tol=(0.01 if sys.platform == 'darwin' + or platform.machine() == 'loongarch64' else 0)) 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')