Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f57e7c4

Browse filesBrowse files
committed
TST: Set explicit styles for image tests
1 parent 00ec4ec commit f57e7c4
Copy full SHA for f57e7c4

16 files changed

+197
-69
lines changed

‎lib/matplotlib/tests/test_agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_agg.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def test_long_path():
8484
fig.savefig(buff, format='png')
8585

8686

87-
@image_comparison(['agg_filter.png'], remove_text=True)
87+
# # Update style when regenerating the test image
88+
@image_comparison(['agg_filter.png'], remove_text=True,
89+
style=("classic", "_classic_test_patch"))
8890
def test_agg_filter():
8991
def smooth1d(x, window_len):
9092
# copied from https://scipy-cookbook.readthedocs.io/

‎lib/matplotlib/tests/test_backend_pdf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_pdf.py
+17-6Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
from matplotlib.testing._markers import needs_usetex
2323

2424

25-
@image_comparison(['pdf_use14corefonts.pdf'])
25+
# Update style when regenerating the test image
26+
@image_comparison(['pdf_use14corefonts.pdf'],
27+
style=("classic", "_classic_test_patch"))
2628
def test_use14corefonts():
2729
rcParams['pdf.use14corefonts'] = True
2830
rcParams['font.family'] = 'sans-serif'
@@ -306,7 +308,9 @@ def test_pdfpages_fspath():
306308
pdf.savefig(plt.figure())
307309

308310

309-
@image_comparison(['hatching_legend.pdf'])
311+
# Update style when regenerating the test image
312+
@image_comparison(['hatching_legend.pdf'],
313+
style=("classic", "_classic_test_patch"))
310314
def test_hatching_legend():
311315
"""Test for correct hatching on patches in legend"""
312316
fig = plt.figure(figsize=(1, 2))
@@ -317,7 +321,9 @@ def test_hatching_legend():
317321
fig.legend([a, b, a, b], ["", "", "", ""])
318322

319323

320-
@image_comparison(['grayscale_alpha.pdf'])
324+
# Update style when regenerating the test image
325+
@image_comparison(['grayscale_alpha.pdf'],
326+
style=("classic", "_classic_test_patch"))
321327
def test_grayscale_alpha():
322328
"""Masking images with NaN did not work for grayscale images"""
323329
x, y = np.ogrid[-2:2:.1, -2:2:.1]
@@ -354,7 +360,8 @@ def test_empty_rasterized():
354360
fig.savefig(io.BytesIO(), format="pdf")
355361

356362

357-
@image_comparison(['kerning.pdf'])
363+
# Update style when regenerating the test image
364+
@image_comparison(['kerning.pdf'], style=("classic", "_classic_test_patch"))
358365
def test_kerning():
359366
fig = plt.figure()
360367
s = "AVAVAVAVAVAVAVAV€AAVV"
@@ -387,7 +394,9 @@ def test_glyphs_subset():
387394
assert subfont.get_num_glyphs() == nosubfont.get_num_glyphs()
388395

389396

390-
@image_comparison(["multi_font_type3.pdf"], tol=4.6)
397+
# Update style when regenerating the test image
398+
@image_comparison(["multi_font_type3.pdf"], tol=4.6,
399+
style=("classic", "_classic_test_patch"))
391400
def test_multi_font_type3():
392401
fp = fm.FontProperties(family=["WenQuanYi Zen Hei"])
393402
if Path(fm.findfont(fp)).name != "wqy-zenhei.ttc":
@@ -400,7 +409,9 @@ def test_multi_font_type3():
400409
fig.text(0.15, 0.475, "There are 几个汉字 in between!")
401410

402411

403-
@image_comparison(["multi_font_type42.pdf"], tol=2.2)
412+
# Update style when regenerating the test image
413+
@image_comparison(["multi_font_type42.pdf"], tol=2.2,
414+
style=("classic", "_classic_test_patch"))
404415
def test_multi_font_type42():
405416
fp = fm.FontProperties(family=["WenQuanYi Zen Hei"])
406417
if Path(fm.findfont(fp)).name != "wqy-zenhei.ttc":

