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

Skip to content

Commit 4a6ce52

Browse files
committed
Updating tests with a new rcparam override for pcolormesh snapping to prevent baseline image updates.
1 parent 4409dad commit 4a6ce52

13 files changed

+107
-0
lines changed

lib/matplotlib/tests/test_agg_filter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
@image_comparison(baseline_images=['agg_filter_alpha'],
88
extensions=['png', 'pdf'])
99
def test_agg_filter_alpha():
10+
# Remove this line when this test image is regenerated.
11+
plt.rcParams['pcolormesh.snap'] = False
12+
1013
ax = plt.axes()
1114
x, y = np.mgrid[0:7, 0:8]
1215
data = x**2 - y**2

lib/matplotlib/tests/test_axes.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,10 @@ def test_hexbin_pickable():
731731
@image_comparison(['hexbin_log.png'], style='mpl20')
732732
def test_hexbin_log():
733733
# Issue #1636 (and also test log scaled colorbar)
734+
735+
# Remove this line when this test image is regenerated.
736+
plt.rcParams['pcolormesh.snap'] = False
737+
734738
np.random.seed(19680801)
735739
n = 100000
736740
x = np.random.standard_normal(n)
@@ -975,6 +979,9 @@ def test_pcolorargs_5205():
975979

976980
@image_comparison(['pcolormesh'], remove_text=True)
977981
def test_pcolormesh():
982+
# Remove this line when this test image is regenerated.
983+
plt.rcParams['pcolormesh.snap'] = False
984+
978985
n = 12
979986
x = np.linspace(-1.5, 1.5, n)
980987
y = np.linspace(-1.5, 1.5, n*2)
@@ -997,6 +1004,9 @@ def test_pcolormesh():
9971004
@image_comparison(['pcolormesh_alpha'], extensions=["png", "pdf"],
9981005
remove_text=True)
9991006
def test_pcolormesh_alpha():
1007+
# Remove this line when this test image is regenerated.
1008+
plt.rcParams['pcolormesh.snap'] = False
1009+
10001010
n = 12
10011011
X, Y = np.meshgrid(
10021012
np.linspace(-1.5, 1.5, n),
@@ -1029,6 +1039,9 @@ def test_pcolormesh_alpha():
10291039
@image_comparison(['pcolormesh_datetime_axis.png'],
10301040
remove_text=False, style='mpl20')
10311041
def test_pcolormesh_datetime_axis():
1042+
# Remove this line when this test image is regenerated.
1043+
plt.rcParams['pcolormesh.snap'] = False
1044+
10321045
fig = plt.figure()
10331046
fig.subplots_adjust(hspace=0.4, top=0.98, bottom=.15)
10341047
base = datetime.datetime(2013, 1, 1)
@@ -1713,6 +1726,9 @@ def test_contour_hatching():
17131726

17141727
@image_comparison(['contour_colorbar'], style='mpl20')
17151728
def test_contour_colorbar():
1729+
# Remove this line when this test image is regenerated.
1730+
plt.rcParams['pcolormesh.snap'] = False
1731+
17161732
x, y, z = contour_dat()
17171733

17181734
fig = plt.figure()
@@ -1736,6 +1752,9 @@ def test_contour_colorbar():
17361752

17371753
@image_comparison(['hist2d', 'hist2d'], remove_text=True, style='mpl20')
17381754
def test_hist2d():
1755+
# Remove this line when this test image is regenerated.
1756+
plt.rcParams['pcolormesh.snap'] = False
1757+
17391758
np.random.seed(0)
17401759
# make it not symmetric in case we switch x and y axis
17411760
x = np.random.randn(100)*2+5
@@ -1753,6 +1772,9 @@ def test_hist2d():
17531772

17541773
@image_comparison(['hist2d_transpose'], remove_text=True, style='mpl20')
17551774
def test_hist2d_transpose():
1775+
# Remove this line when this test image is regenerated.
1776+
plt.rcParams['pcolormesh.snap'] = False
1777+
17561778
np.random.seed(0)
17571779
# make sure the output from np.histogram is transposed before
17581780
# passing to pcolorfast

lib/matplotlib/tests/test_colorbar.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ def _colorbar_extension_length(spacing):
101101
'colorbar_extensions_shape_proportional.png'])
102102
def test_colorbar_extension_shape():
103103
"""Test rectangular colorbar extensions."""
104+
# Remove this line when this test image is regenerated.
105+
plt.rcParams['pcolormesh.snap'] = False
106+
104107
# Create figures for uniform and proportionally spaced colorbars.
105108
_colorbar_extension_shape('uniform')
106109
_colorbar_extension_shape('proportional')
@@ -110,6 +113,9 @@ def test_colorbar_extension_shape():
110113
'colorbar_extensions_proportional.png'])
111114
def test_colorbar_extension_length():
112115
"""Test variable length colorbar extensions."""
116+
# Remove this line when this test image is regenerated.
117+
plt.rcParams['pcolormesh.snap'] = False
118+
113119
# Create figures for uniform and proportionally spaced colorbars.
114120
_colorbar_extension_length('uniform')
115121
_colorbar_extension_length('proportional')
@@ -123,6 +129,9 @@ def test_colorbar_extension_length():
123129
extensions=['png'], remove_text=True,
124130
savefig_kwarg={'dpi': 40})
125131
def test_colorbar_positioning():
132+
# Remove this line when this test image is regenerated.
133+
plt.rcParams['pcolormesh.snap'] = False
134+
126135
data = np.arange(1200).reshape(30, 40)
127136
levels = [0, 200, 400, 600, 800, 1000, 1200]
128137

