1
1
# -*- encoding: utf-8 -*-
2
-
3
2
import os
4
3
import shutil
4
+
5
5
import numpy as np
6
6
import nose
7
7
from nose .plugins .skip import SkipTest
8
+
8
9
import matplotlib as mpl
9
10
import matplotlib .pyplot as plt
10
11
from matplotlib .compat import subprocess
11
12
from matplotlib .testing .compare import compare_images , ImageComparisonFailure
12
13
from matplotlib .testing .decorators import _image_directories
13
14
15
+
14
16
baseline_dir , result_dir = _image_directories (lambda : 'dummy func' )
15
17
16
18
@@ -59,19 +61,21 @@ def compare_figure(fname):
59
61
shutil .copyfile (os .path .join (baseline_dir , fname ), expected )
60
62
err = compare_images (expected , actual , tol = 14 )
61
63
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 ))
63
66
64
- ###############################################################################
65
67
66
68
def create_figure ():
67
69
plt .figure ()
68
70
x = np .linspace (0 , 1 , 15 )
69
- plt .plot (x , x ** 2 , "b-" )
71
+ plt .plot (x , x ** 2 , "b-" )
70
72
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>" )
72
74
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' )
75
79
76
80
77
81
# test compiling a figure to pdf with xelatex
@@ -81,7 +85,7 @@ def test_xelatex():
81
85
raise SkipTest ('xelatex + pgf is required' )
82
86
83
87
rc_xelatex = {'font.family' : 'serif' ,
84
- 'pgf.rcfonts' : False , }
88
+ 'pgf.rcfonts' : False }
85
89
mpl .rcParams .update (rc_xelatex )
86
90
create_figure ()
87
91
compare_figure ('pgf_xelatex.pdf' )
@@ -129,7 +133,7 @@ def test_rcupdate():
129
133
for i , rc_set in enumerate (rc_sets ):
130
134
mpl .rcParams .update (rc_set )
131
135
create_figure ()
132
- compare_figure ('pgf_rcupdate%d.pdf' % (i + 1 ))
136
+ compare_figure ('pgf_rcupdate%d.pdf' % (i + 1 ))
133
137
134
138
135
139
# test backend-side clipping, since large numbers are not supported by TeX
@@ -160,4 +164,4 @@ def test_mixedmode():
160
164
161
165
if __name__ == '__main__' :
162
166
import nose
163
- nose .runmodule (argv = ['-s' ,'--with-doctest' ], exit = False )
167
+ nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
0 commit comments