summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/lib/arraysetops.py16
-rw-r--r--numpy/lib/function_base.py11
-rw-r--r--numpy/lib/type_check.py12
-rw-r--r--numpy/linalg/linalg.py81
4 files changed, 63 insertions, 57 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index 91dd96f9c..20a0e7151 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -44,7 +44,7 @@ def ediff1d(ary, to_end=None, to_begin=None):
Returns
-------
- ed : ndarray
+ ediff1d : ndarray
The differences. Loosely, this is ``ary.flat[1:] - ary.flat[:-1]``.
See Also
@@ -212,7 +212,7 @@ def intersect1d(ar1, ar2, assume_unique=False):
Returns
-------
- out : ndarray
+ intersect1d : ndarray
Sorted 1D array of common and unique elements.
See Also
@@ -251,7 +251,7 @@ def setxor1d(ar1, ar2, assume_unique=False):
Returns
-------
- xor : ndarray
+ setxor1d : ndarray
Sorted 1D array of unique values that are in only one of the input
arrays.
@@ -287,7 +287,7 @@ def in1d(ar1, ar2, assume_unique=False):
Parameters
----------
- ar1 : array_like, shape (M,)
+ ar1 : (M,) array_like
Input array.
ar2 : array_like
The values against which to test each value of `ar1`.
@@ -297,8 +297,8 @@ def in1d(ar1, ar2, assume_unique=False):
Returns
-------
- mask : ndarray of bools, shape(M,)
- The values `ar1[mask]` are in `ar2`.
+ in1d : (M,) ndarray, bool
+ The values `ar1[in1d]` are in `ar2`.
See Also
--------
@@ -365,7 +365,7 @@ def union1d(ar1, ar2):
Returns
-------
- union : ndarray
+ union1d : ndarray
Unique, sorted union of the input arrays.
See Also
@@ -399,7 +399,7 @@ def setdiff1d(ar1, ar2, assume_unique=False):
Returns
-------
- difference : ndarray
+ setdiff1d : ndarray
Sorted 1D array of values in `ar1` that are not in `ar2`.
See Also
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 6a457010b..a0781ebf9 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -843,7 +843,7 @@ def gradient(f, *varargs):
Returns
-------
- g : ndarray
+ gradient : ndarray
N arrays of the same shape as `f` giving the derivative of `f` with
respect to each dimension.
@@ -948,7 +948,7 @@ def diff(a, n=1, axis=-1):
Returns
-------
- out : ndarray
+ diff : ndarray
The `n` order differences. The shape of the output is the same as `a`
except along `axis` where the dimension is smaller by `n`.
@@ -1284,6 +1284,11 @@ def extract(condition, arr):
arr : array_like
Input array of the same size as `condition`.
+ Returns
+ -------
+ extract : ndarray
+ Rank 1 array of values from `arr` where `condition` is True.
+
See Also
--------
take, put, copyto, compress
@@ -2714,7 +2719,7 @@ def kaiser(M,beta):
A beta value of 14 is probably a good starting point. Note that as beta
gets large, the window narrows, and so the number of samples needs to be
- large enough to sample the increasingly narrow spike, otherwise nans will
+ large enough to sample the increasingly narrow spike, otherwise NaNs will
get returned.
Most references to the Kaiser window come from the signal processing
diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py
index c116c7e4a..e22d63156 100644
--- a/numpy/lib/type_check.py
+++ b/numpy/lib/type_check.py
@@ -233,11 +233,10 @@ def isreal(x):
def iscomplexobj(x):
"""
- Return True if x is a complex type or an array of complex numbers.
+ Check for a complex type or an array of complex numbers.
- The type of the input is checked, not the value. So even if the input
- has an imaginary part equal to zero, `iscomplexobj` evaluates to True
- if the data type is complex.
+ The type of the input is checked, not the value. Even if the input
+ has an imaginary part equal to zero, `iscomplexobj` evaluates to True.
Parameters
----------
@@ -246,8 +245,9 @@ def iscomplexobj(x):
Returns
-------
- y : bool
- The return value, True if `x` is of a complex type.
+ iscomplexobj : bool
+ The return value, True if `x` is of a complex type or has at least
+ one complex element.
See Also
--------
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index aba656b5e..f25452064 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -250,15 +250,15 @@ def solve(a, b):
Parameters
----------
- a : array_like, shape (M, M)
+ a : (M, M) array_like
Coefficient matrix.
- b : array_like, shape (M,) or (M, N)
+ b : {(M,), (M, N)}, array_like
Ordinate or "dependent variable" values.
Returns
-------
- x : ndarray, shape (M,) or (M, N) depending on b
- Solution to the system a x = b
+ x : {(M,), (M, N)} ndarray
+ Solution to the system a x = b. Returned shape is identical to `b`.
Raises
------
@@ -410,12 +410,12 @@ def inv(a):
Parameters
----------
- a : array_like, shape (M, M)
+ a : (M, M) array_like
Matrix to be inverted.
Returns
-------
- ainv : ndarray or matrix, shape (M, M)
+ ainv : (M, M) ndarray or matrix
(Multiplicative) inverse of the matrix `a`.
Raises
@@ -459,14 +459,15 @@ def cholesky(a):
Parameters
----------
- a : array_like, shape (M, M)
+ a : (M, M) array_like
Hermitian (symmetric if all elements are real), positive-definite
input matrix.
Returns
-------
- L : ndarray, or matrix object if `a` is, shape (M, M)
- Lower-triangular Cholesky factor of a.
+ L : {(M, M) ndarray, (M, M) matrix}
+ Lower-triangular Cholesky factor of `a`. Returns a matrix object
+ if `a` is a matrix object.
Raises
------
@@ -709,12 +710,12 @@ def eigvals(a):
Parameters
----------
- a : array_like, shape (M, M)
+ a : (M, M) array_like
A complex- or real-valued matrix whose eigenvalues will be computed.
Returns
-------
- w : ndarray, shape (M,)
+ w : (M,) ndarray
The eigenvalues, each repeated according to its multiplicity.
They are not necessarily ordered, nor are they necessarily
real for real matrices.
@@ -815,7 +816,7 @@ def eigvalsh(a, UPLO='L'):
Parameters
----------
- a : array_like, shape (M, M)
+ a : (M, M) array_like
A complex- or real-valued matrix whose eigenvalues are to be
computed.
UPLO : {'L', 'U'}, optional
@@ -824,7 +825,7 @@ def eigvalsh(a, UPLO='L'):
Returns
-------
- w : ndarray, shape (M,)
+ w : (M,) ndarray
The eigenvalues, not necessarily ordered, each repeated according to
its multiplicity.
@@ -910,18 +911,17 @@ def eig(a):
Parameters
----------
- a : array_like, shape (M, M)
+ a : (M, M) array_like
A square array of real or complex elements.
Returns
-------
- w : ndarray, shape (M,)
+ w : (M,) ndarray
The eigenvalues, each repeated according to its multiplicity.
The eigenvalues are not necessarily ordered, nor are they
necessarily real for real arrays (though for real arrays
complex-valued eigenvalues should occur in conjugate pairs).
-
- v : ndarray, shape (M, M)
+ v : (M, M) ndarray
The normalized (unit "length") eigenvectors, such that the
column ``v[:,i]`` is the eigenvector corresponding to the
eigenvalue ``w[i]``.
@@ -1077,7 +1077,7 @@ def eigh(a, UPLO='L'):
Parameters
----------
- a : array_like, shape (M, M)
+ a : (M, M) array_like
A complex Hermitian or real symmetric matrix.
UPLO : {'L', 'U'}, optional
Specifies whether the calculation is done with the lower triangular
@@ -1085,11 +1085,12 @@ def eigh(a, UPLO='L'):
Returns
-------
- w : ndarray, shape (M,)
+ w : (M,) ndarray
The eigenvalues, not necessarily ordered.
- v : ndarray, or matrix object if `a` is, shape (M, M)
+ v : {(M, M) ndarray, (M, M) matrix}
The column ``v[:, i]`` is the normalized eigenvector corresponding
- to the eigenvalue ``w[i]``.
+ to the eigenvalue ``w[i]``. Will return a matrix object if `a` is
+ a matrix object.
Raises
------
@@ -1338,7 +1339,7 @@ def cond(x, p=None):
Parameters
----------
- x : array_like, shape (M, N)
+ x : (M, N) array_like
The matrix whose condition number is sought.
p : {None, 1, -1, 2, -2, inf, -inf, 'fro'}, optional
Order of the norm:
@@ -1424,9 +1425,9 @@ def matrix_rank(M, tol=None):
Parameters
----------
- M : array_like
+ M : {(M,), (M, N)} array_like
array of <=2 dimensions
- tol : {None, float}
+ tol : {None, float}, optional
threshold below which SVD values are considered zero. If `tol` is
None, and ``S`` is an array with singular values for `M`, and
``eps`` is the epsilon value for datatype of ``S``, then `tol` is
@@ -1489,7 +1490,7 @@ def pinv(a, rcond=1e-15 ):
Parameters
----------
- a : array_like, shape (M, N)
+ a : (M, N) array_like
Matrix to be pseudo-inverted.
rcond : float
Cutoff for small singular values.
@@ -1499,7 +1500,7 @@ def pinv(a, rcond=1e-15 ):
Returns
-------
- B : ndarray, shape (N, M)
+ B : (N, M) ndarray
The pseudo-inverse of `a`. If `a` is a `matrix` instance, then so
is `B`.
@@ -1647,14 +1648,19 @@ def det(a):
Parameters
----------
- a : array_like, shape (M, M)
+ a : (M, M) array_like
Input array.
Returns
-------
- det : ndarray
+ det : float
Determinant of `a`.
+ See Also
+ --------
+ slogdet : Another way to representing the determinant, more suitable
+ for large matrices where underflow/overflow may occur.
+
Notes
-----
The determinant is computed via LU factorization using the LAPACK
@@ -1668,11 +1674,6 @@ def det(a):
>>> np.linalg.det(a)
-2.0
- See Also
- --------
- slogdet : Another way to representing the determinant, more suitable
- for large matrices where underflow/overflow may occur.
-
"""
sign, logdet = slogdet(a)
return sign * exp(logdet)
@@ -1693,9 +1694,9 @@ def lstsq(a, b, rcond=-1):
Parameters
----------
- a : array_like, shape (M, N)
+ a : (M, N) array_like
"Coefficient" matrix.
- b : array_like, shape (M,) or (M, K)
+ b : {(M,), (M, K)} array_like
Ordinate or "dependent variable" values. If `b` is two-dimensional,
the least-squares solution is calculated for each of the `K` columns
of `b`.
@@ -1706,18 +1707,18 @@ def lstsq(a, b, rcond=-1):
Returns
-------
- x : ndarray, shape (N,) or (N, K)
+ x : {(M,), (M, K)} ndarray
Least-squares solution. The shape of `x` depends on the shape of
`b`.
- residues : ndarray, shape (), (1,), or (K,)
- Sums of residues; squared Euclidean 2-norm for each column in
+ residuals : {(), (1,), (K,)} ndarray
+ Sums of residuals; squared Euclidean 2-norm for each column in
``b - a*x``.
If the rank of `a` is < N or > M, this is an empty array.
If `b` is 1-dimensional, this is a (1,) shape array.
Otherwise the shape is (K,).
rank : int
Rank of matrix `a`.
- s : ndarray, shape (min(M,N),)
+ s : (min(M, N),) ndarray
Singular values of `a`.
Raises
@@ -1849,7 +1850,7 @@ def norm(x, ord=None):
Parameters
----------
- x : array_like, shape (M,) or (M, N)
+ x : {(M,), (M, N)} array_like
Input array.
ord : {non-zero int, inf, -inf, 'fro'}, optional
Order of the norm (see table under ``Notes``). inf means numpy's