Skip to content

Commit 9e519eb

Browse files
authored
Merge pull request #17800 from QuLogic/altarch
TST: Increase tolerance for alternate architectures
2 parents f8d10f5 + 7deb36d commit 9e519eb

16 files changed

+29
-27
lines changed

lib/matplotlib/testing/decorators.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ def image_comparison(baseline_images, extensions=None, tol=0,
336336
tol : float, default: 0
337337
The RMS threshold above which the test is considered failed.
338338
339+
Due to expected small differences in floating-point calculations, on
340+
32-bit systems an additional 0.06 is added to this threshold.
341+
339342
freetype_version : str or tuple
340343
The expected freetype version or range of versions for this test to
341344
pass.
@@ -378,6 +381,8 @@ def image_comparison(baseline_images, extensions=None, tol=0,
378381
extensions = ['png', 'pdf', 'svg']
379382
if savefig_kwarg is None:
380383
savefig_kwarg = dict() # default no kwargs to savefig
384+
if sys.maxsize <= 2**32:
385+
tol += 0.06
381386
return _pytest_image_comparison(
382387
baseline_images=baseline_images, extensions=extensions, tol=tol,
383388
freetype_version=freetype_version, remove_text=remove_text,

lib/matplotlib/tests/test_arrow_patches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __prepare_fancyarrow_dpi_cor_test():
6767

6868

6969
@image_comparison(['fancyarrow_dpi_cor_100dpi.png'], remove_text=True,
70-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0),
70+
tol=0 if platform.machine() == 'x86_64' else 0.02,
7171
savefig_kwarg=dict(dpi=100))
7272
def test_fancyarrow_dpi_cor_100dpi():
7373
"""
@@ -82,7 +82,7 @@ def test_fancyarrow_dpi_cor_100dpi():
8282

8383

8484
@image_comparison(['fancyarrow_dpi_cor_200dpi.png'], remove_text=True,
85-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0),
85+
tol=0 if platform.machine() == 'x86_64' else 0.02,
8686
savefig_kwarg=dict(dpi=200))
8787
def test_fancyarrow_dpi_cor_200dpi():
8888
"""

lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3738,7 +3738,7 @@ def test_vertex_markers():
37383738

37393739

37403740
@image_comparison(['vline_hline_zorder', 'errorbar_zorder'],
3741-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
3741+
tol=0 if platform.machine() == 'x86_64' else 0.02)
37423742
def test_eb_line_zorder():
37433743
x = list(range(10))
37443744

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import numpy as np
1010
import pytest
11-
import platform
1211

1312
import matplotlib as mpl
1413
import matplotlib.pyplot as plt
@@ -179,10 +178,7 @@ def test_pathclip():
179178
# test mixed mode rendering
180179
@needs_xelatex
181180
@pytest.mark.backend('pgf')
182-
@image_comparison(['pgf_mixedmode.pdf'], style='default',
183-
tol={'aarch64': 1.086, 'x86_64': 1.086}.get(
184-
platform.machine(), 0.0
185-
))
181+
@image_comparison(['pgf_mixedmode.pdf'], style='default')
186182
def test_mixedmode():
187183
rc_xelatex = {'font.family': 'serif',
188184
'pgf.rcfonts': False}

lib/matplotlib/tests/test_collections.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import io
2-
import platform
32
from types import SimpleNamespace
43

54
import numpy as np
@@ -334,8 +333,7 @@ def test_barb_limits():
334333
decimal=1)
335334

336335

337-
@image_comparison(['EllipseCollection_test_image.png'], remove_text=True,
338-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
336+
@image_comparison(['EllipseCollection_test_image.png'], remove_text=True)
339337
def test_EllipseCollection():
340338
# Test basic functionality
341339
fig, ax = plt.subplots()

lib/matplotlib/tests/test_contour.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
import platform
23
import re
34

45
import numpy as np
@@ -189,7 +190,8 @@ def test_contour_datetime_axis():
189190

190191

191192
@image_comparison(['contour_test_label_transforms.png'],
192-
remove_text=True, style='mpl20')
193+
remove_text=True, style='mpl20',
194+
tol=0 if platform.machine() == 'x86_64' else 0.08)
193195
def test_labels():
194196
# Adapted from pylab_examples example code: contour_demo.py
195197
# see issues #2475, #2843, and #2818 for explanation

lib/matplotlib/tests/test_figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
@image_comparison(['figure_align_labels'],
25-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
25+
tol=0 if platform.machine() == 'x86_64' else 0.01)
2626
def test_align_labels():
2727
fig = plt.figure(tight_layout=True)
2828
gs = gridspec.GridSpec(3, 3)

lib/matplotlib/tests/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ def test_imshow_endianess():
861861

862862

863863
@image_comparison(['imshow_masked_interpolation'],
864-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0),
864+
tol=0 if platform.machine() == 'x86_64' else 0.01,
865865
remove_text=True, style='mpl20')
866866
def test_imshow_masked_interpolation():
867867

lib/matplotlib/tests/test_legend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_multiple_keys():
105105

