summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-06-09 09:11:52 -0600
committerGitHub <noreply@github.com>2018-06-09 09:11:52 -0600
commit0c34d3d4674caac3831dd86f202299661bf348f7 (patch)
treefbd69c70f0675a1aa6063d2849cc291ab33f5610
parentdf7b99c63b3686a25b10888e8374a936ab615de7 (diff)
parent5959bb640cf8bd42fc1033b09755d33743814b93 (diff)
downloadnumpy-0c34d3d4674caac3831dd86f202299661bf348f7.tar.gz
Merge pull request #11222 from hmaarrfk/documentation_nditer
DOC: Make reference doc nditer examples python3 friendly
-rw-r--r--doc/source/reference/arrays.nditer.rst38
1 files changed, 19 insertions, 19 deletions
diff --git a/doc/source/reference/arrays.nditer.rst b/doc/source/reference/arrays.nditer.rst
index 239f4296b..fa8183f75 100644
--- a/doc/source/reference/arrays.nditer.rst
+++ b/doc/source/reference/arrays.nditer.rst
@@ -26,7 +26,7 @@ using the standard Python iterator interface.
>>> a = np.arange(6).reshape(2,3)
>>> for x in np.nditer(a):
- ... print x,
+ ... print(x, end=' ')
...
0 1 2 3 4 5
@@ -42,12 +42,12 @@ of that transpose in C order.
>>> a = np.arange(6).reshape(2,3)
>>> for x in np.nditer(a.T):
- ... print x,
+ ... print(x, end=' ')
...
0 1 2 3 4 5
>>> for x in np.nditer(a.T.copy(order='C')):
- ... print x,
+ ... print(x, end=' ')
...
0 3 1 4 2 5
@@ -70,11 +70,11 @@ order='C' for C order and order='F' for Fortran order.
>>> a = np.arange(6).reshape(2,3)
>>> for x in np.nditer(a, order='F'):
- ... print x,
+ ... print(x, end=' ')
...
0 3 1 4 2 5
>>> for x in np.nditer(a.T, order='C'):
- ... print x,
+ ... print(x, end=' ')
...
0 3 1 4 2 5
@@ -139,12 +139,12 @@ elements each.
>>> a = np.arange(6).reshape(2,3)
>>> for x in np.nditer(a, flags=['external_loop']):
- ... print x,
+ ... print(x, end=' ')
...
[0 1 2 3 4 5]
>>> for x in np.nditer(a, flags=['external_loop'], order='F'):
- ... print x,
+ ... print(x, end=' ')
...
[0 3] [1 4] [2 5]
@@ -174,14 +174,14 @@ construct in order to be more readable.
>>> a = np.arange(6).reshape(2,3)
>>> it = np.nditer(a, flags=['f_index'])
>>> while not it.finished:
- ... print "%d <%d>" % (it[0], it.index),
+ ... print("%d <%d>" % (it[0], it.index), end=' ')
... it.iternext()
...
0 <0> 1 <2> 2 <4> 3 <1> 4 <3> 5 <5>
>>> it = np.nditer(a, flags=['multi_index'])
>>> while not it.finished:
- ... print "%d <%s>" % (it[0], it.multi_index),
+ ... print("%d <%s>" % (it[0], it.multi_index), end=' ')
... it.iternext()
...
0 <(0, 0)> 1 <(0, 1)> 2 <(0, 2)> 3 <(1, 0)> 4 <(1, 1)> 5 <(1, 2)>
@@ -228,12 +228,12 @@ is enabled.
>>> a = np.arange(6).reshape(2,3)
>>> for x in np.nditer(a, flags=['external_loop'], order='F'):
- ... print x,
+ ... print(x, end=' ')
...
[0 3] [1 4] [2 5]
>>> for x in np.nditer(a, flags=['external_loop','buffered'], order='F'):
- ... print x,
+ ... print(x, end=' ')
...
[0 3 1 4 2 5]
@@ -270,7 +270,7 @@ data type doesn't match precisely.
>>> a = np.arange(6).reshape(2,3) - 3
>>> for x in np.nditer(a, op_dtypes=['complex128']):
- ... print np.sqrt(x),
+ ... print(np.sqrt(x), end=' ')
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
@@ -285,12 +285,12 @@ specified as an iterator flag.
>>> a = np.arange(6).reshape(2,3) - 3
>>> for x in np.nditer(a, op_flags=['readonly','copy'],
... op_dtypes=['complex128']):
- ... print np.sqrt(x),
+ ... print(np.sqrt(x), end=' ')
...
1.73205080757j 1.41421356237j 1j 0j (1+0j) (1.41421356237+0j)
>>> for x in np.nditer(a, flags=['buffered'], op_dtypes=['complex128']):
- ... print np.sqrt(x),
+ ... print(np.sqrt(x), end=' ')
...
1.73205080757j 1.41421356237j 1j 0j (1+0j) (1.41421356237+0j)
@@ -306,7 +306,7 @@ complex to float.
>>> a = np.arange(6.)
>>> for x in np.nditer(a, flags=['buffered'], op_dtypes=['float32']):
- ... print x,
+ ... print(x, end=' ')
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
@@ -314,12 +314,12 @@ complex to float.
>>> for x in np.nditer(a, flags=['buffered'], op_dtypes=['float32'],
... casting='same_kind'):
- ... print x,
+ ... print(x, end=' ')
...
0.0 1.0 2.0 3.0 4.0 5.0
>>> for x in np.nditer(a, flags=['buffered'], op_dtypes=['int32'], casting='same_kind'):
- ... print x,
+ ... print(x, end=' ')
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
@@ -361,7 +361,7 @@ a two dimensional array together.
>>> a = np.arange(3)
>>> b = np.arange(6).reshape(2,3)
>>> for x, y in np.nditer([a,b]):
- ... print "%d:%d" % (x,y),
+ ... print("%d:%d" % (x,y), end=' ')
...
0:0 1:1 2:2 0:3 1:4 2:5
@@ -373,7 +373,7 @@ which includes the input shapes to help diagnose the problem.
>>> a = np.arange(2)
>>> b = np.arange(6).reshape(2,3)
>>> for x, y in np.nditer([a,b]):
- ... print "%d:%d" % (x,y),
+ ... print("%d:%d" % (x,y), end=' ')
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>