diff --git a/doc/conf.py b/doc/conf.py index 7eef3bf5d742..1f12b1f9f746 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -138,6 +138,7 @@ ('axes_grid', 'axes_grid toolkit'), ('units', 'units'), ('widgets', 'widgets'), + ('misc', 'Miscellaneous examples'), ] diff --git a/examples/misc/image_thumbnail.py b/examples/misc/image_thumbnail.py index 4e3a1dafc032..89a87ecd563e 100644 --- a/examples/misc/image_thumbnail.py +++ b/examples/misc/image_thumbnail.py @@ -1,3 +1,4 @@ +# -*- noplot -*- """ You can use matplotlib to generate thumbnails from existing images. matplotlib natively supports PNG files on the input side, and other diff --git a/examples/misc/longshort.py b/examples/misc/longshort.py index 56b121db2cfc..8e2a4367c903 100644 --- a/examples/misc/longshort.py +++ b/examples/misc/longshort.py @@ -3,18 +3,18 @@ csv file, computing the daily returns, appending the results to the record arrays, joining on date """ -import urllib +from six.moves import urllib import numpy as np import matplotlib.pyplot as plt import matplotlib.mlab as mlab # grab the price data off yahoo -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') -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') +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') +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') # load the CSV files into record arrays -r1 = mlab.csv2rec(file(u1[0])) -r2 = mlab.csv2rec(file(u2[0])) +r1 = mlab.csv2rec(open(u1[0])) +r2 = mlab.csv2rec(open(u2[0])) # compute the daily returns and add these columns to the arrays gains1 = np.zeros_like(r1.adj_close) diff --git a/examples/misc/multiprocess.py b/examples/misc/multiprocess.py index 510e9001fa3e..1ac93d646355 100644 --- a/examples/misc/multiprocess.py +++ b/examples/misc/multiprocess.py @@ -1,3 +1,4 @@ +# -*- noplot -*- # Demo of using multiprocessing for generating data in one process and plotting # in another. # Written by Robert Cimrman diff --git a/examples/misc/rc_traits.py b/examples/misc/rc_traits.py index 45bdbe079af2..e5aa417f4cd3 100644 --- a/examples/misc/rc_traits.py +++ b/examples/misc/rc_traits.py @@ -1,3 +1,4 @@ +# -*- noplot -*- # Here is some example code showing how to define some representative # rc properties and construct a matplotlib artist using traits. # matplotlib does not ship with enthought.traits, so you will need to diff --git a/lib/matplotlib/mlab.py b/lib/matplotlib/mlab.py index 07ddd98cd22c..38b09ea2cc46 100644 --- a/lib/matplotlib/mlab.py +++ b/lib/matplotlib/mlab.py @@ -2387,8 +2387,10 @@ def rec_append_fields(rec, names, arrs, dtypes=None): dtypes = dtypes * len(arrs) else: raise ValueError("dtypes must be None, a single dtype or a list") - - newdtype = np.dtype(rec.dtype.descr + list(zip(names, dtypes))) + old_dtypes = rec.dtype.descr + if six.PY2: + old_dtypes = [(name.encode('utf-8'), dt) for name, dt in old_dtypes] + newdtype = np.dtype(old_dtypes + list(zip(names, dtypes))) newrec = np.recarray(rec.shape, dtype=newdtype) for field in rec.dtype.fields: newrec[field] = rec[field] @@ -2596,8 +2598,10 @@ def mapped_r2field(name): if desc[0] not in key] r2desc = [(mapped_r2field(desc[0]), desc[1]) for desc in r2.dtype.descr if desc[0] not in key] - newdtype = np.dtype(keydesc + r1desc + r2desc) - + all_dtypes = keydesc + r1desc + r2desc + if six.PY2: + all_dtypes = [(name.encode('utf-8'), dt) for name, dt in all_dtypes] + newdtype = np.dtype(all_dtypes) newrec = np.recarray((common_len + left_len + right_len,), dtype=newdtype) if defaults is not None: @@ -2613,7 +2617,7 @@ def mapped_r2field(name): if jointype != 'inner' and defaults is not None: # fill in the defaults enmasse - newrec_fields = list(six.iterkeys(newrec.dtype.fields.keys)) + newrec_fields = list(six.iterkeys(newrec.dtype.fields)) for k, v in six.iteritems(defaults): if k in newrec_fields: newrec[k] = v