Skip to content

Commit 277af03

Browse files
committed
🏷️ stub numpy.linalg._umath_linalg
1 parent cd27c27 commit 277af03

File tree

2 files changed

+202
-11
lines changed

2 files changed

+202
-11
lines changed

src/numpy-stubs/_typing/_ufunc.pyi

Lines changed: 142 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ class _Kwargs3(_KwargsCommon, total=False):
7575
where: _ArrayLikeBool_co | None
7676
signature: _Tuple3[DTypeLike] | str | None
7777

78-
@type_check_only
79-
class _Kwargs3_g(_KwargsCommon, total=False):
80-
signature: _Tuple3[DTypeLike] | str | None
81-
8278
@type_check_only
8379
class _Kwargs4(_KwargsCommon, total=False):
8480
where: _ArrayLikeBool_co | None
@@ -94,6 +90,18 @@ class _Kwargs4_(_KwargsCommon, total=False):
9490
where: _ArrayLikeBool_co | None
9591
signature: _Tuple4_[DTypeLike] | str | None
9692

93+
@type_check_only
94+
class _Kwargs2_g(_KwargsCommon, total=False):
95+
signature: _Tuple2[DTypeLike] | str | None
96+
axes: Sequence[_Tuple2[SupportsIndex]]
97+
axis: SupportsIndex
98+
99+
@type_check_only
100+
class _Kwargs3_g(_KwargsCommon, total=False):
101+
signature: _Tuple3[DTypeLike] | str | None
102+
axes: Sequence[_Tuple2[SupportsIndex]]
103+
axis: SupportsIndex
104+
97105
###
98106
# ufunc method signatures
99107

@@ -592,9 +600,119 @@ class _Call22(Protocol):
592600
**kwds: Unpack[_Kwargs4],
593601
) -> _Tuple2[Any]: ...
594602

