Skip to content
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

Increase tolerance for alternate architectures #17800

Merged
merged 3 commits into from Jul 10, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/matplotlib/testing/decorators.py
Expand Up @@ -336,6 +336,9 @@ def image_comparison(baseline_images, extensions=None, tol=0,
tol : float, default: 0
The RMS threshold above which the test is considered failed.

Due to expected small differences in floating-point calculations, on
32-bit systems an additional 0.06 is added to this threshold.

freetype_version : str or tuple
The expected freetype version or range of versions for this test to
pass.
Expand Down Expand Up @@ -378,6 +381,8 @@ def image_comparison(baseline_images, extensions=None, tol=0,
extensions = ['png', 'pdf', 'svg']
if savefig_kwarg is None:
savefig_kwarg = dict() # default no kwargs to savefig
if sys.maxsize <= 2**32:
tacaswell marked this conversation as resolved.
Show resolved Hide resolved
tol += 0.06
return _pytest_image_comparison(
baseline_images=baseline_images, extensions=extensions, tol=tol,
freetype_version=freetype_version, remove_text=remove_text,
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_arrow_patches.py
Expand Up @@ -67,7 +67,7 @@ def __prepare_fancyarrow_dpi_cor_test():


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


@image_comparison(['fancyarrow_dpi_cor_200dpi.png'], remove_text=True,
tol={'aarch64': 0.02}.get(platform.machine(), 0.0),
tol=0 if platform.machine() == 'x86_64' else 0.02,
savefig_kwarg=dict(dpi=200))
def test_fancyarrow_dpi_cor_200dpi():
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_axes.py
Expand Up @@ -3738,7 +3738,7 @@ def test_vertex_markers():


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

Expand Down
6 changes: 1 addition & 5 deletions lib/matplotlib/tests/test_backend_pgf.py
Expand Up @@ -8,7 +8,6 @@

import numpy as np
import pytest
import platform

import matplotlib as mpl
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -179,10 +178,7 @@ def test_pathclip():
# test mixed mode rendering
@needs_xelatex
@pytest.mark.backend('pgf')
@image_comparison(['pgf_mixedmode.pdf'], style='default',
tol={'aarch64': 1.086, 'x86_64': 1.086}.get(
platform.machine(), 0.0
))
@image_comparison(['pgf_mixedmode.pdf'], style='default')
def test_mixedmode():
rc_xelatex = {'font.family': 'serif',
'pgf.rcfonts': False}
Expand Down
4 changes: 1 addition & 3 deletions lib/matplotlib/tests/test_collections.py
@@ -1,5 +1,4 @@
import io
import platform
from types import SimpleNamespace

import numpy as np
Expand Down Expand Up @@ -334,8 +333,7 @@ def test_barb_limits():
decimal=1)


@image_comparison(['EllipseCollection_test_image.png'], remove_text=True,
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
@image_comparison(['EllipseCollection_test_image.png'], remove_text=True)
def test_EllipseCollection():
# Test basic functionality
fig, ax = plt.subplots()
Expand Down
4 changes: 3 additions & 1 deletion lib/matplotlib/tests/test_contour.py
@@ -1,4 +1,5 @@
import datetime
import platform
import re

import numpy as np
Expand Down Expand Up @@ -189,7 +190,8 @@ def test_contour_datetime_axis():


@image_comparison(['contour_test_label_transforms.png'],
remove_text=True, style='mpl20')
remove_text=True, style='mpl20',
tol=0 if platform.machine() == 'x86_64' else 0.08)
def test_labels():
# Adapted from pylab_examples example code: contour_demo.py
# see issues #2475, #2843, and #2818 for explanation
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_figure.py
Expand Up @@ -22,7 +22,7 @@


@image_comparison(['figure_align_labels'],
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
tol=0 if platform.machine() == 'x86_64' else 0.01)
def test_align_labels():
fig = plt.figure(tight_layout=True)
gs = gridspec.GridSpec(3, 3)
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_image.py
Expand Up @@ -861,7 +861,7 @@ def test_imshow_endianess():


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

Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/tests/test_legend.py
Expand Up @@ -105,7 +105,7 @@ def test_multiple_keys():


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


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


@image_comparison(['framealpha'], remove_text=True,
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
tol=0 if platform.machine() == 'x86_64' else 0.02)
def test_framealpha():
x = np.linspace(1, 100, 100)
y = x
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_patheffects.py
Expand Up @@ -115,7 +115,7 @@ def test_SimplePatchShadow_offset():
assert pe._offset == (4, 5)


@image_comparison(['collection'], tol=0.02, style='mpl20')
@image_comparison(['collection'], tol=0.03, style='mpl20')
def test_collection():
x, y = np.meshgrid(np.linspace(0, 10, 150), np.linspace(-5, 5, 100))
data = np.sin(x) + np.cos(y)
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_pickle.py
Expand Up @@ -41,7 +41,7 @@ def test_simple():


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

Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/tests/test_polar.py
@@ -1,3 +1,5 @@
import platform

import numpy as np
from numpy.testing import assert_allclose
import pytest
Expand All @@ -7,7 +9,8 @@
from matplotlib.testing.decorators import image_comparison, check_figures_equal


@image_comparison(['polar_axes'], style='default')
@image_comparison(['polar_axes'], style='default',
tol=0 if platform.machine() == 'x86_64' else 0.01)
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
Expand Down
4 changes: 1 addition & 3 deletions lib/matplotlib/tests/test_streamplot.py
@@ -1,5 +1,4 @@
import sys
import platform

import numpy as np
from numpy.testing import assert_array_almost_equal
Expand Down Expand Up @@ -48,8 +47,7 @@ def test_colormap():
plt.colorbar()


@image_comparison(['streamplot_linewidth'], remove_text=True, style='mpl20',
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
@image_comparison(['streamplot_linewidth'], remove_text=True, style='mpl20')
def test_linewidth():
X, Y, U, V = velocity_field()
speed = np.hypot(U, V)
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_units.py
Expand Up @@ -74,7 +74,7 @@ def default_units(value, axis):
# Tests that the conversion machinery works properly for classes that
# work as a facade over numpy arrays (like pint)
@image_comparison(['plot_pint.png'], remove_text=False, style='mpl20',
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
tol=0 if platform.machine() == 'x86_64' else 0.01)
def test_numpy_facade(quantity_converter):
# use former defaults to match existing baseline image
plt.rcParams['axes.formatter.limits'] = -7, 7
Expand All @@ -101,7 +101,7 @@ def test_numpy_facade(quantity_converter):

# Tests gh-8908
@image_comparison(['plot_masked_units.png'], remove_text=True, style='mpl20',
tol={'aarch64': 0.02}.get(platform.machine(), 0.0))
tol=0 if platform.machine() == 'x86_64' else 0.01)
def test_plot_masked_units():
data = np.linspace(-5, 5)
data_masked = np.ma.array(data, mask=(data > -2) & (data < 2))
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/tests/test_axes_grid1.py
Expand Up @@ -331,7 +331,7 @@ def test_zooming_with_inverted_axes():


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


@image_comparison(['custom_transform.png'], style='default',
tol={'aarch64': 0.034}.get(platform.machine(), 0.03))
tol=0.03 if platform.machine() == 'x86_64' else 0.034)
def test_custom_transform():
class MyTransform(Transform):
input_dims = output_dims = 2
Expand Down