Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bca638d

Browse files
committed
TST: Reset tolerances on tests changed by text overhaul
1 parent 49bb098 commit bca638d

18 files changed

Lines changed: 95 additions & 140 deletions

lib/matplotlib/tests/test_axes.py

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,8 @@ def test_matshow(fig_test, fig_ref):
239239
ax_ref.xaxis.set_ticks_position('both')
240240

241241

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

813812

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

953951

954-
@image_comparison(['axhspan_epoch.png'], style='mpl20', tol=0.02)
952+
@image_comparison(['axhspan_epoch.png'], style='mpl20')
955953
def test_axhspan_epoch():
956954
import matplotlib.testing.jpl_units as units
957955
units.register()
@@ -1515,8 +1513,7 @@ def test_pcolormesh_log_scale(fig_test, fig_ref):
15151513
ax.set_xscale('log')
15161514

15171515

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

15431540

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

18541850

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

@@ -2778,8 +2770,7 @@ def test_stairs_options():
27782770
ax.legend(loc=0)
27792771

27802772

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

34043395

34053396
@image_comparison(['stackplot_test_image.png', 'stackplot_test_image.png'],
3406-
style='mpl20',
3407-
tol=0 if platform.machine() == 'x86_64' else 0.031)
3397+
style='mpl20')
34083398
def test_stackplot():
34093399
fig = plt.figure()
34103400
x = np.linspace(0, 10, 10)
@@ -3565,10 +3555,7 @@ def test_bxp_horizontal():
35653555
_bxp_test_helper(bxp_kwargs=dict(orientation='horizontal'))
35663556

35673557

3568-
@image_comparison(['bxp_with_ylabels.png'],
3569-
savefig_kwarg={'dpi': 40},
3570-
style='default',
3571-
tol=0.1)
3558+
@image_comparison(['bxp_with_ylabels.png'], savefig_kwarg={'dpi': 40}, style='default')
35723559
def test_bxp_with_ylabels():
35733560
def transform(stats):
35743561
for s, label in zip(stats, list('ABCD')):
@@ -3769,7 +3756,7 @@ def test_bxp_bad_capwidths():
37693756
_bxp_test_helper(bxp_kwargs=dict(capwidths=[1]))
37703757

37713758

3772-
@image_comparison(['boxplot.png', 'boxplot.png'], tol=1.28, style='default')
3759+
@image_comparison(['boxplot.png', 'boxplot.png'], tol=0.43, style='default')
37733760
def test_boxplot():
37743761
# Randomness used for bootstrapping.
37753762
np.random.seed(937)
@@ -5551,7 +5538,7 @@ def test_marker_styles():
55515538

55525539

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

55755562

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

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

64896476

6490-
# Note: The `pie` image tests were affected by Numpy 2.0 changing promotions
6491-
# (NEP 50). While the changes were only marginal, tolerances were introduced.
6492-
# These tolerances could likely go away when numpy 2.0 is the minimum supported
6493-
# numpy and the images are regenerated.
6494-
6495-
@image_comparison(['pie_default.png'], style='mpl20', tol=0.01)
6477+
@image_comparison(['pie_default.png'], style='mpl20')
64966478
def test_pie_default():
64976479
# The slices will be ordered and plotted counter-clockwise.
64986480
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
@@ -6505,7 +6487,7 @@ def test_pie_default():
65056487

65066488

65076489
@image_comparison(['pie_linewidth_0.png', 'pie_linewidth_0.png', 'pie_linewidth_0.png'],
6508-
style='mpl20', tol=0.01)
6490+
style='mpl20')
65096491
def test_pie_linewidth_0():
65106492
# The slices will be ordered and plotted counter-clockwise.
65116493
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
@@ -6537,7 +6519,8 @@ def test_pie_linewidth_0():
65376519
plt.axis('equal')
65386520

65396521

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

65596542

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

65746557

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

65896572

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

66166599

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

66326614

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

83578339

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

@@ -9648,7 +9630,7 @@ def test_zorder_and_explicit_rasterization():
96489630

96499631

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

lib/matplotlib/tests/test_colorbar.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,13 @@ def test_colorbar_extension_inverted_axis(orientation, extend, expected):
152152
assert len(cbar._extend_patches) == 1
153153

154154

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

730729

731-
# TODO: tighten tolerance after baseline image is regenerated for text overhaul
732-
@image_comparison(['colorbar_keeping_xlabel.png'], style='mpl20', tol=0.03)
730+
@image_comparison(['colorbar_keeping_xlabel.png'], style='mpl20')
733731
def test_keeping_xlabel():
734732
# github issue #23398 - xlabels being ignored in colorbar axis
735733
arr = np.arange(25).reshape((5, 5))

lib/matplotlib/tests/test_colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ def test_cmap_and_norm_from_levels_and_colors():
844844
ax.tick_params(labelleft=False, labelbottom=False)
845845

846846

847-
@image_comparison(['boundarynorm_and_colorbar.png'], tol=1.0)
847+
@image_comparison(['boundarynorm_and_colorbar.png'])
848848
def test_boundarynorm_and_colorbarbase():
849849
# Make a figure and axes with dimensions as desired.
850850
fig = plt.figure()

lib/matplotlib/tests/test_contour.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_contour_set_paths(fig_test, fig_ref):
9494
cs_test.set_paths(cs_ref.get_paths())
9595

9696

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

129129

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

231230

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

257255

258256
@image_comparison(['contour_test_label_transforms.png'],
259-
remove_text=True, style='mpl20', tol=1.1)
257+
remove_text=True, style='mpl20',
258+
tol=0 if platform.machine() == 'x86_64' else 0.005)
260259
def test_labels():
261260
# Adapted from pylab_examples example code: contour_demo.py
262261
# see issues #2475, #2843, and #2818 for explanation

lib/matplotlib/tests/test_dates.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ def test_date_axhspan():
152152
fig.subplots_adjust(left=0.25)
153153

154154

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

179178

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

230228

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

275272

276-
# TODO: tighten tolerance after baseline image is regenerated for text overhaul
277-
@image_comparison(['DateFormatter_fractionalSeconds.png'], style='mpl20', tol=0.11)
273+
@image_comparison(['DateFormatter_fractionalSeconds.png'], style='mpl20')
278274
def test_DateFormatter():
279275
import matplotlib.testing.jpl_units as units
280276
units.register()

lib/matplotlib/tests/test_figure.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
import matplotlib.dates as mdates
2727

2828

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

7069

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

325322

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

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

14251421

1426-
# TODO: tighten tolerance after baseline image is regenerated for text overhaul
14271422
@image_comparison(['test_subfigure_double.png'], style='mpl20',
1428-
savefig_kwarg={'facecolor': 'teal'}, tol=0.02)
1423+
savefig_kwarg={'facecolor': 'teal'})
14291424
def test_subfigure_double():
14301425
# test assigning the subfigure via subplotspec
14311426
np.random.seed(19680801)

0 commit comments

Comments
 (0)