‎lib/matplotlib/tests/test_backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_svg.py
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ def test_visibility():
3636
parser.Parse(buf) # this will raise ExpatError if the svg is invalid
3737

3838

39-
@image_comparison(['fill_black_with_alpha.svg'], remove_text=True)
39+
@image_comparison(['fill_black_with_alpha.svg'], remove_text=True,
40+
style=("classic", "_classic_test_patch"))
4041
def test_fill_black_with_alpha():
4142
fig, ax = plt.subplots()
4243
ax.scatter(x=[0, 0.1, 1], y=[0, 0, 0], c='k', alpha=0.1, s=10000)
4344

4445

45-
@image_comparison(['noscale'], remove_text=True)
46+
# Update style when regenerating the test image
47+
@image_comparison(['noscale'], remove_text=True,
48+
style=("classic", "_classic_test_patch"))
4649
def test_noscale():
4750
X, Y = np.meshgrid(np.arange(-5, 5, 1), np.arange(-5, 5, 1))
4851
Z = np.sin(Y ** 2)
@@ -65,7 +68,9 @@ def test_text_urls():
6568
assert expected in buf
6669

6770

68-
@image_comparison(['bold_font_output.svg'])
71+
# Update style when regenerating the test image
72+
@image_comparison(['bold_font_output.svg'],
73+
style=("classic", "_classic_test_patch"))
6974
def test_bold_font_output():
7075
fig, ax = plt.subplots()
7176
ax.plot(np.arange(10), np.arange(10))
@@ -74,7 +79,9 @@ def test_bold_font_output():
7479
ax.set_title('bold-title', fontweight='bold')
7580

7681

77-
@image_comparison(['bold_font_output_with_none_fonttype.svg'])
82+
# Update style when regenerating the test image
83+
@image_comparison(['bold_font_output_with_none_fonttype.svg'],
84+
style=("classic", "_classic_test_patch"))
7885
def test_bold_font_output_with_none_fonttype():
7986
plt.rcParams['svg.fonttype'] = 'none'
8087
fig, ax = plt.subplots()

‎lib/matplotlib/tests/test_colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colorbar.py
+17-6Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ def _colorbar_extension_length(spacing):
102102
return fig
103103

104104

105+
# Update style when regenerating the test image
105106
@image_comparison(['colorbar_extensions_shape_uniform.png',
106-
'colorbar_extensions_shape_proportional.png'])
107+
'colorbar_extensions_shape_proportional.png'],
108+
style=("classic", "_classic_test_patch"))
107109
def test_colorbar_extension_shape():
108110
"""Test rectangular colorbar extensions."""
109111
# Remove this line when this test image is regenerated.
@@ -114,9 +116,10 @@ def test_colorbar_extension_shape():
114116
_colorbar_extension_shape('proportional')
115117

116118

119+
# Update style when regenerating the test image
117120
@image_comparison(['colorbar_extensions_uniform.png',
118121
'colorbar_extensions_proportional.png'],
119-
tol=1.0)
122+
tol=1.0, style=("classic", "_classic_test_patch"))
120123
def test_colorbar_extension_length():
121124
"""Test variable length colorbar extensions."""
122125
# Remove this line when this test image is regenerated.
@@ -152,13 +155,15 @@ def test_colorbar_extension_inverted_axis(orientation, extend, expected):
152155

153156

154157
@pytest.mark.parametrize('use_gridspec', [True, False])
158+
# Update style when regenerating the test image
155159
@image_comparison(['cbar_with_orientation',
156160
'cbar_locationing',
157161
'double_cbar',
158162
'cbar_sharing',
159163
],
160164
extensions=['png'], remove_text=True,
161-
savefig_kwarg={'dpi': 40})
165+
savefig_kwarg={'dpi': 40},
166+
style=("classic", "_classic_test_patch"))
162167
def test_colorbar_positioning(use_gridspec):
163168
# Remove this line when this test image is regenerated.
164169
plt.rcParams['pcolormesh.snap'] = False
@@ -233,7 +238,9 @@ def test_colorbar_single_ax_panchor_east(constrained):
233238
assert ax.get_anchor() == 'E'
234239