@@ -231,6 +240,9 @@ def test_colorbarbase():
231240

232241
@image_comparison(['colorbar_closed_patch'], remove_text=True)
233242
def test_colorbar_closed_patch():
243+
# Remove this line when this test image is regenerated.
244+
plt.rcParams['pcolormesh.snap'] = False
245+
234246
fig = plt.figure(figsize=(8, 6))
235247
ax1 = fig.add_axes([0.05, 0.85, 0.9, 0.1])
236248
ax2 = fig.add_axes([0.1, 0.65, 0.75, 0.1])

lib/matplotlib/tests/test_colors.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@ def _mask_tester(norm_instance, vals):
601601

602602
@image_comparison(['levels_and_colors.png'])
603603
def test_cmap_and_norm_from_levels_and_colors():
604+
# Remove this line when this test image is regenerated.
605+
plt.rcParams['pcolormesh.snap'] = False
606+
604607
data = np.linspace(-2, 4, 49).reshape(7, 7)
605608
levels = [-1, 2, 2.5, 3]
606609
colors = ['red', 'green', 'blue', 'yellow', 'black']
@@ -618,6 +621,8 @@ def test_cmap_and_norm_from_levels_and_colors():
618621
@image_comparison(baseline_images=['boundarynorm_and_colorbar'],
619622
extensions=['png'])
620623
def test_boundarynorm_and_colorbarbase():
624+
# Remove this line when this test image is regenerated.
625+
plt.rcParams['pcolormesh.snap'] = False
621626

622627
# Make a figure and axes with dimensions as desired.
623628
fig = plt.figure()

