Skip to content
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
64 changes: 23 additions & 41 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,8 @@ def test_matshow(fig_test, fig_ref):
ax_ref.xaxis.set_ticks_position('both')


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison([f'formatter_ticker_{i:03d}.png' for i in range(1, 6)], style='mpl20',
tol=0.02 if platform.machine() == 'x86_64' else 0.04)
tol=0.03 if sys.platform == 'darwin' else 0)
def test_formatter_ticker():
import matplotlib.testing.jpl_units as units
units.register()
Expand Down Expand Up @@ -811,8 +810,7 @@ def test_annotate_signature():
assert p1 == p2


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['fill_units.png'], savefig_kwarg={'dpi': 60}, style='mpl20', tol=0.2)
@image_comparison(['fill_units.png'], savefig_kwarg={'dpi': 60}, style='mpl20')
def test_fill_units():
import matplotlib.testing.jpl_units as units
units.register()
Expand Down Expand Up @@ -951,7 +949,7 @@ def test_axvspan_epoch():
ax.set_xlim(t0 - 5.0*dt, tf + 5.0*dt)


@image_comparison(['axhspan_epoch.png'], style='mpl20', tol=0.02)
@image_comparison(['axhspan_epoch.png'], style='mpl20')
def test_axhspan_epoch():
import matplotlib.testing.jpl_units as units
units.register()
Expand Down Expand Up @@ -1515,8 +1513,7 @@ def test_pcolormesh_log_scale(fig_test, fig_ref):
ax.set_xscale('log')


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['pcolormesh_datetime_axis.png'], style='mpl20', tol=0.3)
@image_comparison(['pcolormesh_datetime_axis.png'], style='mpl20')
def test_pcolormesh_datetime_axis():
fig = plt.figure()
fig.subplots_adjust(hspace=0.4, top=0.98, bottom=.15)
Expand All @@ -1541,8 +1538,7 @@ def test_pcolormesh_datetime_axis():
label.set_rotation(30)


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['pcolor_datetime_axis.png'], style='mpl20', tol=0.3)
@image_comparison(['pcolor_datetime_axis.png'], style='mpl20')
def test_pcolor_datetime_axis():
fig = plt.figure()
fig.subplots_adjust(hspace=0.4, top=0.98, bottom=.15)
Expand Down Expand Up @@ -1852,12 +1848,8 @@ def test_markevery():
ax.legend()


@image_comparison(['markevery_line.png'], remove_text=True, style='mpl20', tol=0.005)
@image_comparison(['markevery_line.png'], remove_text=True, style='mpl20')
def test_markevery_line():
# TODO: a slight change in rendering between Inkscape versions may explain
# why one had to introduce a small non-zero tolerance for the SVG test
# to pass. One may try to remove this hack once Travis' Inkscape version
# is modern enough. FWIW, no failure with 0.92.3 on my computer (#11358).
x = np.linspace(0, 10, 100)
y = np.sin(x) * np.sqrt(x/10 + 0.5)

Expand Down Expand Up @@ -2778,8 +2770,7 @@ def test_stairs_options():
ax.legend(loc=0)


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['test_stairs_datetime.png'], style='mpl20', tol=0.2)
@image_comparison(['test_stairs_datetime.png'], style='mpl20')
def test_stairs_datetime():
f, ax = plt.subplots(constrained_layout=True)
ax.stairs(np.arange(36),
Expand Down Expand Up @@ -3403,8 +3394,7 @@ def test_log_scales_invalid():


@image_comparison(['stackplot_test_image.png', 'stackplot_test_image.png'],
style='mpl20',
tol=0 if platform.machine() == 'x86_64' else 0.031)
style='mpl20')
def test_stackplot():
fig = plt.figure()
x = np.linspace(0, 10, 10)
Expand Down Expand Up @@ -3565,10 +3555,7 @@ def test_bxp_horizontal():
_bxp_test_helper(bxp_kwargs=dict(orientation='horizontal'))