235240

236-
@image_comparison(['contour_colorbar.png'], remove_text=True)
241+
# Update style when regenerating the test image
242+
@image_comparison(['contour_colorbar.png'], remove_text=True,
243+
style=("classic", "_classic_test_patch"))
237244
def test_contour_colorbar():
238245
fig, ax = plt.subplots(figsize=(4, 2))
239246
data = np.arange(1200).reshape(30, 40) - 500
@@ -244,8 +251,10 @@ def test_contour_colorbar():
244251
fig.colorbar(CS, orientation='vertical')
245252

246253

254+
# Update style when regenerating the test image
247255
@image_comparison(['cbar_with_subplots_adjust.png'], remove_text=True,
248-
savefig_kwarg={'dpi': 40})
256+
savefig_kwarg={'dpi': 40},
257+
style=("classic", "_classic_test_patch"))
249258
def test_gridspec_make_colorbar():
250259
plt.figure()
251260
data = np.arange(1200).reshape(30, 40)
@@ -262,8 +271,10 @@ def test_gridspec_make_colorbar():
262271
plt.subplots_adjust(top=0.95, right=0.95, bottom=0.2, hspace=0.25)
263272

264273

274+
# Update style when regenerating the test image
265275
@image_comparison(['colorbar_single_scatter.png'], remove_text=True,
266-
savefig_kwarg={'dpi': 40})
276+
savefig_kwarg={'dpi': 40},
277+
style=("classic", "_classic_test_patch"))
267278
def test_colorbar_single_scatter():
268279
# Issue #2642: if a path collection has only one entry,
269280
# the norm scaling within the colorbar must ensure a

‎lib/matplotlib/tests/test_contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_contour.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def test_contour_manual_labels():
124124
plt.clabel(cs, manual=pts, fontsize='small', colors=('r', 'g'))
125125

126126

127-
@image_comparison(['contour_manual_colors_and_levels.png'], remove_text=True)
127+
# Update style when regenerating the test image
128+
@image_comparison(['contour_manual_colors_and_levels.png'], remove_text=True,
129+
style=("classic", "_classic_test_patch"))
128130
def test_given_colors_levels_and_extends():
129131
# Remove this line when this test image is regenerated.
130132
plt.rcParams['pcolormesh.snap'] = False
@@ -211,9 +213,10 @@ def test_labels():
211213
CS.add_label_near(x, y, inline=True, transform=False)
212214

213215

216+
# Update style when regenerating the test image
214217
@image_comparison(['contour_corner_mask_False.png',
215218
'contour_corner_mask_True.png'],
216-
remove_text=True)
219+
remove_text=True, style=("classic", "_classic_test_patch"))
217220
def test_corner_mask():
218221
n = 60
219222
mask_level = 0.95

‎lib/matplotlib/tests/test_figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_figure.py
+10-4Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
import matplotlib.dates as mdates
2626

2727

28+
# Update style when regenerating the test image
2829
@image_comparison(['figure_align_labels'], extensions=['png', 'svg'],
29-
tol=0 if platform.machine() == 'x86_64' else 0.01)
30+
tol=0 if platform.machine() == 'x86_64' else 0.01,
31+
style=("classic", "_classic_test_patch"))
3032
def test_align_labels():
3133
fig = plt.figure(layout='tight')
3234
gs = gridspec.GridSpec(3, 3)
@@ -160,7 +162,8 @@ def test_clf_keyword():
160162
assert [t.get_text() for t in fig2.texts] == []
161163

162164

163-
@image_comparison(['figure_today'])
165+
# Update style when regenerating the test image
166+
@image_comparison(['figure_today'], style=("classic", "_classic_test_patch"))
164167
def test_figure():
165168
# named figure support
166169
fig = plt.figure('today')
@@ -175,7 +178,8 @@ def test_figure():
175178
plt.close('tomorrow')
176179

177180

