Skip to content

Commit f4bf3e8

Browse files
committed
Update docstrings to mention namedtuple in return sections
1 parent 707886d commit f4bf3e8

File tree

1 file changed

+49
-39
lines changed

1 file changed

+49
-39
lines changed

dpnp/linalg/dpnp_iface_linalg.py

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -468,17 +468,18 @@ def eig(a):
468468
469469
Returns
470470
-------
471+
A namedtuple with the following attributes:
472+
471473
eigenvalues : (..., M) dpnp.ndarray
472474
The eigenvalues, each repeated according to its multiplicity.
473-
The eigenvalues are not necessarily ordered. The resulting
474-
array will be of complex type, unless the imaginary part is
475-
zero in which case it will be cast to a real type. When `a`
476-
is real the resulting eigenvalues will be real (0 imaginary
477-
part) or occur in conjugate pairs
475+
The eigenvalues are not necessarily ordered. The resulting array will
476+
be of complex type, unless the imaginary part is zero in which case it
477+
will be cast to a real type. When `a` is real the resulting eigenvalues
478+
will be real (zero imaginary part) or occur in conjugate pairs.
478479
eigenvectors : (..., M, M) dpnp.ndarray
479-
The normalized (unit "length") eigenvectors, such that the
480-
column ``v[:,i]`` is the eigenvector corresponding to the
481-
eigenvalue ``w[i]``.
480+
The normalized (unit "length") eigenvectors, such that the column
481+
``eigenvectors[:,i]`` is the eigenvector corresponding to the
482+
eigenvalue ``eigenvalues[i]``.
482483
483484
Note
484485
----
@@ -582,12 +583,14 @@ def eigh(a, UPLO="L"):
582583
583584
Returns
584585
-------
585-
w : (..., M) dpnp.ndarray
586-
The eigenvalues in ascending order, each repeated according to
587-
its multiplicity.
588-
v : (..., M, M) dpnp.ndarray
589-
The column ``v[:, i]`` is the normalized eigenvector corresponding
590-
to the eigenvalue ``w[i]``.
586+
A namedtuple with the following attributes:
587+
588+
eigenvalues : (..., M) dpnp.ndarray
589+
The eigenvalues in ascending order, each repeated according to its
590+
multiplicity.
591+
eigenvectors : (..., M, M) dpnp.ndarray
592+
The column ``eigenvectors[:, i]`` is the normalized eigenvector
593+
corresponding to the eigenvalue ``eigenvalues[i]``.
591594
592595
See Also
593596
--------
@@ -661,7 +664,7 @@ def eigvals(a):
661664
Illustration, using the fact that the eigenvalues of a diagonal matrix
662665
are its diagonal elements, that multiplying a matrix on the left
663666
by an orthogonal matrix, `Q`, and on the right by `Q.T` (the transpose
664-
of `Q`), preserves the eigenvalues of the "middle" matrix. In other words,
667+
of `Q`), preserves the eigenvalues of the "middle" matrix. In other words,
665668
if `Q` is orthogonal, then ``Q * A * Q.T`` has the same eigenvalues as
666669
``A``:
667670
@@ -856,7 +859,7 @@ def lstsq(a, b, rcond=None):
856859
gradient of roughly 1 and cut the y-axis at, more or less, -1.
857860
858861
We can rewrite the line equation as ``y = Ap``, where ``A = [[x 1]]``
859-
and ``p = [[m], [c]]``. Now use `lstsq` to solve for `p`:
862+
and ``p = [[m], [c]]``. Now use `lstsq` to solve for `p`:
860863
861864
>>> A = np.vstack([x, np.ones(len(x))]).T
862865
>>> A
@@ -1269,7 +1272,7 @@ def norm(x, ord=None, axis=None, keepdims=False):
12691272
Parameters
12701273
----------
12711274
x : {dpnp.ndarray, usm_ndarray}
1272-
Input array. If `axis` is ``None``, `x` must be 1-D or 2-D, unless
1275+
Input array. If `axis` is ``None``, `x` must be 1-D or 2-D, unless
12731276
`ord` is ``None``. If both `axis` and `ord` are ``None``, the 2-norm
12741277
of ``x.ravel`` will be returned.
12751278
ord : {int, float, inf, -inf, "fro", "nuc"}, optional
@@ -1574,20 +1577,22 @@ def qr(a, mode="reduced"):
15741577
Returns
15751578
-------
15761579
When mode is "reduced" or "complete", the result will be a namedtuple with
1577-
the attributes Q and R.
1578-
Q : dpnp.ndarray
1580+
the attributes `Q` and `R`.
1581+
1582+
Q : dpnp.ndarray of float or complex, optional
15791583
A matrix with orthonormal columns.
1580-
When mode = "complete" the result is an orthogonal/unitary matrix
1581-
depending on whether or not a is real/complex.
1582-
The determinant may be either +/- 1 in that case.
1583-
In case the number of dimensions in the input array is greater
1584-
than 2 then a stack of the matrices with above properties is returned.
1585-
R : dpnp.ndarray
1586-
The upper-triangular matrix or a stack of upper-triangular matrices
1587-
if the number of dimensions in the input array is greater than 2.
1588-
(h, tau) : tuple of dpnp.ndarray
1589-
The `h` array contains the Householder reflectors that generate Q along
1590-
with R. The `tau` array contains scaling factors for the reflectors.
1584+
When mode is ``"complete"`` the result is an orthogonal/unitary matrix
1585+
depending on whether or not `a` is real/complex. The determinant may be
1586+
either ``+/- 1`` in that case. In case the number of dimensions in the
1587+
input array is greater than 2 then a stack of the matrices with above
1588+
properties is returned.
1589+
R : dpnp.ndarray of float or complex, optional
1590+
The upper-triangular matrix or a stack of upper-triangular matrices if
1591+
the number of dimensions in the input array is greater than 2.
1592+
(h, tau) : tuple of dpnp.ndarray of float or complex, optional
1593+
The array `h` contains the Householder reflectors that generate `Q`
1594+
along with `R`. The `tau` array contains scaling factors for the
1595+
reflectors.
15911596
15921597
Examples
15931598
--------
@@ -1726,22 +1731,25 @@ def svd(a, full_matrices=True, compute_uv=True, hermitian=False):
17261731
17271732
Returns
17281733
-------
1729-
u : { (…, M, M), (…, M, K) } dpnp.ndarray
1734+
When `compute_uv` is ``True``, the result is a namedtuple with the
1735+
following attribute names:
1736+
1737+
U : { (…, M, M), (…, M, K) } dpnp.ndarray
17301738
Unitary matrix, where M is the number of rows of the input array `a`.
1731-
The shape of the matrix `u` depends on the value of `full_matrices`.
1732-
If `full_matrices` is ``True``, `u` has the shape (…, M, M).
1733-
If `full_matrices` is ``False``, `u` has the shape (…, M, K), where
1734-
K = min(M, N), and N is the number of columns of the input array `a`.
1735-
If `compute_uv` is ``False``, neither `u` or `Vh` are computed.
1736-
s : (…, K) dpnp.ndarray
1739+
The shape of the matrix `U` depends on the value of `full_matrices`.
1740+
If `full_matrices` is ``True``, `U` has the shape (…, M, M). If
1741+
`full_matrices` is ``False``, `U` has the shape (…, M, K), where
1742+
``K = min(M, N)``, and N is the number of columns of the input array
1743+
`a`. If `compute_uv` is ``False``, neither `U` or `Vh` are computed.
1744+
S : (…, K) dpnp.ndarray
17371745
Vector containing the singular values of `a`, sorted in descending
1738-
order. The length of `s` is min(M, N).
1746+
order. The length of `S` is min(M, N).
17391747
Vh : { (…, N, N), (…, K, N) } dpnp.ndarray
17401748
Unitary matrix, where N is the number of columns of the input array `a`.
17411749
The shape of the matrix `Vh` depends on the value of `full_matrices`.
17421750
If `full_matrices` is ``True``, `Vh` has the shape (…, N, N).
17431751
If `full_matrices` is ``False``, `Vh` has the shape (…, K, N).
1744-
If `compute_uv` is ``False``, neither `u` or `Vh` are computed.
1752+
If `compute_uv` is ``False``, neither `U` or `Vh` are computed.
17451753
17461754
Examples
17471755
--------
@@ -1869,6 +1877,8 @@ def slogdet(a):
18691877
18701878
Returns
18711879
-------
1880+
A namedtuple with the following attributes:
1881+
18721882
sign : (...) dpnp.ndarray
18731883
A number representing the sign of the determinant. For a real matrix,
18741884
this is 1, 0, or -1. For a complex matrix, this is a complex number

0 commit comments

Comments
 (0)