Skip to content

Commit 4b64466

Browse files
authored
Update docstrings for dpnp.scipy.linalg LU functions (#2802)
This PR implements few improvements for LU function in `dpnp.scipy.linalg` namespace: * resolved issue with `Returns` section formatting in `lu` function * changed to proper `func:` role for the functions cross-references in `See also` section * used `Warnings` section name instead of `Warning` * changed `{None, bool}` to `bool` for overwrite_a, check_finite, and overwrite_b parameters
1 parent a2825a1 commit 4b64466

File tree

4 files changed

+48
-52
lines changed

4 files changed

+48
-52
lines changed

dpnp/dpnp_iface_histograms.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ def bincount(x, weights=None, minlength=0):
306306
307307
For full documentation refer to :obj:`numpy.bincount`.
308308
309-
Warning
310-
-------
309+
Warnings
310+
--------
311311
This function synchronizes in order to calculate binning edges.
312312
This may harm performance in some applications.
313313
@@ -504,8 +504,8 @@ def histogram(a, bins=10, range=None, density=None, weights=None):
504504
505505
For full documentation refer to :obj:`numpy.histogram`.
506506
507-
Warning
508-
-------
507+
Warnings
508+
--------
509509
This function may synchronize in order to check a monotonically increasing
510510
array of bin edges. This may harm performance in some applications.
511511
@@ -675,8 +675,8 @@ def histogram_bin_edges(a, bins=10, range=None, weights=None):
675675
676676
For full documentation refer to :obj:`numpy.histogram_bin_edges`.
677677
678-
Warning
679-
-------
678+
Warnings
679+
--------
680680
This function may synchronize in order to check a monotonically increasing
681681
array of bin edges. This may harm performance in some applications.
682682
@@ -767,8 +767,8 @@ def histogram2d(x, y, bins=10, range=None, density=None, weights=None):
767767
768768
For full documentation refer to :obj:`numpy.histogram2d`.
769769
770-
Warning
771-
-------
770+
Warnings
771+
--------
772772
This function may synchronize in order to check a monotonically increasing
773773
array of bin edges. This may harm performance in some applications.
774774
@@ -1100,8 +1100,8 @@ def histogramdd(sample, bins=10, range=None, density=None, weights=None):
11001100
11011101
For full documentation refer to :obj:`numpy.histogramdd`.
11021102
1103-
Warning
1104-
-------
1103+
Warnings
1104+
--------
11051105
This function may synchronize in order to check a monotonically increasing
11061106
array of bin edges. This may harm performance in some applications.
11071107

dpnp/dpnp_iface_manipulation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,8 @@ def asfarray(a, dtype=None, *, device=None, usm_type=None, sycl_queue=None):
829829
out : dpnp.ndarray
830830
The input `a` as a float ndarray.
831831
832-
Warning
833-
-------
832+
Warnings
833+
--------
834834
This function is deprecated in favor of :obj:`dpnp.asarray` and
835835
will be removed in a future release.
836836
@@ -3099,8 +3099,8 @@ def resize(a, new_shape):
30993099
be used. In most other cases either indexing (to reduce the size) or
31003100
padding (to increase the size) may be a more appropriate solution.
31013101
3102-
Warning
3103-
-------
3102+
Warnings
3103+
--------
31043104
This functionality does **not** consider axes separately, i.e. it does not
31053105
apply interpolation/extrapolation.
31063106
It fills the return array with the required number of elements, iterating

dpnp/dpnp_iface_nanfunctions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ def nanargmax(a, axis=None, out=None, *, keepdims=False):
122122
123123
For full documentation refer to :obj:`numpy.nanargmax`.
124124
125-
Warning
126-
-------
125+
Warnings
126+
--------
127127
This function synchronizes in order to test for all-NaN slices in the array.
128128
This may harm performance in some applications. To avoid synchronization,
129129
the user is recommended to filter NaNs themselves and use `dpnp.argmax`
130130
on the filtered array.
131131
132-
Warning
133-
-------
132+
Warnings
133+
--------
134134
The results cannot be trusted if a slice contains only NaNs
135135
and -Infs.
136136
@@ -206,15 +206,15 @@ def nanargmin(a, axis=None, out=None, *, keepdims=False):
206206
207207
For full documentation refer to :obj:`numpy.nanargmin`.
208208
209-
Warning
210-
-------
209+
Warnings
210+
--------
211211
This function synchronizes in order to test for all-NaN slices in the array.
212212
This may harm performance in some applications. To avoid synchronization,
213213
the user is recommended to filter NaNs themselves and use `dpnp.argmax`
214214
on the filtered array.
215215
216-
Warning
217-
-------
216+
Warnings
217+
--------
218218
The results cannot be trusted if a slice contains only NaNs
219219
and -Infs.
220220

dpnp/scipy/linalg/_decomp_lu.py

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ def lu(
7777
Perform the multiplication ``P @ L`` (Default: do not permute).
7878
7979
Default: ``False``.
80-
overwrite_a : {None, bool}, optional
80+
overwrite_a : bool, optional
8181
Whether to overwrite data in `a` (may increase performance).
8282
8383
Default: ``False``.
84-
check_finite : {None, bool}, optional
84+
check_finite : bool, optional
8585
Whether to check that the input matrix contains only finite numbers.
8686
Disabling may give a performance gain, but may result in problems
8787
(crashes, non-termination) if the inputs do contain infinities or NaNs.
@@ -95,23 +95,19 @@ def lu(
9595
9696
Returns
9797
-------
98-
**(If ``permute_l`` is ``False``)**
98+
The tuple ``(p, l, u)`` is returned if ``permute_l`` is ``False``
99+
(default), else the tuple ``(pl, u)`` is returned, where:
99100
100101
p : (..., M, M) dpnp.ndarray or (..., M) dpnp.ndarray
101-
If `p_indices` is ``False`` (default), the permutation matrix.
102-
The permutation matrix always has a real dtype (``float32`` or
103-
``float64``) even when `a` is complex, since it only contains
104-
0s and 1s.
102+
Permutation matrix or permutation indices.
103+
If `p_indices` is ``False`` (default), a permutation matrix.
104+
The permutation matrix always has a real-valued floating-point dtype
105+
even when `a` is complex, since it only contains 0s and 1s.
105106
If `p_indices` is ``True``, a 1-D (or batched) array of row
106107
permutation indices such that ``A = L[p] @ U``.
107108
l : (..., M, K) dpnp.ndarray
108109
Lower triangular or trapezoidal matrix with unit diagonal.
109110
``K = min(M, N)``.
110-
u : (..., K, N) dpnp.ndarray
111-
Upper triangular or trapezoidal matrix.
112-
113-
**(If ``permute_l`` is ``True``)**
114-
115111
pl : (..., M, K) dpnp.ndarray
116112
Permuted ``L`` matrix: ``pl = P @ L``.
117113
``K = min(M, N)``.
@@ -130,18 +126,18 @@ def lu(
130126
permutation matrix is still needed then it can be constructed by
131127
``dpnp.eye(M)[P, :]``.
132128
133-
Warning
134-
-------
129+
Warnings
130+
--------
135131
This function synchronizes in order to validate array elements
136132
when ``check_finite=True``, and also synchronizes to compute the
137133
permutation from LAPACK pivot indices.
138134
139135
See Also
140136
--------
141-
:obj:`dpnp.scipy.linalg.lu_factor` : LU factorize a matrix
142-
(compact representation).
143-
:obj:`dpnp.scipy.linalg.lu_solve` : Solve an equation system using
144-
the LU factorization of a matrix.
137+
:func:`dpnp.scipy.linalg.lu_factor` : LU factorize a matrix
138+
(compact representation).
139+
:func:`dpnp.scipy.linalg.lu_solve` : Solve an equation system using
140+
the LU factorization of a matrix.
145141
146142
Examples
147143
--------
@@ -211,11 +207,11 @@ def lu_factor(a, overwrite_a=False, check_finite=True):
211207
----------
212208
a : (..., M, N) {dpnp.ndarray, usm_ndarray}
213209
Input array to decompose.
214-
overwrite_a : {None, bool}, optional
210+
overwrite_a : bool, optional
215211
Whether to overwrite data in `a` (may increase performance).
216212
217213
Default: ``False``.
218-
check_finite : {None, bool}, optional
214+
check_finite : bool, optional
219215
Whether to check that the input matrix contains only finite numbers.
220216
Disabling may give a performance gain, but may result in problems
221217
(crashes, non-termination) if the inputs do contain infinities or NaNs.
@@ -233,15 +229,15 @@ def lu_factor(a, overwrite_a=False, check_finite=True):
233229
row i of matrix was interchanged with row piv[i].
234230
Where ``K = min(M, N)``.
235231
236-
Warning
237-
-------
232+
Warnings
233+
--------
238234
This function synchronizes in order to validate array elements
239235
when ``check_finite=True``.
240236
241237
See Also
242238
--------
243-
:obj:`dpnp.scipy.linalg.lu_solve` : Solve an equation system using
244-
the LU factorization of `a` matrix.
239+
:func:`dpnp.scipy.linalg.lu_solve` : Solve an equation system using
240+
the LU factorization of `a` matrix.
245241
246242
Examples
247243
--------
@@ -273,7 +269,7 @@ def lu_solve(lu_and_piv, b, trans=0, overwrite_b=False, check_finite=True):
273269
lu, piv : {tuple of dpnp.ndarrays or usm_ndarrays}
274270
LU factorization of matrix `a` (..., M, M) together with pivot indices.
275271
b : {(M,), (..., M, K)} {dpnp.ndarray, usm_ndarray}
276-
Right-hand side
272+
Right-hand side.
277273
trans : {0, 1, 2} , optional
278274
Type of system to solve:
279275
@@ -286,11 +282,11 @@ def lu_solve(lu_and_piv, b, trans=0, overwrite_b=False, check_finite=True):
286282
===== =================
287283
288284
Default: ``0``.
289-
overwrite_b : {None, bool}, optional
285+
overwrite_b : bool, optional
290286
Whether to overwrite data in `b` (may increase performance).
291287
292288
Default: ``False``.
293-
check_finite : {None, bool}, optional
289+
check_finite : bool, optional
294290
Whether to check that the input matrix contains only finite numbers.
295291
Disabling may give a performance gain, but may result in problems
296292
(crashes, non-termination) if the inputs do contain infinities or NaNs.
@@ -302,14 +298,14 @@ def lu_solve(lu_and_piv, b, trans=0, overwrite_b=False, check_finite=True):
302298
x : {(M,), (..., M, K)} dpnp.ndarray
303299
Solution to the system
304300
305-
Warning
306-
-------
301+
Warnings
302+
--------
307303
This function synchronizes in order to validate array elements
308304
when ``check_finite=True``.
309305
310306
See Also
311307
--------
312-
:obj:`dpnp.scipy.linalg.lu_factor` : LU factorize a matrix.
308+
:func:`dpnp.scipy.linalg.lu_factor` : LU factorize a matrix.
313309
314310
Examples
315311
--------

0 commit comments

Comments
 (0)