@image_comparison(['bxp_with_ylabels.png'],
savefig_kwarg={'dpi': 40},
style='default',
tol=0.1)
@image_comparison(['bxp_with_ylabels.png'], savefig_kwarg={'dpi': 40}, style='default')
def test_bxp_with_ylabels():
def transform(stats):
for s, label in zip(stats, list('ABCD')):
Expand Down Expand Up @@ -3769,7 +3756,7 @@ def test_bxp_bad_capwidths():
_bxp_test_helper(bxp_kwargs=dict(capwidths=[1]))


@image_comparison(['boxplot.png', 'boxplot.png'], tol=1.28, style='default')
@image_comparison(['boxplot.png', 'boxplot.png'], tol=0.43, style='default')
def test_boxplot():
# Randomness used for bootstrapping.
np.random.seed(937)
Expand Down Expand Up @@ -5551,7 +5538,7 @@ def test_marker_styles():


@image_comparison(['rc_markerfill.png'], style='mpl20',
tol=0 if platform.machine() == 'x86_64' else 0.037)
tol=0.033 if sys.platform == 'darwin' else 0)
def test_markers_fillstyle_rcparams():
fig, ax = plt.subplots()
x = np.arange(7)
Expand All @@ -5574,7 +5561,7 @@ def test_vertex_markers():


@image_comparison(['vline_hline_zorder.png', 'errorbar_zorder.png'], style='mpl20',
tol=0 if platform.machine() == 'x86_64' else 0.026)
tol=0.02 if sys.platform == 'darwin' else 0)
def test_eb_line_zorder():
x = list(range(10))

Expand Down Expand Up @@ -6487,12 +6474,7 @@ def test_text_labelsize():
ax.tick_params(direction='out')


# Note: The `pie` image tests were affected by Numpy 2.0 changing promotions
# (NEP 50). While the changes were only marginal, tolerances were introduced.
# These tolerances could likely go away when numpy 2.0 is the minimum supported
# numpy and the images are regenerated.

@image_comparison(['pie_default.png'], style='mpl20', tol=0.01)
@image_comparison(['pie_default.png'], style='mpl20')
def test_pie_default():
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
Expand All @@ -6505,7 +6487,7 @@ def test_pie_default():


@image_comparison(['pie_linewidth_0.png', 'pie_linewidth_0.png', 'pie_linewidth_0.png'],
style='mpl20', tol=0.01)
style='mpl20')
def test_pie_linewidth_0():
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
Expand Down Expand Up @@ -6537,7 +6519,8 @@ def test_pie_linewidth_0():
plt.axis('equal')


@image_comparison(['pie_center_radius.png'], style='mpl20', tol=0.011)
@image_comparison(['pie_center_radius.png'], style='mpl20',
tol=0.01 if sys.platform == 'darwin' else 0)
def test_pie_center_radius():
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
Expand All @@ -6557,7 +6540,7 @@ def test_pie_center_radius():
plt.axis('equal')


@image_comparison(['pie_linewidth_2.png'], style='mpl20', tol=0.01)
@image_comparison(['pie_linewidth_2.png'], style='mpl20')
def test_pie_linewidth_2():
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
Expand All @@ -6572,7 +6555,7 @@ def test_pie_linewidth_2():
plt.axis('equal')


@image_comparison(['pie_ccw_true.png'], style='mpl20', tol=0.01)
@image_comparison(['pie_ccw_true.png'], style='mpl20')
def test_pie_ccw_true():
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
Expand All @@ -6587,7 +6570,7 @@ def test_pie_ccw_true():
plt.axis('equal')


@image_comparison(['pie_frame_grid.png'], style='mpl20', tol=0.002)
@image_comparison(['pie_frame_grid.png'], style='mpl20')
def test_pie_frame_grid():
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
Expand All @@ -6614,8 +6597,7 @@ def test_pie_frame_grid():
plt.axis('equal')


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['pie_rotatelabels_true.png'], style='mpl20', tol=0.1)
@image_comparison(['pie_rotatelabels_true.png'], style='mpl20')
def test_pie_rotatelabels_true():
# The slices will be ordered and plotted counter-clockwise.
labels = 'Hogwarts', 'Frogs', 'Dogs', 'Logs'
Expand All @@ -6630,7 +6612,7 @@ def test_pie_rotatelabels_true():
plt.axis('equal')


