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

Skip to content

Commit e7f1e51

Browse files
committed
Improve the code coverage of backend_driver.py
svn path=/trunk/matplotlib/; revision=4057
1 parent ec63259 commit e7f1e51

6 files changed

Lines changed: 79 additions & 8 deletions

File tree

examples/arrow_demo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor):
280280

281281
if __name__ == '__main__':
282282
from sys import argv
283+
d = None
283284
if len(argv) > 1:
284285
if argv[1] == 'full':
285286
d = all_on_max
@@ -293,7 +294,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor):
293294
elif argv[1] == 'sample':
294295
d = sample_data
295296
scaled = True
296-
else:
297+
if d is None:
297298
d = all_on_max
298299
scaled=False
299300
if len(argv) > 2:

examples/backend_driver.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,40 @@
2222
files = (
2323
'alignment_test.py',
2424
'arctest.py',
25+
'arrow_demo.py',
2526
'axes_demo.py',
27+
'axhspan_demo.py',
2628
'bar_stacked.py',
2729
'barchart_demo.py',
30+
'boxplot_demo.py',
31+
'broken_barh.py',
32+
'barh_demo.py',
2833
'color_demo.py',
34+
'colorbar_only.py',
2935
'contour_demo.py',
3036
'contourf_demo.py',
3137
'csd_demo.py',
3238
'custom_ticker1.py',
3339
'customize_rc.py',
3440
'date_demo1.py',
3541
'date_demo2.py',
42+
'equal_aspect_ratio.py',
43+
'errorbar_limits.py',
3644
'figimage_demo.py',
3745
'figlegend_demo.py',
3846
'figtext.py',
3947
'fill_demo.py',
4048
'finance_demo.py',
4149
'fonts_demo_kw.py',
4250
'histogram_demo.py',
51+
'hline_demo.py',
4352
'image_demo.py',
4453
'image_demo2.py',
4554
'image_masked.py',
4655
'image_origin.py',
4756
'invert_axes.py',
4857
'layer_images.py',
58+
'legend_auto.py',
4959
'legend_demo.py',
5060
'legend_demo2.py',
5161
'line_collection.py',
@@ -66,11 +76,18 @@
6676
'polar_demo.py',
6777
'polar_scatter.py',
6878
'psd_demo.py',
79+
'quadmesh_demo.py',
6980
'quiver_demo.py',
7081
'scatter_demo.py',
7182
'scatter_demo2.py',
83+
'scatter_star_poly.py',
84+
'shared_axis_demo.py',
85+
'shared_axis_across_figures.py',
7286
'simple_plot.py',
7387
'specgram_demo.py',
88+
'spy_demos.py',
89+
'stem_plot.py',
90+
'step_demo.py',
7491
'stock_demo.py',
7592
'subplot_demo.py',
7693
# 'set_and_get.py',
@@ -104,7 +121,7 @@ def run(arglist):
104121
def run(arglist):
105122
os.system(' '.join(arglist))
106123

107-
def drive(backend, python='python', switches = []):
124+
def drive(backend, python=['python'], switches = []):
108125

109126
exclude = failbackend.get(backend, [])
110127
switchstring = ' '.join(switches)
@@ -151,17 +168,20 @@ def drive(backend, python='python', switches = []):
151168
tmpfile.write('savefig("%s", dpi=150)' % outfile)
152169

153170
tmpfile.close()
154-
run([python, tmpfile_name, switchstring])
171+
run(python + [tmpfile_name, switchstring])
155172
#os.system('%s %s %s' % (python, tmpfile_name, switchstring))
156173
os.remove(tmpfile_name)
157174

158175
if __name__ == '__main__':
159176
times = {}
160177
default_backends = ['Agg', 'PS', 'SVG', 'PDF', 'Template']
161-
if sys.platform == 'win32':
162-
python = r'c:\Python24\python.exe'
178+
if '--coverage' in sys.argv:
179+
python = ['coverage.py', '-x']
180+
sys.argv.remove('--coverage')
181+
elif sys.platform == 'win32':
182+
python = [r'c:\Python24\python.exe']
163183
else:
164-
python = 'python'
184+
python = ['python']
165185
all_backends = [b.lower() for b in mplbe.all_backends]
166186
all_backends.extend(['cairo.png', 'cairo.ps', 'cairo.pdf', 'cairo.svg'])
167187
backends = []

examples/equal_aspect_ratio.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
"""
3+
Example: simple line plot.
4+
Show how to make a plot that has equal aspect ratio
5+
"""
6+
from pylab import *
7+
8+
t = arange(0.0, 1.0+0.01, 0.01)
9+
s = cos(2*2*pi*t)
10+
plot(t, s, '-', lw=2)
11+
12+
xlabel('time (s)')
13+
ylabel('voltage (mV)')
14+
title('About as simple as it gets, folks')
15+
grid(True)
16+
17+
axes().set_aspect('equal', 'datalim')
18+
19+
20+
#savefig('simple_plot.png')
21+
savefig('equal_aspect')
22+
23+
show()

examples/hline_demo.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
from matplotlib.pyplot import *
3+
from numpy import sin, exp, absolute, pi, arange
4+
from numpy.random import normal
5+
6+
def f(t):
7+
s1 = sin(2*pi*t)
8+
e1 = exp(-t)
9+
return absolute((s1*e1))+.05
10+
11+
12+
t = arange(0.0, 5.0, 0.1)
13+
s = f(t)
14+
nse = normal(0.0, 0.3, t.shape) * s
15+
16+
plot(s+nse, t, 'b^')
17+
hlines(t, [0], s)
18+
xlabel('time (s)')
19+
title('Comparison of model with data')
20+
show()
21+

examples/legend_auto.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ def fig_10():
7979

8080
if __name__ == '__main__':
8181
nfigs = 10
82-
figures = [int(f) for f in sys.argv[1:]]
82+
figures = []
83+
for f in sys.argv[1:]:
84+
try:
85+
figures.append(int(f))
86+
except ValueError:
87+
pass
8388
if len(figures) == 0:
8489
figures = range(1, nfigs+1)
8590

examples/wxcursor_demo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"""
44

55
import matplotlib
6+
matplotlib.use('WXAgg')
7+
68
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
79
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
810
from matplotlib.figure import Figure
@@ -65,6 +67,5 @@ def OnInit(self):
6567
return True
6668

6769
if __name__=='__main__':
68-
matplotlib.use('WXAgg')
6970
app = App(0)
7071
app.MainLoop()

0 commit comments

Comments
 (0)