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

Skip to content

Commit 336a8fd

Browse files
committed
backend_pgf parameterize tol and adjust to hopefully pass on travis
1 parent a8f58a2 commit 336a8fd

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ def check_for(texsystem):
4141
return latex.returncode == 0
4242

4343

44-
def compare_figure(fname, savefig_kwargs={}):
44+
def compare_figure(fname, savefig_kwargs={}, tol=0):
4545
actual = os.path.join(result_dir, fname)
4646
plt.savefig(actual, **savefig_kwargs)
4747

4848
expected = os.path.join(result_dir, "expected_%s" % fname)
4949
shutil.copyfile(os.path.join(baseline_dir, fname), expected)
50-
err = compare_images(expected, actual, tol=0)
50+
err = compare_images(expected, actual, tol=tol)
5151
if err:
5252
raise ImageComparisonFailure(err)
5353

@@ -88,7 +88,7 @@ def test_xelatex():
8888
'pgf.rcfonts': False}
8989
mpl.rcParams.update(rc_xelatex)
9090
create_figure()
91-
compare_figure('pgf_xelatex.pdf')
91+
compare_figure('pgf_xelatex.pdf', tol=0)
9292

9393

9494
# test compiling a figure to pdf with pdflatex
@@ -104,7 +104,7 @@ def test_pdflatex():
104104
'\\usepackage[T1]{fontenc}']}
105105
mpl.rcParams.update(rc_pdflatex)
106106
create_figure()
107-
compare_figure('pgf_pdflatex.pdf')
107+
compare_figure('pgf_pdflatex.pdf', tol=14)
108108

109109

110110
# test updating the rc parameters for each figure
@@ -129,11 +129,11 @@ def test_rcupdate():
129129
'pgf.preamble': ['\\usepackage[utf8x]{inputenc}',
130130
'\\usepackage[T1]{fontenc}',
131131
'\\usepackage{sfmath}']})
132-
132+
tol = (4, 13)
133133
for i, rc_set in enumerate(rc_sets):
134134
mpl.rcParams.update(rc_set)
135135
create_figure()
136-
compare_figure('pgf_rcupdate%d.pdf' % (i + 1))
136+
compare_figure('pgf_rcupdate%d.pdf' % (i + 1), tol=tol[i])
137137

138138

139139
# test backend-side clipping, since large numbers are not supported by TeX
@@ -167,7 +167,7 @@ def test_mixedmode():
167167
Y, X = np.ogrid[-1:1:40j, -1:1:40j]
168168
plt.figure()
169169
plt.pcolor(X**2 + Y**2).set_rasterized(True)
170-
compare_figure('pgf_mixedmode.pdf')
170+
compare_figure('pgf_mixedmode.pdf', tol=0)
171171

172172

173173
# test bbox_inches clipping
@@ -189,7 +189,8 @@ def test_bbox_inches():
189189
plt.tight_layout()
190190

191191
bbox = ax1.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
192-
compare_figure('pgf_bbox_inches.pdf', savefig_kwargs={'bbox_inches': bbox})
192+
compare_figure('pgf_bbox_inches.pdf', savefig_kwargs={'bbox_inches': bbox},
193+
tol=0)
193194

194195

195196
if __name__ == '__main__':

0 commit comments

Comments
 (0)