106106

107107
@image_comparison(['rgba_alpha.png'], remove_text=True,
108-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
108+
tol=0 if platform.machine() == 'x86_64' else 0.01)
109109
def test_alpha_rgba():
110110
fig, ax = plt.subplots(1, 1)
111111
ax.plot(range(10), lw=5)
@@ -114,7 +114,7 @@ def test_alpha_rgba():
114114

115115

116116
@image_comparison(['rcparam_alpha.png'], remove_text=True,
117-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
117+
tol=0 if platform.machine() == 'x86_64' else 0.01)
118118
def test_alpha_rcparam():
119119
fig, ax = plt.subplots(1, 1)
120120
ax.plot(range(10), lw=5)
@@ -140,7 +140,7 @@ def test_fancy():
140140

141141

142142
@image_comparison(['framealpha'], remove_text=True,
143-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
143+
tol=0 if platform.machine() == 'x86_64' else 0.02)
144144
def test_framealpha():
145145
x = np.linspace(1, 100, 100)
146146
y = x

lib/matplotlib/tests/test_patheffects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_SimplePatchShadow_offset():
115115
assert pe._offset == (4, 5)
116116

117117

118-
@image_comparison(['collection'], tol=0.02, style='mpl20')
118+
@image_comparison(['collection'], tol=0.03, style='mpl20')
119119
def test_collection():
120120
x, y = np.meshgrid(np.linspace(0, 10, 150), np.linspace(-5, 5, 100))
121121
data = np.sin(x) + np.cos(y)

lib/matplotlib/tests/test_pickle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_simple():
4141

4242

4343
@image_comparison(['multi_pickle.png'], remove_text=True, style='mpl20',
44-
tol={'aarch64': 0.082}.get(platform.machine(), 0.0))
44+
tol=0 if platform.machine() == 'x86_64' else 0.082)
4545
def test_complete():
4646
fig = plt.figure('Figure with a label?', figsize=(10, 6))
4747

lib/matplotlib/tests/test_polar.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import platform
2+
13
import numpy as np
24
from numpy.testing import assert_allclose
35
import pytest
@@ -7,7 +9,8 @@
79
from matplotlib.testing.decorators import image_comparison, check_figures_equal
810

911

10-
@image_comparison(['polar_axes'], style='default')
12+
@image_comparison(['polar_axes'], style='default',
13+
tol=0 if platform.machine() == 'x86_64' else 0.01)
1114
def test_polar_annotations():
1215
# You can specify the xypoint and the xytext in different positions and
1316
# coordinate systems, and optionally turn on a connecting line and mark the

lib/matplotlib/tests/test_streamplot.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import sys
2-
import platform
32

43
import numpy as np
54
from numpy.testing import assert_array_almost_equal
@@ -48,8 +47,7 @@ def test_colormap():
4847
plt.colorbar()
4948

5049

51-
@image_comparison(['streamplot_linewidth'], remove_text=True, style='mpl20',
52-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
50+
@image_comparison(['streamplot_linewidth'], remove_text=True, style='mpl20')
5351
def test_linewidth():
5452
X, Y, U, V = velocity_field()
5553
speed = np.hypot(U, V)

lib/matplotlib/tests/test_units.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def default_units(value, axis):
7474
# Tests that the conversion machinery works properly for classes that
7575
# work as a facade over numpy arrays (like pint)
7676
@image_comparison(['plot_pint.png'], remove_text=False, style='mpl20',
77-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
77+
tol=0 if platform.machine() == 'x86_64' else 0.01)
7878
def test_numpy_facade(quantity_converter):
7979
# use former defaults to match existing baseline image
8080
plt.rcParams['axes.formatter.limits'] = -7, 7
@@ -101,7 +101,7 @@ def test_numpy_facade(quantity_converter):
101101

102102
# Tests gh-8908
103103
@image_comparison(['plot_masked_units.png'], remove_text=True, style='mpl20',
104-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
104+
tol=0 if platform.machine() == 'x86_64' else 0.01)
105105
def test_plot_masked_units():
106106
data = np.linspace(-5, 5)
107107
data_masked = np.ma.array(data, mask=(data > -2) & (data < 2))

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def test_zooming_with_inverted_axes():
331331

332332

333333
@image_comparison(['anchored_direction_arrows.png'],
334-
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
334+
tol=0 if platform.machine() == 'x86_64' else 0.01)
335335
def test_anchored_direction_arrows():
336336
fig, ax = plt.subplots()
337337
ax.imshow(np.zeros((10, 10)), interpolation='nearest')

lib/mpl_toolkits/tests/test_axisartist_grid_helper_curvelinear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
@image_comparison(['custom_transform.png'], style='default',
20-
tol={'aarch64': 0.034}.get(platform.machine(), 0.03))
20+
tol=0.03 if platform.machine() == 'x86_64' else 0.034)
2121
def test_custom_transform():
2222
class MyTransform(Transform):
2323
input_dims = output_dims = 2

0 commit comments

Comments
 (0)