Skip to content

Commit 4a80fa1

Browse files
committed
🤡 linalg.det: shuffle disjoint overloads to avoid triggering a pyright bug
1 parent 22360ce commit 4a80fa1

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

‎scipy-stubs/linalg/_basic.pyi

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,6 @@ def solve_circulant(
994994
) -> onp.ArrayND[npc.inexact]: ...
995995

996996
#
997-
998997
@overload # 2d bool sequence
999998
def inv(a: Sequence[Sequence[bool]], overwrite_a: bool = False, check_finite: bool = True) -> onp.Array2D[np.float32]: ...
1000999
@overload # Nd bool sequence
@@ -1036,32 +1035,30 @@ def inv(
10361035
a: onp.CanArrayND[np.complex128 | np.clongdouble, _ShapeT], overwrite_a: bool = False, check_finite: bool = True
10371036
) -> onp.ArrayND[np.complex128, _ShapeT]: ...
10381037

1039-
# TODO(jorenham): improve this
1038+
# NOTE: The order of the overloads has been carefully chosen to avoid triggering a Pyright bug.
10401039
@overload # +float64 2d
10411040
def det(a: onp.ToFloat64Strict2D, overwrite_a: bool = False, check_finite: bool = True) -> np.float64: ...
1042-
@overload # +float64 3d
1043-
def det(a: onp.ToFloat64Strict3D, overwrite_a: bool = False, check_finite: bool = True) -> onp.Array1D[np.float64]: ...
1044-
@overload # +float64 ND
1045-
def det(a: onp.ToFloat64_ND, overwrite_a: bool = False, check_finite: bool = True) -> np.float64 | onp.ArrayND[np.float64]: ...
10461041
@overload # complex128 | complex64 2d
10471042
def det(
1048-
a: onp.ToJustComplex128Strict2D | onp.CanArray2D[np.complex64], overwrite_a: bool = False, check_finite: bool = True
1043+
a: onp.ToArrayStrict2D[op.JustComplex, np.complex128 | np.complex64], overwrite_a: bool = False, check_finite: bool = True
10491044
) -> np.complex128: ...
1045+
@overload # +float64 3d
1046+
def det(a: onp.ToFloat64Strict3D, overwrite_a: bool = False, check_finite: bool = True) -> onp.Array1D[np.float64]: ...
10501047
@overload # complex128 | complex64 3d
10511048
def det(
1052-
a: onp.ToJustComplex128Strict3D | onp.CanArray3D[np.complex64], overwrite_a: bool = False, check_finite: bool = True
1049+
a: onp.ToArrayStrict3D[op.JustComplex, np.complex128 | np.complex64], overwrite_a: bool = False, check_finite: bool = True
10531050
) -> onp.Array1D[np.complex128]: ...
1051+
@overload # +float64 ND
1052+
def det(a: onp.ToFloat64_ND, overwrite_a: bool = False, check_finite: bool = True) -> np.float64 | onp.ArrayND[np.float64]: ...
10541053
@overload # complex128 | complex64 Nd
10551054
def det(
1056-
a: onp.ToJustComplex128_ND, overwrite_a: bool = False, check_finite: bool = True
1055+
a: onp.ToArrayND[op.JustComplex, np.complex128 | np.complex64], overwrite_a: bool = False, check_finite: bool = True
10571056
) -> np.complex128 | onp.ArrayND[np.complex128]: ...
10581057
@overload # +complex128 2d
1059-
def det(
1060-
a: onp.ToComplex128Strict2D | onp.CanArray2D[np.complex64], overwrite_a: bool = False, check_finite: bool = True
1061-
) -> np.float64 | np.complex128: ...
1058+
def det(a: onp.ToComplex128Strict2D, overwrite_a: bool = False, check_finite: bool = True) -> np.float64 | np.complex128: ...
10621059
@overload # +complex128 3d
10631060
def det(
1064-
a: onp.ToComplex128Strict3D | onp.CanArray3D[np.complex64], overwrite_a: bool = False, check_finite: bool = True
1061+
a: onp.ToComplex128Strict3D, overwrite_a: bool = False, check_finite: bool = True
10651062
) -> onp.Array1D[np.float64 | np.complex128]: ...
10661063
@overload # +complex128 Nd
10671064
def det(

0 commit comments

Comments
 (0)