@@ -31,7 +31,7 @@ def check_for(texsystem):
31
31
\\ @@end
32
32
"""
33
33
try :
34
- latex = subprocess .Popen (["xelatex" , "-halt-on-error" ],
34
+ latex = subprocess .Popen ([texsystem , "-halt-on-error" ],
35
35
stdin = subprocess .PIPE ,
36
36
stdout = subprocess .PIPE )
37
37
stdout , stderr = latex .communicate (header .encode ("utf8" ))
@@ -41,16 +41,15 @@ def check_for(texsystem):
41
41
return latex .returncode == 0
42
42
43
43
44
- def compare_figure (fname , savefig_kwargs = {}):
44
+ def compare_figure (fname , savefig_kwargs = {}, tol = 0 ):
45
45
actual = os .path .join (result_dir , fname )
46
46
plt .savefig (actual , ** savefig_kwargs )
47
47
48
48
expected = os .path .join (result_dir , "expected_%s" % fname )
49
49
shutil .copyfile (os .path .join (baseline_dir , fname ), expected )
50
- err = compare_images (expected , actual , tol = 14 )
50
+ err = compare_images (expected , actual , tol = tol )
51
51
if err :
52
- raise ImageComparisonFailure ('images not close: %s vs. '
53
- '%s' % (actual , expected ))
52
+ raise ImageComparisonFailure (err )
54
53
55
54
56
55
def create_figure ():
@@ -89,7 +88,7 @@ def test_xelatex():
89
88
'pgf.rcfonts' : False }
90
89
mpl .rcParams .update (rc_xelatex )
91
90
create_figure ()
92
- compare_figure ('pgf_xelatex.pdf' )
91
+ compare_figure ('pgf_xelatex.pdf' , tol = 0 )
93
92
94
93
95
94
# test compiling a figure to pdf with pdflatex
@@ -105,7 +104,7 @@ def test_pdflatex():
105
104
'\\ usepackage[T1]{fontenc}' ]}
106
105
mpl .rcParams .update (rc_pdflatex )
107
106
create_figure ()
108
- compare_figure ('pgf_pdflatex.pdf' )
107
+ compare_figure ('pgf_pdflatex.pdf' , tol = 0 )
109
108
110
109
111
110
# test updating the rc parameters for each figure
@@ -130,11 +129,11 @@ def test_rcupdate():
130
129
'pgf.preamble' : ['\\ usepackage[utf8x]{inputenc}' ,
131
130
'\\ usepackage[T1]{fontenc}' ,
132
131
'\\ usepackage{sfmath}' ]})
133
-
132
+ tol = ( 4 , 0 )
134
133
for i , rc_set in enumerate (rc_sets ):
135
134
mpl .rcParams .update (rc_set )
136
135
create_figure ()
137
- compare_figure ('pgf_rcupdate%d.pdf' % (i + 1 ))
136
+ compare_figure ('pgf_rcupdate%d.pdf' % (i + 1 ), tol = tol [ i ] )
138
137
139
138
140
139
# test backend-side clipping, since large numbers are not supported by TeX
@@ -168,7 +167,7 @@ def test_mixedmode():
168
167
Y , X = np .ogrid [- 1 :1 :40j , - 1 :1 :40j ]
169
168
plt .figure ()
170
169
plt .pcolor (X ** 2 + Y ** 2 ).set_rasterized (True )
171
- compare_figure ('pgf_mixedmode.pdf' )
170
+ compare_figure ('pgf_mixedmode.pdf' , tol = 0 )
172
171
173
172
174
173
# test bbox_inches clipping
@@ -190,7 +189,8 @@ def test_bbox_inches():
190
189
plt .tight_layout ()
191
190
192
191
bbox = ax1 .get_window_extent ().transformed (fig .dpi_scale_trans .inverted ())
193
- 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 )
194
194
195
195
196
196
if __name__ == '__main__' :
0 commit comments