11# -*- encoding: utf-8 -*-
2-
32import os
43import shutil
4+
55import numpy as np
66import nose
77from nose .plugins .skip import SkipTest
8+
89import matplotlib as mpl
910import matplotlib .pyplot as plt
1011from matplotlib .compat import subprocess
1112from matplotlib .testing .compare import compare_images , ImageComparisonFailure
1213from matplotlib .testing .decorators import _image_directories
1314
15+
1416baseline_dir , result_dir = _image_directories (lambda : 'dummy func' )
1517
1618
@@ -59,19 +61,21 @@ def compare_figure(fname):
5961 shutil .copyfile (os .path .join (baseline_dir , fname ), expected )
6062 err = compare_images (expected , actual , tol = 14 )
6163 if err :
62- raise ImageComparisonFailure ('images not close: %s vs. %s' % (actual , expected ))
64+ raise ImageComparisonFailure ('images not close: %s vs. '
65+ '%s' % (actual , expected ))
6366
64- ###############################################################################
6567
6668def create_figure ():
6769 plt .figure ()
6870 x = np .linspace (0 , 1 , 15 )
69- plt .plot (x , x ** 2 , "b-" )
71+ plt .plot (x , x ** 2 , "b-" )
7072 plt .fill_between ([0. , .4 ], [.4 , 0. ], hatch = '//' , facecolor = "lightgray" , edgecolor = "red" )
71- plt .plot (x , 1 - x ** 2 , "g>" )
73+ plt .plot (x , 1 - x ** 2 , "g>" )
7274 plt .plot ([0.9 ], [0.5 ], "ro" , markersize = 3 )
73- plt .text (0.9 , 0.5 , u'unicode (ü, °, µ) and math ($\\ mu_i = x_i^2$)' , ha = 'right' , fontsize = 20 )
74- plt .ylabel (u'sans-serif with math $\\ frac{\\ sqrt{x}}{y^2}$..' , family = 'sans-serif' )
75+ plt .text (0.9 , 0.5 , u'unicode (ü, °, µ) and math ($\\ mu_i = x_i^2$)' ,
76+ ha = 'right' , fontsize = 20 )
77+ plt .ylabel (u'sans-serif with math $\\ frac{\\ sqrt{x}}{y^2}$..' ,
78+ family = 'sans-serif' )
7579
7680
7781# test compiling a figure to pdf with xelatex
@@ -81,7 +85,7 @@ def test_xelatex():
8185 raise SkipTest ('xelatex + pgf is required' )
8286
8387 rc_xelatex = {'font.family' : 'serif' ,
84- 'pgf.rcfonts' : False , }
88+ 'pgf.rcfonts' : False }
8589 mpl .rcParams .update (rc_xelatex )
8690 create_figure ()
8791 compare_figure ('pgf_xelatex.pdf' )
@@ -129,7 +133,7 @@ def test_rcupdate():
129133 for i , rc_set in enumerate (rc_sets ):
130134 mpl .rcParams .update (rc_set )
131135 create_figure ()
132- compare_figure ('pgf_rcupdate%d.pdf' % (i + 1 ))
136+ compare_figure ('pgf_rcupdate%d.pdf' % (i + 1 ))
133137
134138
135139# test backend-side clipping, since large numbers are not supported by TeX
@@ -160,4 +164,4 @@ def test_mixedmode():
160164
161165if __name__ == '__main__' :
162166 import nose
163- nose .runmodule (argv = ['-s' ,'--with-doctest' ], exit = False )
167+ nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
0 commit comments