178-
@image_comparison(['figure_legend'])
181+
# Update style when regenerating the test image
182+
@image_comparison(['figure_legend'], style=("classic", "_classic_test_patch"))
179183
def test_figure_legend():
180184
fig, axs = plt.subplots(2)
181185
axs[0].plot([0, 1], [1, 0], label='x', color='g')
@@ -272,7 +276,9 @@ def test_add_subplot_invalid():
272276
fig.add_subplot(ax)
273277

274278

275-
@image_comparison(['figure_suptitle'])
279+
# Update style when regenerating the test image
280+
@image_comparison(['figure_suptitle'],
281+
style=("classic", "_classic_test_patch"))
276282
def test_suptitle():
277283
fig, _ = plt.subplots()
278284
fig.suptitle('hello', color='r')

‎lib/matplotlib/tests/test_image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_image.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def test_image_interps():
4343
ax3.set_ylabel('bicubic')
4444

4545

46-
@image_comparison(['interp_alpha.png'], remove_text=True)
46+
# Update style when regenerating the test image
47+
@image_comparison(['interp_alpha.png'], remove_text=True,
48+
style=("classic", "_classic_test_patch"))
4749
def test_alpha_interp():
4850
"""Test the interpolation of the alpha channel on RGBA images"""
4951
fig, (axl, axr) = plt.subplots(1, 2)
@@ -56,8 +58,10 @@ def test_alpha_interp():
5658
axr.imshow(img, interpolation="bilinear")
5759

5860

61+
# Update style when regenerating the test image
5962
@image_comparison(['interp_nearest_vs_none'],
60-
extensions=['pdf', 'svg'], remove_text=True)
63+
extensions=['pdf', 'svg'], remove_text=True,
64+
style=("classic", "_classic_test_patch"))
6165
def test_interp_nearest_vs_none():
6266
"""Test the effect of "nearest" and "none" interpolation"""
6367
# Setting dpi to something really small makes the difference very
@@ -74,8 +78,10 @@ def test_interp_nearest_vs_none():
7478
ax2.set_title('interpolation nearest')
7579

7680

81+
# Update style when regenerating the test image
7782
@pytest.mark.parametrize('suppressComposite', [False, True])
78-
@image_comparison(['figimage'], extensions=['png', 'pdf'])
83+
@image_comparison(['figimage'], extensions=['png', 'pdf'],
84+
style=("classic", "_classic_test_patch"))
7985
def test_figimage(suppressComposite):
8086
fig = plt.figure(figsize=(2, 2), dpi=100)
8187
fig.suppressComposite = suppressComposite

‎lib/matplotlib/tests/test_lines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_lines.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def test_set_line_coll_dash():
8383
ax.contour(np.random.randn(20, 30), linestyles=[(0, (3, 3))])
8484

8585

86-
@image_comparison(['line_dashes'], remove_text=True)
86+
# Update style when regenerating the test image
87+
@image_comparison(['line_dashes'], remove_text=True,
88+
style=("classic", "_classic_test_patch"))
8789
def test_line_dashes():
8890
fig, ax = plt.subplots()
8991

@@ -122,7 +124,9 @@ def test_valid_linestyles():
122124
line.set_linestyle('aardvark')
123125

124126

125-
@image_comparison(['drawstyle_variants.png'], remove_text=True)
127+
# Update style when regenerating the test image
128+
@image_comparison(['drawstyle_variants.png'], remove_text=True,
129+
style=("classic", "_classic_test_patch"))
126130
def test_drawstyle_variants():
127131
fig, axs = plt.subplots(6)
128132
dss = ["default", "steps-mid", "steps-pre", "steps-post", "steps", None]
@@ -172,7 +176,9 @@ def test_set_line_coll_dash_image():
172176
ax.contour(np.random.randn(20, 30), linestyles=[(0, (3, 3))])
173177

174178

175-
@image_comparison(['marker_fill_styles.png'], remove_text=True)
179+
# Update style when regenerating the test image
180+
@image_comparison(['marker_fill_styles.png'], remove_text=True,
181+
style=("classic", "_classic_test_patch"))
176182
def test_marker_fill_styles():
177183
colors = itertools.cycle([[0, 0, 1], 'g', '#ff0000', 'c', 'm', 'y',
178184
np.array([0, 0, 0])])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.