@image_comparison(['pie_no_label.png'], style='mpl20', tol=0.01)
@image_comparison(['pie_no_label.png'], style='mpl20')
def test_pie_nolabel_but_legend():
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
Expand Down Expand Up @@ -8356,7 +8338,7 @@ def inverted(self):


@image_comparison(['secondary_xy.png'], style='mpl20',
tol=0 if platform.machine() == 'x86_64' else 0.027)
tol=0 if platform.machine() == 'x86_64' else 0.024)
def test_secondary_xy():
fig, axs = plt.subplots(1, 2, figsize=(10, 5), constrained_layout=True)

Expand Down Expand Up @@ -9648,7 +9630,7 @@ def test_zorder_and_explicit_rasterization():


@image_comparison(["preset_clip_paths.png"], remove_text=True, style="mpl20",
tol=0 if platform.machine() == 'x86_64' else 0.027)
tol=0.01 if sys.platform == 'darwin' else 0)
def test_preset_clip_paths():
fig, ax = plt.subplots()

Expand Down
6 changes: 2 additions & 4 deletions lib/matplotlib/tests/test_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,13 @@ def test_colorbar_extension_inverted_axis(orientation, extend, expected):
assert len(cbar._extend_patches) == 1


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@pytest.mark.parametrize('use_gridspec', [True, False])
@image_comparison(['cbar_with_orientation.png',
'cbar_locationing.png',
'double_cbar.png',
'cbar_sharing.png',
],
remove_text=True, savefig_kwarg={'dpi': 40}, style='mpl20', tol=0.05)
remove_text=True, savefig_kwarg={'dpi': 40}, style='mpl20')
def test_colorbar_positioning(use_gridspec):
data = np.arange(1200).reshape(30, 40)
levels = [0, 200, 400, 600, 800, 1000, 1200]
Expand Down Expand Up @@ -728,8 +727,7 @@ def test_colorbar_label():
assert cbar3.ax.get_xlabel() == 'horizontal cbar'


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['colorbar_keeping_xlabel.png'], style='mpl20', tol=0.03)
@image_comparison(['colorbar_keeping_xlabel.png'], style='mpl20')
def test_keeping_xlabel():
# github issue #23398 - xlabels being ignored in colorbar axis
arr = np.arange(25).reshape((5, 5))
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ def test_cmap_and_norm_from_levels_and_colors():
ax.tick_params(labelleft=False, labelbottom=False)


@image_comparison(['boundarynorm_and_colorbar.png'], tol=1.0)
@image_comparison(['boundarynorm_and_colorbar.png'])
def test_boundarynorm_and_colorbarbase():
# Make a figure and axes with dimensions as desired.
fig = plt.figure()
Expand Down
11 changes: 5 additions & 6 deletions lib/matplotlib/tests/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_contour_set_paths(fig_test, fig_ref):
cs_test.set_paths(cs_ref.get_paths())


@image_comparison(['contour_manual_labels'], remove_text=True, style='mpl20', tol=0.26)
@image_comparison(['contour_manual_labels'], remove_text=True, style='mpl20')
def test_contour_manual_labels():
x, y = np.meshgrid(np.arange(0, 10), np.arange(0, 10))
z = np.max(np.dstack([abs(x), abs(y)]), 2)
Expand Down Expand Up @@ -127,9 +127,8 @@ def test_contour_manual_moveto():
assert clabels[0].get_text() == "0"


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['contour_disconnected_segments.png'],
remove_text=True, style='mpl20', tol=0.01)
remove_text=True, style='mpl20')
def test_contour_label_with_disconnected_segments():
x, y = np.mgrid[-1:1:21j, -1:1:21j]
z = 1 / np.sqrt(0.01 + (x + 0.3) ** 2 + y ** 2)
Expand Down Expand Up @@ -229,8 +228,7 @@ def test_lognorm_levels(n_levels):
assert len(visible_levels) <= n_levels + 1


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['contour_datetime_axis.png'], style='mpl20', tol=0.3)
@image_comparison(['contour_datetime_axis.png'], style='mpl20')
def test_contour_datetime_axis():
fig = plt.figure()
fig.subplots_adjust(hspace=0.4, top=0.98, bottom=.15)
Expand All @@ -256,7 +254,8 @@ def test_contour_datetime_axis():