603+
@type_check_only
604+
class _Call11_g(Protocol):
605+
@overload
606+
def __call__(
607+
self,
608+
x: ArrayLike,
609+
/,
610+
out: _Out1[_ArrayT],
611+
*,
612+
dtype: None = None,
613+
**kwds: Unpack[_Kwargs2_g],
614+
) -> _ArrayT: ...
615+
@overload
616+
def __call__(
617+
self,
618+
x: ArrayLike,
619+
/,
620+
out: _Out1[_AnyArray | None] = None,
621+
*,
622+
dtype: DTypeLike | None = None,
623+
**kwds: Unpack[_Kwargs2_g],
624+
) -> Any: ...
625+
626+
@type_check_only
627+
class _Call12_g(Protocol):
628+
@overload
629+
def __call__(
630+
self,
631+
x: ArrayLike,
632+
out1: None = None,
633+
out2: None = None,
634+
/,
635+
out: _Tuple2[None] = (None, None),
636+
*,
637+
dtype: DTypeLike | None = None,
638+
**kwds: Unpack[_Kwargs3_g],
639+
) -> tuple[Any, Any]: ...
640+
@overload
641+
def __call__(
642+
self,
643+
x: ArrayLike,
644+
out1: None = None,
645+
out2: None = None,
646+
/,
647+
*,
648+
out: tuple[None, _ArrayT2],
649+
dtype: None = None,
650+
**kwds: Unpack[_Kwargs3_g],
651+
) -> tuple[Any, _ArrayT2]: ...
652+
@overload
653+
def __call__(
654+
self,
655+
x: ArrayLike,
656+
out1: None = None,
657+
out2: None = None,
658+
/,
659+
*,
660+
out: tuple[_ArrayT1, None],
661+
dtype: None = None,
662+
**kwds: Unpack[_Kwargs3_g],
663+
) -> tuple[_ArrayT1, Any]: ...
664+
@overload
665+
def __call__(
666+
self,
667+
x: ArrayLike,
668+
out1: None = None,
669+
out2: None = None,
670+
/,
671+
*,
672+
out: tuple[_ArrayT1, _ArrayT2],
673+
dtype: None = None,
674+
**kwds: Unpack[_Kwargs3_g],
675+
) -> tuple[_ArrayT1, _ArrayT2]: ...
676+
@overload
677+
def __call__(
678+
self,
679+
x: ArrayLike,
680+
out1: None,
681+
out2: _ArrayT2,
682+
/,
683+
*,
684+
out: _Tuple2[None] = (None, None),
685+
dtype: None = None,
686+
**kwds: Unpack[_Kwargs3_g],
687+
) -> tuple[Any, _ArrayT2]: ...
688+
@overload
689+
def __call__(
690+
self,
691+
x: ArrayLike,
692+
out1: _ArrayT1,
693+
out2: None,
694+
/,
695+
*,
696+
out: _Tuple2[None] = (None, None),
697+
dtype: None = None,
698+
**kwds: Unpack[_Kwargs3_g],
699+
) -> tuple[_ArrayT1, Any]: ...
700+
@overload
701+
def __call__(
702+
self,
703+
x: ArrayLike,
704+
out1: _ArrayT1,
705+
out2: _ArrayT2,
706+
/,
707+
*,
708+
out: _Tuple2[None] = (None, None),
709+
dtype: None = None,
710+
**kwds: Unpack[_Kwargs3_g],
711+
) -> tuple[_ArrayT1, _ArrayT2]: ...
712+
595713
@type_check_only
596714
class _Call21_g(Protocol):
597-
# Scalar for 1D array-likes; ndarray otherwise
715+
# scalar for 1D array-likes; ndarray otherwise
598716
@overload
599717
def __call__(
600718
self,
@@ -604,8 +722,6 @@ class _Call21_g(Protocol):
604722
out: _Out1[_ArrayT],
605723
*,
606724
dtype: None = None,
607-
axis: SupportsIndex = ...,
608-
axes: Sequence[_Tuple2[SupportsIndex]] = ...,
609725
**kwds: Unpack[_Kwargs3_g],
610726
) -> _ArrayT: ...
611727
@overload
@@ -617,8 +733,6 @@ class _Call21_g(Protocol):
617733
out: _Out1[_AnyArray | None] = None,
618734
*,
619735
dtype: DTypeLike | None = None,
620-
axis: SupportsIndex = ...,
621-
axes: Sequence[_Tuple2[SupportsIndex]] = ...,
622736
**kwds: Unpack[_Kwargs3_g],
623737
) -> Any: ...
624738

@@ -1074,7 +1188,6 @@ _CallT11 = TypeVar("_CallT11", bound=Callable[Concatenate[Any, ...], object], de
10741188
_CallT12 = TypeVar("_CallT12", bound=Callable[Concatenate[Any, ...], tuple[object, object]], default=_Call12)
10751189
_CallT21 = TypeVar("_CallT21", bound=Callable[Concatenate[Any, Any, ...], object], default=_Call21)
10761190
_CallT22 = TypeVar("_CallT22", bound=Callable[Concatenate[Any, Any, ...], tuple[object, object]], default=_Call22)
1077-
_CallT21G = TypeVar("_CallT21G", bound=Callable[Concatenate[Any, ...], object], default=_Call21_g)
10781191

10791192
_ufunc_1_1 = TypeAliasType(
10801193
"_ufunc_1_1",
@@ -1097,12 +1210,30 @@ _ufunc_2_2 = TypeAliasType(
10971210
type_params=(_CallT22,),
10981211
)
10991212

1213+
#
1214+
1215+
_CallT11G = TypeVar("_CallT11G", bound=Callable[Concatenate[Any, ...], object], default=_Call11_g)
1216+
_CallT12G = TypeVar("_CallT12G", bound=Callable[Concatenate[Any, ...], object], default=_Call12_g)
1217+
_CallT21G = TypeVar("_CallT21G", bound=Callable[Concatenate[Any, ...], object], default=_Call21_g)
1218+
1219+
_gufunc_1_1 = TypeAliasType(
1220+
"_gufunc_1_1",
1221+
np.ufunc[_CallT11G, _AtE, _ReduceE, _ReduceAtE, _AccumulateE, _OuterE],
1222+
type_params=(_CallT11G,),
1223+
)
1224+
_gufunc_1_2 = TypeAliasType(
1225+
"_gufunc_1_2",
1226+
np.ufunc[_CallT12G, _AtE, _ReduceE, _ReduceAtE, _AccumulateE, _OuterE],
1227+
type_params=(_CallT12G,),
1228+
)
11001229
_gufunc_2_1 = TypeAliasType(
11011230
"_gufunc_2_1",
1102-
np.ufunc[_CallT21G, _AtE, _ReduceE, _ReduceAtE, _AccumulateE, _Outer2],
1231+
np.ufunc[_CallT21G, _AtE, _ReduceE, _ReduceAtE, _AccumulateE, _Outer1],
11031232
type_params=(_CallT21G,),
11041233
)
11051234

1235+
#
1236+
11061237
_pyfunc_1_1 = TypeAliasType(
11071238
"_pyfunc_1_1",
11081239
np.ufunc[_Call11_py[_OutT], _At1, _ReduceE, _ReduceAtE, _AccumulateE, _OuterE],
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from typing import Final
2+
3+
import numpy as np
4+
from numpy._typing._ufunc import _gufunc_1_1, _gufunc_1_2, _gufunc_2_1
5+
6+
__version__: Final[str] = ...
7+
_ilp64: Final[bool] = ...
8+
9+
###
10+
# 1 -> 1
11+
12+
# (m,m) -> ()
13+
det: Final[_gufunc_1_1] = ...
14+
# (m,m) -> (m)
15+
cholesky_lo: Final[_gufunc_1_1] = ...
16+
cholesky_up: Final[_gufunc_1_1] = ...
17+
eigvals: Final[_gufunc_1_1] = ...
18+
eigvalsh_lo: Final[_gufunc_1_1] = ...
19+
eigvalsh_up: Final[_gufunc_1_1] = ...
20+
# (m,m) -> (m,m)
21+
inv: Final[_gufunc_1_1] = ...
22+
# (m,n) -> (p)
23+
qr_r_raw: Final[_gufunc_1_1] = ...
24+
svd: Final[_gufunc_1_1] = ...
25+
26+
###
27+
# 1 -> 2
28+
29+
# (m,m) -> (), ()
30+
slogdet: Final[_gufunc_1_2] = ...
31+
# (m,m) -> (m), (m,m)
32+
eig: Final[_gufunc_1_2] = ...
33+
eigh_lo: Final[_gufunc_1_2] = ...
34+
eigh_up: Final[_gufunc_1_2] = ...
35+
36+
###
37+
# 2 -> 1
38+
39+
# (m,n), (n) -> (m,m)
40+
qr_complete: Final[_gufunc_2_1] = ...
41+
# (m,n), (k) -> (m,k)
42+
qr_reduced: Final[_gufunc_2_1] = ...
43+
# (m,m), (m,n) -> (m,n)
44+
solve: Final[_gufunc_2_1] = ...
45+
# (m,m), (m) -> (m)
46+
solve1: Final[_gufunc_2_1] = ...
47+
48+
###
49+
# 1 -> 3
50+
51+
# (m,n) -> (m,m), (p), (n,n)
52+
svd_f: Final[np.ufunc] = ...
53+
# (m,n) -> (m,p), (p), (p,n)
54+
svd_s: Final[np.ufunc] = ...
55+
56+
###
57+
# 3 -> 4
58+
59+
# (m,n), (m,k), () -> (n,k), (k), (), (p)
60+
lstsq: Final[np.ufunc] = ...

0 commit comments

Comments
 (0)