summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
diff options
context:
space:
mode:
authorAndras Deak <deak.andris@gmail.com>2018-04-27 14:05:07 +0200
committerAndras Deak <deak.andris@gmail.com>2018-04-27 16:51:50 +0200
commit92f85239dad607540a1fa3124e41c7b357caf7fe (patch)
tree582f9f751e91b75e04f4d3a2cf4400d4a1ff8d27 /numpy/lib/npyio.py
parent79cd01d4e7daaf925d29194ce0cdfa7b14dba85c (diff)
downloadnumpy-92f85239dad607540a1fa3124e41c7b357caf7fe.tar.gz
DOC: Make doc examples using StringIO python2-3 compatible
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r--numpy/lib/npyio.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 67585443b..97f50b5d8 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -859,18 +859,18 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
Examples
--------
>>> from io import StringIO # StringIO behaves like a file object
- >>> c = StringIO("0 1\\n2 3")
+ >>> c = StringIO(u"0 1\\n2 3")
>>> np.loadtxt(c)
array([[ 0., 1.],
[ 2., 3.]])
- >>> d = StringIO("M 21 72\\nF 35 58")
+ >>> d = StringIO(u"M 21 72\\nF 35 58")
>>> np.loadtxt(d, dtype={'names': ('gender', 'age', 'weight'),
... 'formats': ('S1', 'i4', 'f4')})
array([('M', 21, 72.0), ('F', 35, 58.0)],
dtype=[('gender', '|S1'), ('age', '<i4'), ('weight', '<f4')])
- >>> c = StringIO("1,0,2\\n3,0,4")
+ >>> c = StringIO(u"1,0,2\\n3,0,4")
>>> x, y = np.loadtxt(c, delimiter=',', usecols=(0, 2), unpack=True)
>>> x
array([ 1., 3.])
@@ -1632,7 +1632,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
Comma delimited file with mixed dtype
- >>> s = StringIO("1,1.3,abcde")
+ >>> s = StringIO(u"1,1.3,abcde")
>>> data = np.genfromtxt(s, dtype=[('myint','i8'),('myfloat','f8'),
... ('mystring','S5')], delimiter=",")
>>> data
@@ -1659,7 +1659,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
An example with fixed-width columns
- >>> s = StringIO("11.3abcde")
+ >>> s = StringIO(u"11.3abcde")
>>> data = np.genfromtxt(s, dtype=None, names=['intvar','fltvar','strvar'],
... delimiter=[1,3,5])
>>> data