lib/matplotlib/tests/test_constrainedlayout.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def test_constrained_layout2():
5151
@image_comparison(['constrained_layout3.png'])
5252
def test_constrained_layout3():
5353
"""Test constrained_layout for colorbars with subplots"""
54+
# Remove this line when this test image is regenerated.
55+
plt.rcParams['pcolormesh.snap'] = False
56+
5457
fig, axs = plt.subplots(2, 2, constrained_layout=True)
5558
for nn, ax in enumerate(axs.flat):
5659
pcm = example_pcolor(ax, fontsize=24)
@@ -64,6 +67,9 @@ def test_constrained_layout3():
6467
@image_comparison(['constrained_layout4'])
6568
def test_constrained_layout4():
6669
"""Test constrained_layout for a single colorbar with subplots"""
70+
# Remove this line when this test image is regenerated.
71+
plt.rcParams['pcolormesh.snap'] = False
72+
6773
fig, axs = plt.subplots(2, 2, constrained_layout=True)
6874
for ax in axs.flat:
6975
pcm = example_pcolor(ax, fontsize=24)
@@ -76,6 +82,9 @@ def test_constrained_layout5():
7682
Test constrained_layout for a single colorbar with subplots,
7783
colorbar bottom
7884
"""
85+
# Remove this line when this test image is regenerated.
86+
plt.rcParams['pcolormesh.snap'] = False
87+
7988
fig, axs = plt.subplots(2, 2, constrained_layout=True)
8089
for ax in axs.flat:
8190
pcm = example_pcolor(ax, fontsize=24)
@@ -87,6 +96,9 @@ def test_constrained_layout5():
8796
@image_comparison(['constrained_layout6.png'])
8897
def test_constrained_layout6():
8998
"""Test constrained_layout for nested gridspecs"""
99+
# Remove this line when this test image is regenerated.
100+
plt.rcParams['pcolormesh.snap'] = False
101+
90102
fig = plt.figure(constrained_layout=True)
91103
gs = fig.add_gridspec(1, 2, figure=fig)
92104
gsl = gs[0].subgridspec(2, 2)
@@ -126,6 +138,9 @@ def test_constrained_layout7():
126138
@image_comparison(['constrained_layout8.png'])
127139
def test_constrained_layout8():
128140
"""Test for gridspecs that are not completely full"""
141+
# Remove this line when this test image is regenerated.
142+
plt.rcParams['pcolormesh.snap'] = False
143+
129144
fig = plt.figure(figsize=(10, 5), constrained_layout=True)
130145
gs = gridspec.GridSpec(3, 5, figure=fig)
131146
axs = []
@@ -153,6 +168,9 @@ def test_constrained_layout8():
153168
@image_comparison(['constrained_layout9.png'])
154169
def test_constrained_layout9():
155170
"""Test for handling suptitle and for sharex and sharey"""
171+
# Remove this line when this test image is regenerated.
172+
plt.rcParams['pcolormesh.snap'] = False
173+
156174
fig, axs = plt.subplots(2, 2, constrained_layout=True,
157175
sharex=False, sharey=False)
158176
for ax in axs.flat:
@@ -176,6 +194,9 @@ def test_constrained_layout10():
176194
@image_comparison(['constrained_layout11.png'])
177195
def test_constrained_layout11():
178196
"""Test for multiple nested gridspecs"""
197+
# Remove this line when this test image is regenerated.
198+
plt.rcParams['pcolormesh.snap'] = False
199+
179200
fig = plt.figure(constrained_layout=True, figsize=(13, 3))
180201
gs0 = gridspec.GridSpec(1, 2, figure=fig)
181202
gsl = gridspec.GridSpecFromSubplotSpec(1, 2, gs0[0])
@@ -195,6 +216,9 @@ def test_constrained_layout11():
195216
@image_comparison(['constrained_layout11rat.png'])
196217
def test_constrained_layout11rat():
197218
"""Test for multiple nested gridspecs with width_ratios"""
219+
# Remove this line when this test image is regenerated.
220+
plt.rcParams['pcolormesh.snap'] = False
221+
198222
fig = plt.figure(constrained_layout=True, figsize=(10, 3))
199223
gs0 = gridspec.GridSpec(1, 2, figure=fig, width_ratios=[6, 1])
200224
gsl = gridspec.GridSpecFromSubplotSpec(1, 2, gs0[0])
@@ -236,6 +260,9 @@ def test_constrained_layout12():
236260
@image_comparison(['constrained_layout13.png'], tol=2.e-2)
237261
def test_constrained_layout13():
238262
"""Test that padding works."""
263+
# Remove this line when this test image is regenerated.
264+
plt.rcParams['pcolormesh.snap'] = False
265+
239266
fig, axs = plt.subplots(2, 2, constrained_layout=True)
240267
for ax in axs.flat:
241268
pcm = example_pcolor(ax, fontsize=12)
@@ -246,6 +273,9 @@ def test_constrained_layout13():
246273
@image_comparison(['constrained_layout14.png'])
247274
def test_constrained_layout14():
248275
"""Test that padding works."""
276+
# Remove this line when this test image is regenerated.
277+
plt.rcParams['pcolormesh.snap'] = False
278+
249279
fig, axs = plt.subplots(2, 2, constrained_layout=True)
250280
for ax in axs.flat:
251281
pcm = example_pcolor(ax, fontsize=12)
@@ -374,6 +404,8 @@ def test_colorbar_location():
374404
Test that colorbar handling is as expected for various complicated
375405
cases...
376406
"""
407+
# Remove this line when this test image is regenerated.
408+
plt.rcParams['pcolormesh.snap'] = False
377409

378410
fig, axs = plt.subplots(4, 5, constrained_layout=True)
379411
for ax in axs.flat:

lib/matplotlib/tests/test_contour.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ def test_contour_labels_size_color():
136136

137137
@image_comparison(['contour_manual_colors_and_levels.png'], remove_text=True)
138138
def test_given_colors_levels_and_extends():
139+
# Remove this line when this test image is regenerated.
140+
plt.rcParams['pcolormesh.snap'] = False
141+
139142
_, axs = plt.subplots(2, 4)
140143

141144
data = np.arange(12).reshape(3, 4)
@@ -314,6 +317,9 @@ def test_clabel_zorder(use_clabeltext, contour_zorder, clabel_zorder):
314317
@image_comparison(['contour_log_extension.png'],
315318
remove_text=True, style='mpl20')
316319
def test_contourf_log_extension():
320+
# Remove this line when this test image is regenerated.
321+
plt.rcParams['pcolormesh.snap'] = False
322+
317323
# Test that contourf with lognorm is extended correctly
318324
fig = plt.figure(figsize=(10, 5))
319325
fig.subplots_adjust(left=0.05, right=0.95)
@@ -353,6 +359,9 @@ def test_contourf_log_extension():
353359
# tolerance is because image changed minutely when tick finding on
354360
# colorbars was cleaned up...
355361
def test_contour_addlines():
362+
# Remove this line when this test image is regenerated.
363+
plt.rcParams['pcolormesh.snap'] = False
364+
356365
fig, ax = plt.subplots()
357366
np.random.seed(19680812)
358367
X = np.random.rand(10, 10)*10000
@@ -367,6 +376,9 @@ def test_contour_addlines():
367376
@image_comparison(baseline_images=['contour_uneven'],
368377
extensions=['png'], remove_text=True, style='mpl20')
369378
def test_contour_uneven():
379+
# Remove this line when this test image is regenerated.
380+
plt.rcParams['pcolormesh.snap'] = False
381+
370382
z = np.arange(24).reshape(4, 6)
371383
fig, axs = plt.subplots(1, 2)
372384
ax = axs[0]

lib/matplotlib/tests/test_image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,9 @@ def test_image_preserve_size2():
796796

797797
@image_comparison(['mask_image_over_under.png'], remove_text=True)
798798
def test_mask_image_over_under():
799+
# Remove this line when this test image is regenerated.
800+
plt.rcParams['pcolormesh.snap'] = False
801+
799802
delta = 0.025
800803
x = y = np.arange(-3.0, 3.0, delta)
801804
X, Y = np.meshgrid(x, y)

lib/matplotlib/tests/test_pickle.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def test_simple():
4343
@image_comparison(['multi_pickle.png'], remove_text=True, style='mpl20',
4444
tol={'aarch64': 0.082}.get(platform.machine(), 0.0))
4545
def test_complete():
46+
# Remove this line when this test image is regenerated.
47+
plt.rcParams['pcolormesh.snap'] = False
48+
4649
fig = plt.figure('Figure with a label?', figsize=(10, 6))
4750

4851
plt.suptitle('Can you fit any more in a figure?')

lib/matplotlib/tests/test_streamplot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def test_startpoints():
4242
@image_comparison(['streamplot_colormap'],
4343
tol=.04, remove_text=True, style='mpl20')
4444
def test_colormap():
45+
# Remove this line when this test image is regenerated.
46+
plt.rcParams['pcolormesh.snap'] = False
47+
4548
X, Y, U, V = velocity_field()
4649
plt.streamplot(X, Y, U, V, color=U, density=0.6, linewidth=2,
4750
cmap=plt.cm.autumn)

lib/matplotlib/tests/test_transforms.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ def test_pre_transform_plotting():
7373
# a catch-all for as many as possible plot layouts which handle
7474
# pre-transforming the data NOTE: The axis range is important in this
7575
# plot. It should be x10 what the data suggests it should be
76+
77+
# Remove this line when this test image is regenerated.
78+
plt.rcParams['pcolormesh.snap'] = False
79+
7680
ax = plt.axes()
7781
times10 = mtransforms.Affine2D().scale(10)
7882

lib/mpl_toolkits/tests/test_axes_grid.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
@image_comparison(['imagegrid_cbar_mode.png'],
1717
remove_text=True, style='mpl20', tol=0.3)
1818
def test_imagegrid_cbar_mode_edge(legacy_colorbar):
19+
# Remove this line when this test image is regenerated.
20+
plt.rcParams['pcolormesh.snap'] = False
21+
1922
mpl.rcParams["mpl_toolkits.legacy_colorbar"] = legacy_colorbar
2023

2124
X, Y = np.meshgrid(np.linspace(0, 6, 30), np.linspace(0, 6, 30))

lib/mpl_toolkits/tests/test_axisartist_axislines.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def test_Axes():
6262
@image_comparison(['ParasiteAxesAuxTrans_meshplot.png'],
6363
remove_text=True, style='default', tol=0.075)
6464
def test_ParasiteAxesAuxTrans():
65+
# Remove this line when this test image is regenerated.
66+
plt.rcParams['pcolormesh.snap'] = False
6567

6668
data = np.ones((6, 6))
6769
data[2, 2] = 2

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ def test_plot_3d_from_2d():
299299

300300
@mpl3d_image_comparison(['surface3d.png'])
301301
def test_surface3d():
302+
# Remove this line when this test image is regenerated.
303+
plt.rcParams['pcolormesh.snap'] = False
304+
302305
fig = plt.figure()
303306
ax = fig.gca(projection='3d')
304307
X = np.arange(-5, 5, 0.25)

0 commit comments

Comments
 (0)