Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0df13d7

Browse files
committed
Increased coverage of backend_driver.py to include almost everything
in axes.py. Lots of little bug fixes.svn path=/branches/transforms/; revision=4004
1 parente573c25 commit0df13d7

22 files changed

+239
-338
lines changed

‎PASSED_DEMOS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ dynamic_demo.pyO
6060
dynamic_demo_wx.py[REQUIRES NON-AGG WX RENDERER, WHICH IS NOT YET IMPLEMENTED]
6161
dynamic_image_gtkagg.py O
6262
dynamic_image_wxagg2.py O
63-
dynamic_image_wxagg.py
63+
dynamic_image_wxagg.py[REQUIRES NON-AGG WX RENDERER, WHICH IS NOT YET IMPLEMENTED]
6464
ellipse_demo.pyO
6565
ellipse_rotated.pyO
6666
embedding_in_gtk2.py[REQUIRES NON-AGG GDK RENDERER, WHICH IS NOT YET IMPLEMENTED]

‎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
fromsysimportargv
283+
d=None
283284
iflen(argv)>1:
284285
ifargv[1]=='full':
285286
d=all_on_max
@@ -293,7 +294,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor):
293294
elifargv[1]=='sample':
294295
d=sample_data
295296
scaled=True
296-
else:
297+
ifdisNone:
297298
d=all_on_max
298299
scaled=False
299300
iflen(argv)>2:

‎examples/backend_driver.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,33 @@
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',
@@ -66,11 +75,18 @@
6675
'polar_demo.py',
6776
'polar_scatter.py',
6877
'psd_demo.py',
78+
'quadmesh_demo.py',
6979
'quiver_demo.py',
7080
'scatter_demo.py',
7181
'scatter_demo2.py',
82+
'scatter_star_poly.py',
83+
'shared_axis_demo.py',
84+
'shared_axis_across_figures.py',
7285
'simple_plot.py',
7386
'specgram_demo.py',
87+
'spy_demos.py',
88+
'stem_plot.py',
89+
'step_demo.py',
7490
'stock_demo.py',
7591
'subplot_demo.py',
7692
# 'set_and_get.py',
@@ -104,7 +120,7 @@ def run(arglist):
104120
defrun(arglist):
105121
os.system(' '.join(arglist))
106122

107-
defdrive(backend,python='python',switches= []):
123+
defdrive(backend,python=['python'],switches= []):
108124

109125
exclude=failbackend.get(backend, [])
110126
switchstring=' '.join(switches)
@@ -151,17 +167,20 @@ def drive(backend, python='python', switches = []):
151167
tmpfile.write('savefig("%s", dpi=150)'%outfile)
152168

153169
tmpfile.close()
154-
run([python,tmpfile_name,switchstring])
170+
run(python+ [tmpfile_name,switchstring])
155171
#os.system('%s %s %s' % (python, tmpfile_name, switchstring))
156172
os.remove(tmpfile_name)
157173

