From 3fd720d5162e1b6869f1df4688c2906f52fa52c5 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 5 Mar 2026 13:05:04 +0100 Subject: [PATCH 1/4] Fix parameter type annotations in scipy.linalg LU functions Change parameter types from `{None, bool}` to `bool` for overwrite_a, check_finite, and overwrite_b parameters to match SciPy's documentation. These parameters are boolean flags that do not accept None as a valid value according to the documented API. Co-Authored-By: Claude Sonnet 4.5 --- dpnp/scipy/linalg/_decomp_lu.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dpnp/scipy/linalg/_decomp_lu.py b/dpnp/scipy/linalg/_decomp_lu.py index 823b2fccc23..d07e722060a 100644 --- a/dpnp/scipy/linalg/_decomp_lu.py +++ b/dpnp/scipy/linalg/_decomp_lu.py @@ -77,11 +77,11 @@ def lu( Perform the multiplication ``P @ L`` (Default: do not permute). Default: ``False``. - overwrite_a : {None, bool}, optional + overwrite_a : bool, optional Whether to overwrite data in `a` (may increase performance). Default: ``False``. - check_finite : {None, bool}, optional + check_finite : bool, optional Whether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. @@ -211,11 +211,11 @@ def lu_factor(a, overwrite_a=False, check_finite=True): ---------- a : (..., M, N) {dpnp.ndarray, usm_ndarray} Input array to decompose. - overwrite_a : {None, bool}, optional + overwrite_a : bool, optional Whether to overwrite data in `a` (may increase performance). Default: ``False``. - check_finite : {None, bool}, optional + check_finite : bool, optional Whether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. @@ -286,11 +286,11 @@ def lu_solve(lu_and_piv, b, trans=0, overwrite_b=False, check_finite=True): ===== ================= Default: ``0``. - overwrite_b : {None, bool}, optional + overwrite_b : bool, optional Whether to overwrite data in `b` (may increase performance). Default: ``False``. - check_finite : {None, bool}, optional + check_finite : bool, optional Whether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. From b9a9f42f5540f21b3e5e47d53bfc0877453507da Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 5 Mar 2026 13:05:33 +0100 Subject: [PATCH 2/4] Standardize docstring section header to 'Warnings' Change 'Warning' to 'Warnings' (plural) in docstring section headers across multiple modules to follow NumPy/SciPy documentation style guide. Files modified: - dpnp/scipy/linalg/_decomp_lu.py (3 functions) - dpnp/dpnp_iface_histograms.py (5 functions) - dpnp/dpnp_iface_manipulation.py (2 functions) - dpnp/dpnp_iface_nanfunctions.py (4 functions) Co-Authored-By: Claude Sonnet 4.5 --- dpnp/dpnp_iface_histograms.py | 20 ++++++++++---------- dpnp/dpnp_iface_manipulation.py | 8 ++++---- dpnp/dpnp_iface_nanfunctions.py | 16 ++++++++-------- dpnp/scipy/linalg/_decomp_lu.py | 12 ++++++------ 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/dpnp/dpnp_iface_histograms.py b/dpnp/dpnp_iface_histograms.py index 8f3363e79fe..0a2f18fe364 100644 --- a/dpnp/dpnp_iface_histograms.py +++ b/dpnp/dpnp_iface_histograms.py @@ -306,8 +306,8 @@ def bincount(x, weights=None, minlength=0): For full documentation refer to :obj:`numpy.bincount`. - Warning - ------- + Warnings + -------- This function synchronizes in order to calculate binning edges. This may harm performance in some applications. @@ -504,8 +504,8 @@ def histogram(a, bins=10, range=None, density=None, weights=None): For full documentation refer to :obj:`numpy.histogram`. - Warning - ------- + Warnings + -------- This function may synchronize in order to check a monotonically increasing array of bin edges. This may harm performance in some applications. @@ -675,8 +675,8 @@ def histogram_bin_edges(a, bins=10, range=None, weights=None): For full documentation refer to :obj:`numpy.histogram_bin_edges`. - Warning - ------- + Warnings + -------- This function may synchronize in order to check a monotonically increasing array of bin edges. This may harm performance in some applications. @@ -767,8 +767,8 @@ def histogram2d(x, y, bins=10, range=None, density=None, weights=None): For full documentation refer to :obj:`numpy.histogram2d`. - Warning - ------- + Warnings + -------- This function may synchronize in order to check a monotonically increasing array of bin edges. This may harm performance in some applications. @@ -1100,8 +1100,8 @@ def histogramdd(sample, bins=10, range=None, density=None, weights=None): For full documentation refer to :obj:`numpy.histogramdd`. - Warning - ------- + Warnings + -------- This function may synchronize in order to check a monotonically increasing array of bin edges. This may harm performance in some applications. diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index ff7ac85666a..0594a406ac5 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -829,8 +829,8 @@ def asfarray(a, dtype=None, *, device=None, usm_type=None, sycl_queue=None): out : dpnp.ndarray The input `a` as a float ndarray. - Warning - ------- + Warnings + -------- This function is deprecated in favor of :obj:`dpnp.asarray` and will be removed in a future release. @@ -3099,8 +3099,8 @@ def resize(a, new_shape): be used. In most other cases either indexing (to reduce the size) or padding (to increase the size) may be a more appropriate solution. - Warning - ------- + Warnings + -------- This functionality does **not** consider axes separately, i.e. it does not apply interpolation/extrapolation. It fills the return array with the required number of elements, iterating diff --git a/dpnp/dpnp_iface_nanfunctions.py b/dpnp/dpnp_iface_nanfunctions.py index b8abad2a208..a5fb750cf58 100644 --- a/dpnp/dpnp_iface_nanfunctions.py +++ b/dpnp/dpnp_iface_nanfunctions.py @@ -122,15 +122,15 @@ def nanargmax(a, axis=None, out=None, *, keepdims=False): For full documentation refer to :obj:`numpy.nanargmax`. - Warning - ------- + Warnings + -------- This function synchronizes in order to test for all-NaN slices in the array. This may harm performance in some applications. To avoid synchronization, the user is recommended to filter NaNs themselves and use `dpnp.argmax` on the filtered array. - Warning - ------- + Warnings + -------- The results cannot be trusted if a slice contains only NaNs and -Infs. @@ -206,15 +206,15 @@ def nanargmin(a, axis=None, out=None, *, keepdims=False): For full documentation refer to :obj:`numpy.nanargmin`. - Warning - ------- + Warnings + -------- This function synchronizes in order to test for all-NaN slices in the array. This may harm performance in some applications. To avoid synchronization, the user is recommended to filter NaNs themselves and use `dpnp.argmax` on the filtered array. - Warning - ------- + Warnings + -------- The results cannot be trusted if a slice contains only NaNs and -Infs. diff --git a/dpnp/scipy/linalg/_decomp_lu.py b/dpnp/scipy/linalg/_decomp_lu.py index d07e722060a..2d7d88fd466 100644 --- a/dpnp/scipy/linalg/_decomp_lu.py +++ b/dpnp/scipy/linalg/_decomp_lu.py @@ -130,8 +130,8 @@ def lu( permutation matrix is still needed then it can be constructed by ``dpnp.eye(M)[P, :]``. - Warning - ------- + Warnings + -------- This function synchronizes in order to validate array elements when ``check_finite=True``, and also synchronizes to compute the permutation from LAPACK pivot indices. @@ -233,8 +233,8 @@ def lu_factor(a, overwrite_a=False, check_finite=True): row i of matrix was interchanged with row piv[i]. Where ``K = min(M, N)``. - Warning - ------- + Warnings + -------- This function synchronizes in order to validate array elements when ``check_finite=True``. @@ -302,8 +302,8 @@ def lu_solve(lu_and_piv, b, trans=0, overwrite_b=False, check_finite=True): x : {(M,), (..., M, K)} dpnp.ndarray Solution to the system - Warning - ------- + Warnings + -------- This function synchronizes in order to validate array elements when ``check_finite=True``. From 430186112d81d259094e57b9ec6de619f19dee0d Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 5 Mar 2026 13:06:11 +0100 Subject: [PATCH 3/4] Use :func: role for function cross-references Change :obj: to :func: for function references in See Also sections to be more semantically correct according to Sphinx documentation conventions. Updated 5 function cross-references in scipy.linalg._decomp_lu module. Co-Authored-By: Claude Sonnet 4.5 --- dpnp/scipy/linalg/_decomp_lu.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dpnp/scipy/linalg/_decomp_lu.py b/dpnp/scipy/linalg/_decomp_lu.py index 2d7d88fd466..54fab0ad756 100644 --- a/dpnp/scipy/linalg/_decomp_lu.py +++ b/dpnp/scipy/linalg/_decomp_lu.py @@ -138,10 +138,10 @@ def lu( See Also -------- - :obj:`dpnp.scipy.linalg.lu_factor` : LU factorize a matrix - (compact representation). - :obj:`dpnp.scipy.linalg.lu_solve` : Solve an equation system using - the LU factorization of a matrix. + :func:`dpnp.scipy.linalg.lu_factor` : LU factorize a matrix + (compact representation). + :func:`dpnp.scipy.linalg.lu_solve` : Solve an equation system using + the LU factorization of a matrix. Examples -------- @@ -240,8 +240,8 @@ def lu_factor(a, overwrite_a=False, check_finite=True): See Also -------- - :obj:`dpnp.scipy.linalg.lu_solve` : Solve an equation system using - the LU factorization of `a` matrix. + :func:`dpnp.scipy.linalg.lu_solve` : Solve an equation system using + the LU factorization of `a` matrix. Examples -------- @@ -309,7 +309,7 @@ def lu_solve(lu_and_piv, b, trans=0, overwrite_b=False, check_finite=True): See Also -------- - :obj:`dpnp.scipy.linalg.lu_factor` : LU factorize a matrix. + :func:`dpnp.scipy.linalg.lu_factor` : LU factorize a matrix. Examples -------- From 5b4c119e48a9532658c05d5cf758b3a121ec40da Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 5 Mar 2026 13:07:22 +0100 Subject: [PATCH 4/4] Improve Returns section formatting in lu function Replace bold asterisk formatting with clearer conditional returns documentation: - Add explanatory sentence about tuple returns based on permute_l - List all return values (p, l, pl, u) at the top level for Napoleon - Maintain clear structure: explanation first, then "where:" with details Also add missing period to parameter description in lu_solve. This ensures proper Sphinx/Napoleon rendering while keeping the clear explanation of which tuples are returned. Co-Authored-By: Claude Sonnet 4.5 --- dpnp/scipy/linalg/_decomp_lu.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/dpnp/scipy/linalg/_decomp_lu.py b/dpnp/scipy/linalg/_decomp_lu.py index 54fab0ad756..f96d56b0e42 100644 --- a/dpnp/scipy/linalg/_decomp_lu.py +++ b/dpnp/scipy/linalg/_decomp_lu.py @@ -95,23 +95,19 @@ def lu( Returns ------- - **(If ``permute_l`` is ``False``)** + The tuple ``(p, l, u)`` is returned if ``permute_l`` is ``False`` + (default), else the tuple ``(pl, u)`` is returned, where: p : (..., M, M) dpnp.ndarray or (..., M) dpnp.ndarray - If `p_indices` is ``False`` (default), the permutation matrix. - The permutation matrix always has a real dtype (``float32`` or - ``float64``) even when `a` is complex, since it only contains - 0s and 1s. + Permutation matrix or permutation indices. + If `p_indices` is ``False`` (default), a permutation matrix. + The permutation matrix always has a real-valued floating-point dtype + even when `a` is complex, since it only contains 0s and 1s. If `p_indices` is ``True``, a 1-D (or batched) array of row permutation indices such that ``A = L[p] @ U``. l : (..., M, K) dpnp.ndarray Lower triangular or trapezoidal matrix with unit diagonal. ``K = min(M, N)``. - u : (..., K, N) dpnp.ndarray - Upper triangular or trapezoidal matrix. - - **(If ``permute_l`` is ``True``)** - pl : (..., M, K) dpnp.ndarray Permuted ``L`` matrix: ``pl = P @ L``. ``K = min(M, N)``. @@ -273,7 +269,7 @@ def lu_solve(lu_and_piv, b, trans=0, overwrite_b=False, check_finite=True): lu, piv : {tuple of dpnp.ndarrays or usm_ndarrays} LU factorization of matrix `a` (..., M, M) together with pivot indices. b : {(M,), (..., M, K)} {dpnp.ndarray, usm_ndarray} - Right-hand side + Right-hand side. trans : {0, 1, 2} , optional Type of system to solve: