summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrgommers <ralf.gommers@googlemail.com>2011-03-03 14:13:28 +0800
committerrgommers <ralf.gommers@googlemail.com>2011-03-03 14:13:28 +0800
commit821afc8f1376a634612e182903c06a0c9c556d94 (patch)
tree909d7f649c4db817a1c0f1e8fc9f1934584242b9
parent85813a9a2eb163582cb518f0fe5d632b662ad0c7 (diff)
downloadnumpy-821afc8f1376a634612e182903c06a0c9c556d94.tar.gz
DOC: commit some more fixes from the doc wiki.
-rw-r--r--numpy/add_newdocs.py45
-rw-r--r--numpy/core/numerictypes.py5
-rw-r--r--numpy/lib/function_base.py26
-rw-r--r--numpy/lib/npyio.py2
-rw-r--r--numpy/linalg/linalg.py18
5 files changed, 73 insertions, 23 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
index c631fe3d0..6f9435c5c 100644
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -1337,6 +1337,11 @@ add_newdoc('numpy.core.multiarray', 'promote_types',
out : dtype
The promoted data type.
+ See Also
+ --------
+ issctype, issubsctype, issubdtype, obj2sctype, sctype2char,
+ maximum_sctype, min_scalar_type
+
Examples
--------
>>> np.promote_types('f4', 'f8')
@@ -1352,6 +1357,7 @@ add_newdoc('numpy.core.multiarray', 'promote_types',
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: invalid type promotion
+
""")
add_newdoc('numpy.core.multiarray', 'min_scalar_type',
@@ -1375,6 +1381,12 @@ add_newdoc('numpy.core.multiarray', 'min_scalar_type',
out : dtype
The minimal data type.
+
+ See Also
+ --------
+ issctype, issubsctype, issubdtype, obj2sctype, sctype2char,
+ maximum_sctype, promote_types
+
Examples
--------
>>> np.min_scalar_type(10)
@@ -2854,6 +2866,35 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('diagonal',
"""))
+add_newdoc('numpy.core.multiarray', 'ndarray', ('dot',
+ """
+ a.dot(b, out=None)
+
+ Dot product of two arrays.
+
+ Refer to `numpy.dot` for full documentation.
+
+ See Also
+ --------
+ numpy.dot : equivalent function
+
+ Examples
+ --------
+ >>> a = np.eye(2)
+ >>> b = np.ones((2, 2)) * 2
+ >>> a.dot(b)
+ array([[ 2., 2.],
+ [ 2., 2.]])
+
+ This array method can be conveniently chained:
+
+ >>> a.dot(b).dot(b)
+ array([[ 8., 8.],
+ [ 8., 8.]])
+
+ """))
+
+
add_newdoc('numpy.core.multiarray', 'ndarray', ('dump',
"""a.dump(file)
@@ -4458,9 +4499,10 @@ add_newdoc('numpy.lib._compiled_base', 'unravel_index',
version of an array of dimensions ``dims``. Before version 1.6.0,
this function accepted just one index value.
dims : tuple of ints
- The shape of the array to use for unravelling ``indices``.
+ The shape of the array to use for unraveling ``indices``.
order : {'C', 'F'}, optional
.. versionadded:: 1.6.0
+
Determines whether the indices should be viewed as indexing in
C (row-major) order or FORTRAN (column-major) order.
@@ -4483,6 +4525,7 @@ add_newdoc('numpy.lib._compiled_base', 'unravel_index',
>>> np.unravel_index(1621, (6,7,8,9))
(3, 1, 4, 1)
+
""")
add_newdoc('numpy.lib._compiled_base', 'add_docstring',
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index 9482257bc..8874667d8 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -589,6 +589,11 @@ def issctype(rep):
>>> np.issctype(1.1)
False
+ Strings are also a scalar type:
+
+ >>> np.issctype(np.dtype('str'))
+ True
+
"""
if not isinstance(rep, (type, dtype)):
return False
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 033e18f8e..b2d2856d6 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -2921,22 +2921,22 @@ def percentile(a, q, axis=None, out=None, overwrite_input=False):
a : array_like
Input array or object that can be converted to an array.
q : float in range of [0,100] (or sequence of floats)
- percentile to compute which must be between 0 and 100 inclusive
- axis : {None, int}, optional
- Axis along which the percentiles are computed. The default (axis=None)
+ Percentile to compute which must be between 0 and 100 inclusive.
+ axis : int, optional
+ Axis along which the percentiles are computed. The default (None)
is to compute the median along a flattened version of the array.
out : ndarray, optional
Alternative output array in which to place the result. It must
have the same shape and buffer length as the expected output,
but the type (of the output) will be cast if necessary.
- overwrite_input : {False, True}, optional
- If True, then allow use of memory of input array (a) for
+ overwrite_input : bool, optional
+ If True, then allow use of memory of input array `a` for
calculations. The input array will be modified by the call to
median. This will save memory when you do not need to preserve
the contents of the input array. Treat the input as undefined,
- but it will probably be fully or partially sorted. Default is
- False. Note that, if `overwrite_input` is True and the input
- is not already an ndarray, an error will be raised.
+ but it will probably be fully or partially sorted.
+ Default is False. Note that, if `overwrite_input` is True and the
+ input is not already an array, an error will be raised.
Returns
-------
@@ -2954,10 +2954,10 @@ def percentile(a, q, axis=None, out=None, overwrite_input=False):
Notes
-----
Given a vector V of length N, the qth percentile of V is the qth ranked
- value in a sorted copy of V. A weighted average of the two nearest neighbors
- is used if the normalized ranking does not match q exactly.
- The same as the median if q is 0.5; the same as the min if q is 0;
- and the same as the max if q is 1
+ value in a sorted copy of V. A weighted average of the two nearest
+ neighbors is used if the normalized ranking does not match q exactly.
+ The same as the median if ``q=0.5``, the same as the minimum if ``q=0``
+ and the same as the maximum if ``q=1``.
Examples
--------
@@ -2971,12 +2971,14 @@ def percentile(a, q, axis=None, out=None, overwrite_input=False):
array([ 6.5, 4.5, 2.5])
>>> np.percentile(a, 0.5, axis=1)
array([ 7., 2.])
+
>>> m = np.percentile(a, 0.5, axis=0)
>>> out = np.zeros_like(m)
>>> np.percentile(a, 0.5, axis=0, out=m)
array([ 6.5, 4.5, 2.5])
>>> m
array([ 6.5, 4.5, 2.5])
+
>>> b = a.copy()
>>> np.percentile(b, 0.5, axis=1, overwrite_input=True)
array([ 7., 2.])
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 1f2fc714a..15d29d60b 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -500,7 +500,7 @@ def savez_compressed(file, *args, **kwds):
Parameters
----------
- file : string
+ file : str
File name of .npz file.
args : Arguments
Function arguments.
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index c23338cd8..87be0e8a3 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -1567,8 +1567,8 @@ def slogdet(a):
Parameters
----------
- a : array_like, shape (M, M)
- Input array.
+ a : array_like
+ Input array, has to be a square 2-D array.
Returns
-------
@@ -1580,18 +1580,22 @@ def slogdet(a):
The natural log of the absolute value of the determinant.
If the determinant is zero, then `sign` will be 0 and `logdet` will be
- -Inf. In all cases, the determinant is equal to `sign * np.exp(logdet)`.
+ -Inf. In all cases, the determinant is equal to ``sign * np.exp(logdet)``.
+
+ See Also
+ --------
+ det
Notes
-----
The determinant is computed via LU factorization using the LAPACK
routine z/dgetrf.
- .. versionadded:: 2.0.0.
+ .. versionadded:: 1.6.0.
Examples
--------
- The determinant of a 2-D array [[a, b], [c, d]] is ad - bc:
+ The determinant of a 2-D array ``[[a, b], [c, d]]`` is ``ad - bc``:
>>> a = np.array([[1, 2], [3, 4]])
>>> (sign, logdet) = np.linalg.slogdet(a)
@@ -1607,10 +1611,6 @@ def slogdet(a):
>>> np.linalg.slogdet(np.eye(500) * 0.1)
(1, -1151.2925464970228)
- See Also
- --------
- det
-
"""
a = asarray(a)
_assertRank2(a)