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

Skip to content

Commit 70e7a6c

Browse files
authored
Merge pull request #6868 from jenshnielsen/buildmiscexamples
DOC: Build misc examples
2 parents 1ea17e1 + b926d50 commit 70e7a6c

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-
import urllib
6+
from six.moves import urllib
77
import numpy as np
88
import matplotlib.pyplot as plt
99
import matplotlib.mlab as mlab
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
raise ValueError("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+
if six.PY2:
2392+
old_dtypes = [(name.encode('utf-8'), dt) for name, dt in old_dtypes]
2393+
newdtype = np.dtype(old_dtypes + list(zip(names, dtypes)))
23922394
newrec = np.recarray(rec.shape, dtype=newdtype)
23932395
for field in rec.dtype.fields:
23942396
newrec[field] = rec[field]
@@ -2596,8 +2598,10 @@ def mapped_r2field(name):
25962598
if desc[0] not in key]
25972599
r2desc = [(mapped_r2field(desc[0]), desc[1]) for desc in r2.dtype.descr
25982600
if desc[0] not in key]
2599-
newdtype = np.dtype(keydesc + r1desc + r2desc)
2600-
2601+
all_dtypes = keydesc + r1desc + r2desc
2602+
if six.PY2:
2603+
all_dtypes = [(name.encode('utf-8'), dt) for name, dt in all_dtypes]
2604+
newdtype = np.dtype(all_dtypes)
26012605
newrec = np.recarray((common_len + left_len + right_len,), dtype=newdtype)
26022606

26032607
if defaults is not None:
@@ -2613,7 +2617,7 @@ def mapped_r2field(name):
26132617

26142618
if jointype != 'inner' and defaults is not None:
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
for k, v in six.iteritems(defaults):
26182622
if k in newrec_fields:
26192623
newrec[k] = v

0 commit comments

Comments
 (0)