Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👽️ linalg: 1.15.0 support #344

Merged
merged 9 commits into from
Dec 17, 2024
6 changes: 0 additions & 6 deletions .mypyignore-todo
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
scipy\.linalg\.(_basic\.)?solve
scipy\.linalg\.(_?decomp_svd\.)?null_space
scipy\.linalg\._matfuncs_expm\.__all__
scipy\.linalg\.(_sketches\.)?clarkson_woodruff_transform
scipy\.linalg\._sketches\.cwt_matrix

scipy\.ndimage\.__all__
scipy\.ndimage\.(_?filters\.)?convolve
scipy\.ndimage\.(_?filters\.)?correlate
Expand Down
108 changes: 87 additions & 21 deletions scipy-stubs/linalg/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,93 @@ from . import (
misc,
special_matrices,
)
from ._basic import *
from ._cythonized_array_utils import *
from ._decomp import *
from ._decomp_cholesky import *
from ._decomp_cossin import *
from ._decomp_ldl import *
from ._decomp_lu import *
from ._decomp_polar import *
from ._decomp_qr import *
from ._decomp_qz import *
from ._decomp_schur import *
from ._decomp_svd import *
from ._decomp_update import *
from ._matfuncs import *
from ._misc import *
from ._procrustes import *
from ._sketches import *
from ._solvers import *
from ._special_matrices import *
from .blas import *
from .lapack import *
from ._basic import (
det,
inv,
lstsq,
matmul_toeplitz,
matrix_balance,
pinv,
pinvh,
solve,
solve_banded,
solve_circulant,
solve_toeplitz,
solve_triangular,
solveh_banded,
)
from ._cythonized_array_utils import bandwidth, ishermitian, issymmetric
from ._decomp import (
cdf2rdf,
eig,
eig_banded,
eigh,
eigh_tridiagonal,
eigvals,
eigvals_banded,
eigvalsh,
eigvalsh_tridiagonal,
hessenberg,
)
from ._decomp_cholesky import cho_factor, cho_solve, cho_solve_banded, cholesky, cholesky_banded
from ._decomp_cossin import cossin
from ._decomp_ldl import ldl
from ._decomp_lu import lu, lu_factor, lu_solve
from ._decomp_polar import polar
from ._decomp_qr import qr, qr_multiply, rq
from ._decomp_qz import ordqz, qz
from ._decomp_schur import rsf2csf, schur
from ._decomp_svd import diagsvd, null_space, orth, subspace_angles, svd, svdvals
from ._decomp_update import qr_delete, qr_insert, qr_update
from ._matfuncs import (
coshm,
cosm,
expm,
expm_cond,
expm_frechet,
fractional_matrix_power,
funm,
khatri_rao,
logm,
signm,
sinhm,
sinm,
sqrtm,
tanhm,
tanm,
)
from ._misc import LinAlgError, LinAlgWarning, norm
from ._procrustes import orthogonal_procrustes
from ._sketches import clarkson_woodruff_transform
from ._solvers import (
solve_continuous_are,
solve_continuous_lyapunov,
solve_discrete_are,
solve_discrete_lyapunov,
solve_lyapunov,
solve_sylvester,
)
from ._special_matrices import (
block_diag,
circulant,
companion,
convolution_matrix,
dft,
fiedler,
fiedler_companion,
hadamard,
hankel,
helmert,
hilbert,
invhilbert,
invpascal,
kron,
leslie,
pascal,
toeplitz,
)
from .blas import find_best_blas_type, get_blas_funcs
from .lapack import get_lapack_funcs

__all__ = [
"LinAlgError",
Expand Down
16 changes: 13 additions & 3 deletions scipy-stubs/linalg/_basic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ _Complex1D: TypeAlias = onp.Array1D[_Complex]
_Complex2D: TypeAlias = onp.Array2D[_Complex]
_ComplexND: TypeAlias = onp.ArrayND[_Complex]

_AssumeA: TypeAlias = Literal["gen", "sym", "her", "pos"]
_AssumeA: TypeAlias = Literal[
"diagonal",
"tridiagonal",
"banded",
"upper triangular",
"lower triangular",
"symmetric", "sym",
"hermitian", "her",
"positive definite", "pos",
"general", "gen",
] # fmt: skip
_TransSystem: TypeAlias = Literal[0, "N", 1, "T", 2, "C"]
_Singular: TypeAlias = Literal["lstsq", "raise"]
_LapackDriver: TypeAlias = Literal["gelsd", "gelsy", "gelss"]
Expand All @@ -55,7 +65,7 @@ def solve(
overwrite_a: onp.ToBool = False,
overwrite_b: onp.ToBool = False,
check_finite: onp.ToBool = True,
assume_a: _AssumeA = "gen",
assume_a: _AssumeA | None = None,
transposed: onp.ToBool = False,
) -> _Float2D: ...
@overload # (complex[:, :], complex[:, :]) -> complex[:, :]
Expand All @@ -66,7 +76,7 @@ def solve(
overwrite_a: onp.ToBool = False,
overwrite_b: onp.ToBool = False,
check_finite: onp.ToBool = True,
assume_a: _AssumeA = "gen",
assume_a: _AssumeA | None = None,
transposed: onp.ToBool = False,
) -> _Complex2D: ...

Expand Down
29 changes: 26 additions & 3 deletions scipy-stubs/linalg/_decomp_svd.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ _ComplexSVD: TypeAlias = tuple[_Complex2D, _Float1D, _Complex2D]
_RealT = TypeVar("_RealT", bound=np.bool_ | np.integer[Any] | np.floating[Any])
_InexactT = TypeVar("_InexactT", bound=_Float | _Complex)

###

@overload
def svd(
a: onp.ToFloat2D,
Expand Down Expand Up @@ -88,11 +90,32 @@ def orth(A: onp.ToComplex2D, rcond: onp.ToFloat | None = None) -> _Inexact2D: ..

#
@overload
def null_space(A: onp.CanArray2D[_InexactT], rcond: onp.ToFloat | None = None) -> onp.Array2D[_InexactT]: ...
def null_space(
A: onp.CanArray2D[_InexactT],
rcond: onp.ToFloat | None = None,
*,
overwrite_a: onp.ToBool = False,
check_finite: onp.ToBool = True,
lapack_driver: _LapackDriver = "gesdd",
) -> onp.Array2D[_InexactT]: ...
@overload
def null_space(A: onp.ToFloat2D, rcond: onp.ToFloat | None = None) -> _Float2D: ...
def null_space(
A: onp.ToFloat2D,
rcond: onp.ToFloat | None = None,
*,
overwrite_a: onp.ToBool = False,
check_finite: onp.ToBool = True,
lapack_driver: _LapackDriver = "gesdd",
) -> _Float2D: ...
@overload
def null_space(A: onp.ToComplex2D, rcond: onp.ToFloat | None = None) -> _Inexact2D: ...
def null_space(
A: onp.ToComplex2D,
rcond: onp.ToFloat | None = None,
*,
overwrite_a: onp.ToBool = False,
check_finite: onp.ToBool = True,
lapack_driver: _LapackDriver = "gesdd",
) -> _Inexact2D: ...

#
def subspace_angles(A: onp.ToComplex2D, B: onp.ToComplex2D) -> _Float1D: ...
8 changes: 5 additions & 3 deletions scipy-stubs/linalg/_matfuncs_expm.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ from typing import TypeAlias
import numpy as np
import optype.numpy as onp

__all__ = ["pade_UV_calc", "pick_pade_structure"]

_Inexact: TypeAlias = np.float32 | np.float64 | np.complex64 | np.complex128

###

class error(Exception): ... # undocumented

# `Am` must have a shape like `(5, n, n)`.
def pick_pade_structure(Am: onp.ArrayND[_Inexact]) -> tuple[int, int]: ...
def pade_UV_calc(Am: onp.ArrayND[_Inexact], n: int, m: int) -> None: ...
def pade_UV_calc(Am: onp.ArrayND[_Inexact], n: int) -> int: ...
9 changes: 5 additions & 4 deletions scipy-stubs/linalg/_sketches.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,29 @@ __all__ = ["clarkson_woodruff_transform"]

_ST = TypeVar("_ST", bound=np.generic)
_VT = TypeVar("_VT")

_ToJust2D: TypeAlias = onp.CanArrayND[_ST] | Sequence[onp.CanArrayND[_ST]] | Sequence[Sequence[opt.Just[_VT] | _ST]]

###

def cwt_matrix(n_rows: onp.ToInt, n_columns: onp.ToInt, seed: spt.ToRNG = None) -> csc_matrix: ...
def cwt_matrix(n_rows: onp.ToInt, n_columns: onp.ToInt, rng: spt.ToRNG = None) -> csc_matrix: ...

#
@overload
def clarkson_woodruff_transform(
input_matrix: onp.ToInt2D,
sketch_size: onp.ToInt,
seed: spt.ToRNG = None,
rng: spt.ToRNG = None,
) -> onp.Array2D[np.int_]: ...
@overload
def clarkson_woodruff_transform(
input_matrix: _ToJust2D[np.floating[Any], float],
sketch_size: onp.ToInt,
seed: spt.ToRNG = None,
rng: spt.ToRNG = None,
) -> onp.Array2D[np.float64 | np.longdouble]: ...
@overload
def clarkson_woodruff_transform(
input_matrix: _ToJust2D[np.complexfloating[Any, Any], complex],
sketch_size: onp.ToInt,
seed: spt.ToRNG = None,
rng: spt.ToRNG = None,
) -> onp.Array2D[np.complex64 | np.clongdouble]: ...
Loading
Loading