@image_comparison(['contour_test_label_transforms.png'],
remove_text=True, style='mpl20', tol=1.1)
remove_text=True, style='mpl20',
tol=0 if platform.machine() == 'x86_64' else 0.005)
def test_labels():
# Adapted from pylab_examples example code: contour_demo.py
# see issues #2475, #2843, and #2818 for explanation
Expand Down
12 changes: 4 additions & 8 deletions lib/matplotlib/tests/test_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ def test_date_axhspan():
fig.subplots_adjust(left=0.25)


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['date_axvspan.png'], style='mpl20', tol=0.07)
@image_comparison(['date_axvspan.png'], style='mpl20')
def test_date_axvspan():
# test axvspan with date inputs
t0 = datetime.datetime(2000, 1, 20)
Expand All @@ -177,8 +176,7 @@ def test_date_axhline():
fig.subplots_adjust(left=0.25)


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['date_axvline.png'], style='mpl20', tol=0.09)
@image_comparison(['date_axvline.png'], style='mpl20')
def test_date_axvline():
# test axvline with date inputs
t0 = datetime.datetime(2000, 1, 20)
Expand Down Expand Up @@ -228,8 +226,7 @@ def wrapper():
return wrapper


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['RRuleLocator_bounds.png'], style='mpl20', tol=0.07)
@image_comparison(['RRuleLocator_bounds.png'], style='mpl20')
def test_RRuleLocator():
import matplotlib.testing.jpl_units as units
units.register()
Expand Down Expand Up @@ -273,8 +270,7 @@ def test_RRuleLocator_close_minmax():
assert list(map(str, mdates.num2date(loc.tick_values(d1, d2)))) == expected


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['DateFormatter_fractionalSeconds.png'], style='mpl20', tol=0.11)
@image_comparison(['DateFormatter_fractionalSeconds.png'], style='mpl20')
def test_DateFormatter():
import matplotlib.testing.jpl_units as units
units.register()
Expand Down
15 changes: 5 additions & 10 deletions lib/matplotlib/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
import matplotlib.dates as mdates


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['figure_align_labels'], extensions=['png', 'svg'], style='mpl20',
tol=0.1 if platform.machine() == 'x86_64' else 0.1)
tol=0 if platform.machine() == 'x86_64' else 0.01)
def test_align_labels():
fig = plt.figure(layout='tight')
gs = gridspec.GridSpec(3, 3)
Expand Down Expand Up @@ -68,11 +67,9 @@ def test_align_labels():
fig.align_labels()


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['figure_align_titles_tight.png',
'figure_align_titles_constrained.png'],
tol=0.3 if platform.machine() == 'x86_64' else 0.04,
style='mpl20')
style='mpl20', tol=0 if platform.machine() == 'x86_64' else 0.021)
def test_align_titles():
for layout in ['tight', 'constrained']:
fig, axs = plt.subplots(1, 2, layout=layout, width_ratios=[2, 1])
Expand Down Expand Up @@ -323,8 +320,7 @@ def test_add_subplot_invalid():
fig.add_subplot(ax)


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['figure_suptitle.png'], style='mpl20', tol=0.02)
@image_comparison(['figure_suptitle.png'], style='mpl20')
def test_suptitle():
fig, _ = plt.subplots()
fig.suptitle('hello', color='r')
Expand Down Expand Up @@ -1401,7 +1397,7 @@ def test_subfigure_dpi():

@image_comparison(['test_subfigure_ss.png'], style='mpl20',
savefig_kwarg={'facecolor': 'teal'},
tol=0.022)
tol=0.022 if sys.platform == 'darwin' else 0)
def test_subfigure_ss():
# test assigning the subfigure via subplotspec
np.random.seed(19680801)
Expand All @@ -1423,9 +1419,8 @@ def test_subfigure_ss():
fig.suptitle('Figure suptitle', fontsize='xx-large')


# TODO: tighten tolerance after baseline image is regenerated for text overhaul
@image_comparison(['test_subfigure_double.png'], style='mpl20',
savefig_kwarg={'facecolor': 'teal'}, tol=0.02)
savefig_kwarg={'facecolor': 'teal'})
def test_subfigure_double():
# test assigning the subfigure via subplotspec
np.random.seed(19680801)
Expand Down
Loading
Loading