summaryrefslogtreecommitdiff
path: root/numpy/add_newdocs.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r--numpy/add_newdocs.py76
1 files changed, 38 insertions, 38 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
index c44ba9094..eb1083df7 100644
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -19,46 +19,46 @@ Examples
--------
Using array-scalar type:
->>> dtype(int16)
+>>> np.dtype(np.int16)
dtype('int16')
Record, one field name 'f1', containing int16:
->>> dtype([('f1', int16)])
+>>> np.dtype([('f1', np.int16)])
dtype([('f1', '<i2')])
Record, one field named 'f1', in itself containing a record with one field:
->>> dtype([('f1', [('f1', int16)])])
+>>> np.dtype([('f1', [('f1', np.int16)])])
dtype([('f1', [('f1', '<i2')])])
Record, two fields: the first field contains an unsigned int, the
second an int32:
->>> dtype([('f1', uint), ('f2', int32)])
+>>> np.dtype([('f1', np.uint), ('f2', np.int32)])
dtype([('f1', '<u4'), ('f2', '<i4')])
Using array-protocol type strings:
->>> dtype([('a','f8'),('b','S10')])
+>>> np.dtype([('a','f8'),('b','S10')])
dtype([('a', '<f8'), ('b', '|S10')])
Using comma-separated field formats. The shape is (2,3):
->>> dtype("i4, (2,3)f8")
+>>> np.dtype("i4, (2,3)f8")
dtype([('f0', '<i4'), ('f1', '<f8', (2, 3))])
Using tuples. ``int`` is a fixed type, 3 the field's shape. ``void``
is a flexible type, here of size 10:
->>> dtype([('hello',(int,3)),('world',void,10)])
+>>> np.dtype([('hello',(np.int,3)),('world',np.void,10)])
dtype([('hello', '<i4', 3), ('world', '|V10')])
Subdivide ``int16`` into 2 ``int8``'s, called x and y. 0 and 1 are
the offsets in bytes:
->>> dtype((int16, {'x':(int8,0), 'y':(int8,1)}))
+>>> np.dtype((np.int16, {'x':(np.int8,0), 'y':(np.int8,1)}))
dtype(('<i2', [('x', '|i1'), ('y', '|i1')]))
Using dictionaries. Two fields named 'gender' and 'age':
->>> dtype({'names':['gender','age'], 'formats':['S1',uint8]})
+>>> np.dtype({'names':['gender','age'], 'formats':['S1',np.uint8]})
dtype([('gender', '|S1'), ('age', '|u1')])
Offsets in bytes, here 0 and 25:
->>> dtype({'surname':('S25',0),'age':(uint8,25)})
+>>> np.dtype({'surname':('S25',0),'age':(np.uint8,25)})
dtype([('surname', '|S25'), ('age', '|u1')])
""")
@@ -386,7 +386,7 @@ add_newdoc('numpy.core.multiarray','concatenate',
Examples
--------
- >>> concatenate( ([0,1,2], [5,6,7]) )
+ >>> np.concatenate( ([0,1,2], [5,6,7]) )
array([0, 1, 2, 5, 6, 7])
""")
@@ -480,7 +480,7 @@ add_newdoc('numpy.core.multiarray','where',
Examples
--------
- >>> where([True,False,True],[1,2,3],[4,5,6])
+ >>> np.where([True,False,True],[1,2,3],[4,5,6])
array([1, 5, 3])
""")
@@ -520,12 +520,12 @@ add_newdoc('numpy.core.multiarray','lexsort',
--------
>>> a = [1,5,1,4,3,6,7]
>>> b = [9,4,0,4,0,4,3]
- >>> ind = lexsort((b,a))
+ >>> ind = np.lexsort((b,a))
>>> print ind
[2 0 4 3 1 5 6]
- >>> print take(a,ind)
+ >>> print np.take(a,ind)
[1 1 3 4 5 6 7]
- >>> print take(b,ind)
+ >>> print np.take(b,ind)
[0 9 0 4 4 4 3]
""")
@@ -858,7 +858,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('argmax',
Examples
--------
- >>> a = arange(6).reshape(2,3)
+ >>> a = np.arange(6).reshape(2,3)
>>> a.argmax()
5
>>> a.argmax(0)
@@ -889,7 +889,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('argmin',
Examples
--------
- >>> a = arange(6).reshape(2,3)
+ >>> a = np.arange(6).reshape(2,3)
>>> a.argmin()
0
>>> a.argmin(0)
@@ -1008,10 +1008,10 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('choose',
--------
>>> choices = [[0, 1, 2, 3], [10, 11, 12, 13],
... [20, 21, 22, 23], [30, 31, 32, 33]]
- >>> a = array([2, 3, 1, 0], dtype=int)
+ >>> a = np.array([2, 3, 1, 0], dtype=int)
>>> a.choose(choices)
array([20, 31, 12, 3])
- >>> a = array([2, 4, 1, 0], dtype=int)
+ >>> a = np.array([2, 4, 1, 0], dtype=int)
>>> a.choose(choices, mode='clip')
array([20, 31, 12, 3])
>>> a.choose(choices, mode='wrap')
@@ -1226,7 +1226,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('diagonal',
Examples
--------
- >>> a = arange(4).reshape(2,2)
+ >>> a = np.arange(4).reshape(2,2)
>>> a
array([[0, 1],
[2, 3]])
@@ -1235,7 +1235,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('diagonal',
>>> a.diagonal(1)
array([1])
- >>> a = arange(8).reshape(2,2,2)
+ >>> a = np.arange(8).reshape(2,2,2)
>>> a
array([[[0, 1],
[2, 3]],
@@ -1462,13 +1462,13 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('prod',
Examples
--------
- >>> prod([1.,2.])
+ >>> np.prod([1.,2.])
2.0
- >>> prod([1.,2.], dtype=int32)
+ >>> np.prod([1.,2.], dtype=np.int32)
2
- >>> prod([[1.,2.],[3.,4.]])
+ >>> np.prod([[1.,2.],[3.,4.]])
24.0
- >>> prod([[1.,2.],[3.,4.]], axis=1)
+ >>> np.prod([[1.,2.],[3.,4.]], axis=1)
array([ 2., 12.])
Notes
@@ -1599,7 +1599,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('ravel',
Examples
--------
- >>> x = array([[1,2,3],[4,5,6]])
+ >>> x = np.array([[1,2,3],[4,5,6]])
>>> x
array([[1, 2, 3],
[4, 5, 6]])
@@ -1637,7 +1637,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('repeat',
Examples
--------
- >>> x = array([[1,2],[3,4]])
+ >>> x = np.array([[1,2],[3,4]])
>>> x.repeat(2)
array([1, 1, 2, 2, 3, 3, 4, 4])
>>> x.repeat(3, axis=1)
@@ -1725,10 +1725,10 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('round',
Examples
--------
- >>> x = array([.5, 1.5, 2.5, 3.5, 4.5])
+ >>> x = np.array([.5, 1.5, 2.5, 3.5, 4.5])
>>> x.round()
array([ 0., 2., 2., 4., 4.])
- >>> x = array([1,2,3,11])
+ >>> x = np.array([1,2,3,11])
>>> x.round(decimals=1)
array([ 1, 2, 3, 11])
>>> x.round(decimals=-1)
@@ -1840,7 +1840,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('squeeze',
Examples
--------
- >>> x = array([[[1,1,1],[2,2,2],[3,3,3]]])
+ >>> x = np.array([[[1,1,1],[2,2,2],[3,3,3]]])
>>> x.shape
(1, 3, 3)
>>> x.squeeze().shape
@@ -1929,15 +1929,15 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('sum',
Examples
--------
- >>> array([0.5, 1.5]).sum()
+ >>> np.array([0.5, 1.5]).sum()
2.0
- >>> array([0.5, 1.5]).sum(dtype=int32)
+ >>> np.array([0.5, 1.5]).sum(dtype=np.int32)
1
- >>> array([[0, 1], [0, 5]]).sum(axis=0)
+ >>> np.array([[0, 1], [0, 5]]).sum(axis=0)
array([0, 6])
- >>> array([[0, 1], [0, 5]]).sum(axis=1)
+ >>> np.array([[0, 1], [0, 5]]).sum(axis=1)
array([1, 5])
- >>> ones(128, dtype=int8).sum(dtype=int8) # overflow!
+ >>> np.ones(128, dtype=np.int8).sum(dtype=np.int8) # overflow!
-128
Notes
@@ -2120,9 +2120,9 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('trace',
Examples
--------
- >>> eye(3).trace()
+ >>> np.eye(3).trace()
3.0
- >>> a = arange(8).reshape((2,2,2))
+ >>> a = np.arange(8).reshape((2,2,2))
>>> a.trace()
array([6, 8])
@@ -2139,7 +2139,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('transpose',
Examples
--------
- >>> a = array([[1,2],[3,4]])
+ >>> a = np.array([[1,2],[3,4]])
>>> a
array([[1, 2],
[3, 4]])