158174
if__name__=='__main__':
159175
times= {}
160176
default_backends= ['Agg','PS','SVG','PDF','Template']
161-
ifsys.platform=='win32':
162-
python=r'c:\Python24\python.exe'
177+
if'--coverage'insys.argv:
178+
python= ['coverage.py','-x']
179+
sys.argv.remove('--coverage')
180+
elifsys.platform=='win32':
181+
python= [r'c:\Python24\python.exe']
163182
else:
164-
python='python'
183+
python=['python']
165184
all_backends= [b.lower()forbinmplbe.all_backends]
166185
all_backends.extend(['cairo.png','cairo.ps','cairo.pdf','cairo.svg'])
167186
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+
frompylabimport*
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+
frommatplotlib.pyplotimport*
3+
fromnumpyimportsin,exp,absolute,pi,arange
4+
fromnumpy.randomimportnormal
5+
6+
deff(t):
7+
s1=sin(2*pi*t)
8+
e1=exp(-t)
9+
returnabsolute((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+

‎lib/matplotlib/artist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__importdivision
2-
importsys,re
2+
importsys,re,warnings
33
fromcbookimportiterable,flatten
44
fromtransformsimportAffine2D,Bbox,IdentityTransform,TransformedBbox, \
55
TransformedPath
@@ -174,7 +174,7 @@ def contains(self,mouseevent):
174174
"""
175175
ifcallable(self._contains):returnself._contains(self,mouseevent)
176176
#raise NotImplementedError,str(self.__class__)+" needs 'contains' method"
177-
printstr(self.__class__)+" needs 'contains' method"
177+
warnings.warn("'%s' needs 'contains' method"%self.__class__.__name__)
178178
returnFalse,{}
179179

180180
defset_contains(self,picker):

‎lib/matplotlib/axes.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -821,16 +821,15 @@ def apply_aspect(self):
821821
Use self._aspect and self._adjustable to modify the
822822
axes box or the view limits.
823823
'''
824-
#MGDTODO: Numpify
825-
826-
ifself._aspect=='auto':
824+
aspect=self.get_aspect()
825+
ifaspect=='auto':
827826
self.set_position(self._originalPosition ,'active')
828827
return
829828

830-
ifself._aspect=='equal':
829+
ifaspect=='equal':
831830
A=1
832831
else:
833-
A=self._aspect
832+
A=aspect
834833

835834
#Ensure at drawing time that any Axes involved in axis-sharing
836835
# does not have its position changed.
@@ -843,7 +842,7 @@ def apply_aspect(self):
843842
box_aspect=A*self.get_data_ratio()
844843
pb=self._originalPosition.frozen()
845844
pb1=pb.shrunk_to_aspect(box_aspect,pb,fig_aspect)
846-
self.set_position(pb1.anchored(self._anchor,pb),'active')
845+
self.set_position(pb1.anchored(self.get_anchor(),pb),'active')
847846
return
848847

849848
xmin,xmax=self.get_xbound()
@@ -1040,7 +1039,7 @@ def add_artist(self, a):
10401039
a.set_clip_path(self.axesPatch)
10411040
a._remove_method=lambdah:self.artists.remove(h)
10421041

1043-
defadd_collection(self,collection,autolim=False):
1042+
defadd_collection(self,collection,autolim=True):
10441043
'add a Collection instance to Axes'
10451044
label=collection.get_label()
10461045
ifnotlabel:
@@ -1127,8 +1126,8 @@ def update_datalim_numerix(self, x, y):
11271126
self.ignore_existing_data_limits=False
11281127

11291128
defupdate_datalim_bounds(self,bounds):
1130-
# MGDTODO: Document me
1131-
self.dataLim.bounds=Bbox.union([self.dataLim,bounds]).bounds
1129+
'Update the datalim to include the given Bbox'
1130+
self.dataLim.set(Bbox.union([self.dataLim,bounds]))
11321131

11331132
def_get_verts_in_data_coords(self,trans,xys):
11341133
iftrans==self.transData:
@@ -2017,8 +2016,9 @@ def __pick(self, x, y, trans=None, among=None):
20172016
Note this algorithm calculates distance to the vertices of the
20182017
polygon, so if you want to pick a patch, click on the edge!
20192018
"""
2019+
# MGDTODO: Needs updating
20202020
iftransisnotNone:
2021-
xywin=trans.xy_tup((x,y))
2021+
xywin=trans.transform_point((x,y))
20222022
else:
20232023
xywin=x,y
20242024

@@ -2036,12 +2036,12 @@ def dist_x_y(p1, x, y):
20362036
defdist(a):
20372037
ifisinstance(a,Text):
20382038
bbox=a.get_window_extent()
2039-
l,b,w,h=bbox.get_bounds()
2039+
l,b,w,h=bbox.bounds
20402040
verts= (l,b), (l,b+h), (l+w,b+h), (l+w,b)
20412041
xt,yt=zip(*verts)
20422042
elifisinstance(a,Patch):
2043-
verts=a.get_verts()
2044-
tverts=a.get_transform().seq_xy_tups(verts)
2043+
path=a.get_path()
2044+
tverts=a.get_transform().transform_path(path)
20452045
xt,yt=zip(*tverts)
20462046
elifisinstance(a,mlines.Line2D):
20472047
xdata=a.get_xdata(orig=False)
@@ -3278,19 +3278,19 @@ def make_iterable(x):
32783278
self.hold(holdstate)# restore previous hold state
32793279

32803280
ifadjust_xlim:
3281-
xmin,xmax=self.dataLim.intervalx().get_bounds()
3281+
xmin,xmax=self.dataLim.intervalx
32823282
xmin=npy.amin(width)
32833283
ifxerrisnotNone:
32843284
xmin=xmin-npy.amax(xerr)
32853285
xmin=max(xmin*0.9,1e-100)
3286-
self.dataLim.intervalx().set_bounds(xmin,xmax)
3286+
self.dataLim.intervalx=(xmin,xmax)
32873287
ifadjust_ylim:
3288-
ymin,ymax=self.dataLim.intervaly().get_bounds()
3288+
ymin,ymax=self.dataLim.intervaly
32893289
ymin=npy.amin(height)
32903290
ifyerrisnotNone:
32913291
ymin=ymin-npy.amax(yerr)
32923292
ymin=max(ymin*0.9,1e-100)
3293-
self.dataLim.intervaly().set_bounds(ymin,ymax)
3293+
self.dataLim.intervaly=(ymin,ymax)
32943294
self.autoscale_view()
32953295
returnpatches
32963296
bar.__doc__=cbook.dedent(bar.__doc__)%martist.kwdocd
@@ -4197,7 +4197,7 @@ def quiverkey(self, *args, **kw):
41974197

41984198
defquiver(self,*args,**kw):
41994199
q=mquiver.Quiver(self,*args,**kw)
4200-
self.add_collection(q)
4200+
self.add_collection(q,False)
42014201
self.update_datalim_numerix(q.X,q.Y)
42024202
self.autoscale_view()
42034203
returnq
@@ -5170,6 +5170,7 @@ def get_geometry(self):
51705170
'get the subplot geometry, eg 2,2,3'
51715171
returnself._rows,self._cols,self._num+1
51725172

5173+
# COVERAGE NOTE: Never used internally or from examples
51735174
defchange_geometry(self,numrows,numcols,num):
51745175
'change subplot geometry, eg from 1,1,1 to 2,2,3'
51755176
self._rows=numrows
@@ -5238,6 +5239,7 @@ def is_last_row(self):
52385239
defis_last_col(self):
52395240
returnself.colNum==self.numCols-1
52405241

5242+
# COVERAGE NOTE: Never used internally or from examples
52415243
deflabel_outer(self):
52425244
"""
52435245
set the visible property on ticklabels so xticklabels are

‎lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
223223
baseline (descent), in display coords of the string s with
224224
FontPropertry prop
225225
"""
226-
return1,1,1
226+
raiseNotImplementedError
227227

228228
defnew_gc(self):
229229
"""

‎lib/matplotlib/backends/backend_pdf.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,11 +1180,12 @@ def merge_used_characters(self, other):
11801180
defget_image_magnification(self):
11811181
returnself.image_magnification
11821182

1183-
defdraw_image(self,x,y,im,bbox):
1183+
defdraw_image(self,x,y,im,bbox,clippath=None,clippath_trans=None):
11841184
#print >>sys.stderr, "draw_image called"
11851185

1186+
# MGDTODO: Support clippath here
11861187
gc=self.new_gc()
1187-
gc.set_clip_rectangle(bbox.get_bounds())
1188+
gc.set_clip_rectangle(bbox.bounds)
11881189
self.check_gc(gc)
11891190

11901191
h,w=im.get_size_out()
@@ -1714,13 +1715,19 @@ def delta(self, other):
17141715
"""
17151716
cmds= []
17161717
forparams,cmdinself.commands:
1717-
ours= [getattr(self,p)forpinparams ]
1718-
theirs= [getattr(other,p)forpinparams ]
1719-
try:
1720-
different=ours!=theirs
1721-
exceptValueError:
1722-
different=ours.shape!=theirs.shapeornpy.any(ours!=theirs)
1723-
ifoursisnottheirs:
1718+
different=False
1719+
forpinparams:
1720+
ours=getattr(self,p)
1721+
theirs=getattr(other,p)
1722+
try:
1723+
different=bool(ours!=theirs)
1724+
exceptValueError:
1725+
different=ours.shape!=theirs.shapeornpy.any(ours!=theirs)
1726+
ifdifferent:
1727+
break
1728+
1729+
ifdifferent:
1730+
theirs= [getattr(other,p)forpinparams]
17241731
cmds.extend(cmd(self,*theirs))
17251732
forpinparams:
17261733
setattr(self,p,getattr(other,p))

‎lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,12 +994,12 @@ def _print_figure_tex(self, outfile, format, dpi, facecolor, edgecolor,
994994
tmpfile=os.path.join(gettempdir(),md5.md5(outfile).hexdigest())
995995
fh=file(tmpfile,'w')
996996

997-
self.figure.dpi.set(72)# ignore the dpi kwarg
997+
self.figure.dpi=72# ignore the dpi kwarg
998998
width,height=self.figure.get_size_inches()
999999
xo=0
10001000
yo=0
10011001

1002-
l,b,w,h=self.figure.bbox.get_bounds()
1002+
l,b,w,h=self.figure.bbox.bounds
10031003
llx=xo
10041004
lly=yo
10051005
urx=llx+w

‎lib/matplotlib/backends/backend_svg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
193193
details='xlink:href="#%s" x="%f" y="%f"'% (name,x,y)
194194
self._draw_svg_element('use',details,gc,rgbFace)
195195

196-
defdraw_image(self,x,y,im,bbox):
196+
defdraw_image(self,x,y,im,bbox,clippath=None,clippath_trans=None):
197+
# MGDTODO: Support clippath here
197198
trans= [1,0,0,1,0,0]
198199
transstr=''
199200
ifrcParams['svg.image_noscale']:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp