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

Commit70e7a6c

Browse files
authored
Merge pull request#6868 from jenshnielsen/buildmiscexamples
DOC: Build misc examples
2 parents1ea17e1 +b926d50 commit70e7a6c

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

‎doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
('axes_grid','axes_grid toolkit'),
139139
('units','units'),
140140
('widgets','widgets'),
141+
('misc','Miscellaneous examples'),
141142
]
142143

143144

‎examples/misc/image_thumbnail.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- noplot -*-
12
"""
23
You can use matplotlib to generate thumbnails from existing images.
34
matplotlib natively supports PNG files on the input side, and other

‎examples/misc/longshort.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
csv file, computing the daily returns, appending the results to the
44
record arrays, joining on date
55
"""
6-
importurllib
6+
fromsix.movesimporturllib
77
importnumpyasnp
88
importmatplotlib.pyplotasplt
99
importmatplotlib.mlabasmlab
1010

1111
# grab the price data off yahoo
12-
u1=urllib.urlretrieve('http://ichart.finance.yahoo.com/table.csv?s=AAPL&d=9&e=14&f=2008&g=d&a=8&b=7&c=1984&ignore=.csv')
13-
u2=urllib.urlretrieve('http://ichart.finance.yahoo.com/table.csv?s=GOOG&d=9&e=14&f=2008&g=d&a=8&b=7&c=1984&ignore=.csv')
12+
u1=urllib.request.urlretrieve('http://ichart.finance.yahoo.com/table.csv?s=AAPL&d=9&e=14&f=2008&g=d&a=8&b=7&c=1984&ignore=.csv')
13+
u2=urllib.request.urlretrieve('http://ichart.finance.yahoo.com/table.csv?s=GOOG&d=9&e=14&f=2008&g=d&a=8&b=7&c=1984&ignore=.csv')
1414

1515
# load the CSV files into record arrays
16-
r1=mlab.csv2rec(file(u1[0]))
17-
r2=mlab.csv2rec(file(u2[0]))
16+
r1=mlab.csv2rec(open(u1[0]))
17+
r2=mlab.csv2rec(open(u2[0]))
1818

1919
# compute the daily returns and add these columns to the arrays
2020
gains1=np.zeros_like(r1.adj_close)

‎examples/misc/multiprocess.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- noplot -*-
12
# Demo of using multiprocessing for generating data in one process and plotting
23
# in another.
34
# Written by Robert Cimrman

‎examples/misc/rc_traits.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- noplot -*-
12
# Here is some example code showing how to define some representative
23
# rc properties and construct a matplotlib artist using traits.
34
# matplotlib does not ship with enthought.traits, so you will need to

‎lib/matplotlib/mlab.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,8 +2387,10 @@ def rec_append_fields(rec, names, arrs, dtypes=None):
23872387
dtypes=dtypes*len(arrs)
23882388
else:
23892389
raiseValueError("dtypes must be None, a single dtype or a list")
2390-
2391-
newdtype=np.dtype(rec.dtype.descr+list(zip(names,dtypes)))
2390+
old_dtypes=rec.dtype.descr
2391+
ifsix.PY2:
2392+
old_dtypes= [(name.encode('utf-8'),dt)forname,dtinold_dtypes]
2393+
newdtype=np.dtype(old_dtypes+list(zip(names,dtypes)))
23922394
newrec=np.recarray(rec.shape,dtype=newdtype)
23932395
forfieldinrec.dtype.fields:
23942396
newrec[field]=rec[field]
@@ -2596,8 +2598,10 @@ def mapped_r2field(name):
25962598
ifdesc[0]notinkey]
25972599
r2desc= [(mapped_r2field(desc[0]),desc[1])fordescinr2.dtype.descr
25982600
ifdesc[0]notinkey]
2599-
newdtype=np.dtype(keydesc+r1desc+r2desc)
2600-
2601+
all_dtypes=keydesc+r1desc+r2desc
2602+
ifsix.PY2:
2603+
all_dtypes= [(name.encode('utf-8'),dt)forname,dtinall_dtypes]
2604+
newdtype=np.dtype(all_dtypes)
26012605
newrec=np.recarray((common_len+left_len+right_len,),dtype=newdtype)
26022606

26032607
ifdefaultsisnotNone:
@@ -2613,7 +2617,7 @@ def mapped_r2field(name):
26132617

26142618
ifjointype!='inner'anddefaultsisnotNone:
26152619
# fill in the defaults enmasse
2616-
newrec_fields=list(six.iterkeys(newrec.dtype.fields.keys))
2620+
newrec_fields=list(six.iterkeys(newrec.dtype.fields))
26172621
fork,vinsix.iteritems(defaults):
26182622
ifkinnewrec_fields:
26192623
newrec[k]=v

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp