@@ -31,7 +31,7 @@ def check_for(texsystem):
3131 \\ @@end
3232 """
3333 try :
34- latex = subprocess .Popen (["xelatex" , "-halt-on-error" ],
34+ latex = subprocess .Popen ([texsystem , "-halt-on-error" ],
3535 stdin = subprocess .PIPE ,
3636 stdout = subprocess .PIPE )
3737 stdout , stderr = latex .communicate (header .encode ("utf8" ))
@@ -41,16 +41,15 @@ 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 = 14 )
50+ err = compare_images (expected , actual , tol = tol )
5151 if err :
52- raise ImageComparisonFailure ('images not close: %s vs. '
53- '%s' % (actual , expected ))
52+ raise ImageComparisonFailure (err )
5453
5554
5655def create_figure ():
@@ -89,7 +88,7 @@ def test_xelatex():
8988 'pgf.rcfonts' : False }
9089 mpl .rcParams .update (rc_xelatex )
9190 create_figure ()
92- compare_figure ('pgf_xelatex.pdf' )
91+ compare_figure ('pgf_xelatex.pdf' , tol = 0 )
9392
9493
9594# test compiling a figure to pdf with pdflatex
@@ -105,7 +104,7 @@ def test_pdflatex():
105104 '\\ usepackage[T1]{fontenc}' ]}
106105 mpl .rcParams .update (rc_pdflatex )
107106 create_figure ()
108- compare_figure ('pgf_pdflatex.pdf' )
107+ compare_figure ('pgf_pdflatex.pdf' , tol = 0 )
109108
110109
111110# test updating the rc parameters for each figure
@@ -130,11 +129,11 @@ def test_rcupdate():
130129 'pgf.preamble' : ['\\ usepackage[utf8x]{inputenc}' ,
131130 '\\ usepackage[T1]{fontenc}' ,
132131 '\\ usepackage{sfmath}' ]})
133-
132+ tol = ( 4 , 0 )
134133 for i , rc_set in enumerate (rc_sets ):
135134 mpl .rcParams .update (rc_set )
136135 create_figure ()
137- compare_figure ('pgf_rcupdate%d.pdf' % (i + 1 ))
136+ compare_figure ('pgf_rcupdate%d.pdf' % (i + 1 ), tol = tol [ i ] )
138137
139138
140139# test backend-side clipping, since large numbers are not supported by TeX
@@ -168,7 +167,7 @@ def test_mixedmode():
168167 Y , X = np .ogrid [- 1 :1 :40j , - 1 :1 :40j ]
169168 plt .figure ()
170169 plt .pcolor (X ** 2 + Y ** 2 ).set_rasterized (True )
171- compare_figure ('pgf_mixedmode.pdf' )
170+ compare_figure ('pgf_mixedmode.pdf' , tol = 0 )
172171
173172
174173# test bbox_inches clipping
@@ -190,7 +189,8 @@ def test_bbox_inches():
190189 plt .tight_layout ()
191190
192191 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 )
194194
195195
196196if __name__ == '__main__' :
0 commit comments