diff --git a/src/numpy-stubs/_core/einsumfunc.pyi b/src/numpy-stubs/_core/einsumfunc.pyi index 17d101d2..d1ee7aeb 100644 --- a/src/numpy-stubs/_core/einsumfunc.pyi +++ b/src/numpy-stubs/_core/einsumfunc.pyi @@ -25,6 +25,7 @@ __all__ = ["einsum", "einsum_path"] _ArrayT = TypeVar("_ArrayT", bound=_nt.Array[_nt.co_complex]) +# TODO (@jorenham): Annotate the `Sequence` value (numpy/numtype#724) _OptimizeKind: TypeAlias = bool | Literal["greedy", "optimal"] | Sequence[Incomplete] _CastingSafe: TypeAlias = Literal["no", "equiv", "safe", "same_kind"] _CastingUnsafe: TypeAlias = Literal["unsafe"] @@ -41,7 +42,7 @@ def einsum( /, *operands: _ArrayLikeBool_co, out: None = None, - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, dtype: _DTypeLikeBool | None = None, order: _OrderKACF = "K", casting: _CastingSafe = "safe", @@ -55,7 +56,7 @@ def einsum( dtype: _DTypeLikeUInt | None = None, order: _OrderKACF = "K", casting: _CastingSafe = "safe", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> Incomplete: ... @overload def einsum( @@ -66,7 +67,7 @@ def einsum( dtype: _DTypeLikeInt | None = None, order: _OrderKACF = "K", casting: _CastingSafe = "safe", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> Incomplete: ... @overload def einsum( @@ -77,7 +78,7 @@ def einsum( dtype: _DTypeLikeFloat | None = None, order: _OrderKACF = "K", casting: _CastingSafe = "safe", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> Incomplete: ... @overload def einsum( @@ -88,7 +89,7 @@ def einsum( dtype: _DTypeLikeComplex | None = None, order: _OrderKACF = "K", casting: _CastingSafe = "safe", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> Incomplete: ... @overload def einsum( @@ -99,7 +100,7 @@ def einsum( dtype: _DTypeLikeComplex_co | None = None, out: None = None, order: _OrderKACF = "K", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> Incomplete: ... @overload def einsum( @@ -110,7 +111,7 @@ def einsum( dtype: _DTypeLikeComplex_co | None = None, order: _OrderKACF = "K", casting: _CastingSafe = "safe", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> _ArrayT: ... @overload def einsum( @@ -121,7 +122,7 @@ def einsum( casting: _CastingUnsafe, dtype: _DTypeLikeComplex_co | None = None, order: _OrderKACF = "K", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> _ArrayT: ... @overload def einsum( @@ -132,7 +133,7 @@ def einsum( dtype: _DTypeLikeObject | None = None, order: _OrderKACF = "K", casting: _CastingSafe = "safe", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> Incomplete: ... @overload def einsum( @@ -143,7 +144,7 @@ def einsum( dtype: _DTypeLikeObject | None = None, out: None = None, order: _OrderKACF = "K", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> Incomplete: ... @overload def einsum( @@ -154,7 +155,7 @@ def einsum( dtype: _DTypeLikeObject | None = None, order: _OrderKACF = "K", casting: _CastingSafe = "safe", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> _ArrayT: ... @overload def einsum( @@ -165,13 +166,12 @@ def einsum( casting: _CastingUnsafe, dtype: _DTypeLikeObject | None = None, order: _OrderKACF = "K", - optimize: _OptimizeKind | None = None, + optimize: _OptimizeKind = False, ) -> _ArrayT: ... +# TODO (@jorenham): Annotate the `Sequence` value (numpy/numtype#724) # NOTE: `einsum_call` is a hidden kwarg unavailable for public use. # It is therefore excluded from the signatures below. -# NOTE: In practice the list consists of a `str` (first element) -# and a variable number of integer tuples. def einsum_path( subscripts: str | _ArrayLikeInt_co, /, diff --git a/src/numpy-stubs/_core/fromnumeric.pyi b/src/numpy-stubs/_core/fromnumeric.pyi index bb537d90..12cd0429 100644 --- a/src/numpy-stubs/_core/fromnumeric.pyi +++ b/src/numpy-stubs/_core/fromnumeric.pyi @@ -230,7 +230,7 @@ def matrix_transpose(x: ArrayLike, /) -> _nt.Array[Incomplete]: ... def partition( a: _nt._ToArray_nd[_ScalarT], kth: _nt.ToInteger_nd, - axis: CanIndex | None = None, + axis: CanIndex | None = -1, kind: _PartitionKind = "introselect", order: _Order | None = None, ) -> _nt.Array[_ScalarT]: ... @@ -238,7 +238,7 @@ def partition( def partition( a: ArrayLike, kth: _nt.ToInteger_nd, - axis: CanIndex | None = None, + axis: CanIndex | None = -1, kind: _PartitionKind = "introselect", order: _Order | None = None, ) -> _nt.Array[Incomplete]: ... @@ -266,7 +266,7 @@ def sort( def sort( a: _nt.CanArray0D[_ScalarT], axis: None, - kind: CanIndex | None = -1, + kind: CanIndex | None = None, order: _Order | None = None, *, stable: bool | None = None, diff --git a/src/numpy-stubs/_core/numeric.pyi b/src/numpy-stubs/_core/numeric.pyi index e899bc4e..470fd66e 100644 --- a/src/numpy-stubs/_core/numeric.pyi +++ b/src/numpy-stubs/_core/numeric.pyi @@ -2075,34 +2075,34 @@ def correlate( # @overload -def convolve(a: _nt.ToBool_1d, v: _nt.ToBool_1d, mode: _Mode = "valid") -> _nt.Array1D[np.bool]: ... +def convolve(a: _nt.ToBool_1d, v: _nt.ToBool_1d, mode: _Mode = "full") -> _nt.Array1D[np.bool]: ... @overload -def convolve(a: _nt.ToUInteger_1d, v: _nt.CoUInt64_1d, mode: _Mode = "valid") -> _nt.Array1D[np.unsignedinteger]: ... +def convolve(a: _nt.ToUInteger_1d, v: _nt.CoUInt64_1d, mode: _Mode = "full") -> _nt.Array1D[np.unsignedinteger]: ... @overload -def convolve(a: _nt.CoUInt64_1d, v: _nt.ToUInteger_1d, mode: _Mode = "valid") -> _nt.Array1D[np.unsignedinteger]: ... +def convolve(a: _nt.CoUInt64_1d, v: _nt.ToUInteger_1d, mode: _Mode = "full") -> _nt.Array1D[np.unsignedinteger]: ... @overload -def convolve(a: _nt.ToSInteger_1d, v: _nt.CoInt64_1d, mode: _Mode = "valid") -> _nt.Array1D[np.signedinteger]: ... +def convolve(a: _nt.ToSInteger_1d, v: _nt.CoInt64_1d, mode: _Mode = "full") -> _nt.Array1D[np.signedinteger]: ... @overload -def convolve(a: _nt.CoInt64_1d, v: _nt.ToSInteger_1d, mode: _Mode = "valid") -> _nt.Array1D[np.signedinteger]: ... +def convolve(a: _nt.CoInt64_1d, v: _nt.ToSInteger_1d, mode: _Mode = "full") -> _nt.Array1D[np.signedinteger]: ... @overload -def convolve(a: _nt.ToFloating_1d, v: _nt.CoFloating_1d, mode: _Mode = "valid") -> _nt.Array1D[np.floating]: ... +def convolve(a: _nt.ToFloating_1d, v: _nt.CoFloating_1d, mode: _Mode = "full") -> _nt.Array1D[np.floating]: ... @overload -def convolve(a: _nt.CoFloating_1d, v: _nt.ToFloating_1d, mode: _Mode = "valid") -> _nt.Array1D[np.floating]: ... +def convolve(a: _nt.CoFloating_1d, v: _nt.ToFloating_1d, mode: _Mode = "full") -> _nt.Array1D[np.floating]: ... @overload -def convolve(a: _nt.ToComplex_1d, v: _nt.CoComplex_1d, mode: _Mode = "valid") -> _nt.Array1D[np.complexfloating]: ... +def convolve(a: _nt.ToComplex_1d, v: _nt.CoComplex_1d, mode: _Mode = "full") -> _nt.Array1D[np.complexfloating]: ... @overload -def convolve(a: _nt.CoComplex_1d, v: _nt.ToComplex_1d, mode: _Mode = "valid") -> _nt.Array1D[np.complexfloating]: ... +def convolve(a: _nt.CoComplex_1d, v: _nt.ToComplex_1d, mode: _Mode = "full") -> _nt.Array1D[np.complexfloating]: ... @overload -def convolve(a: _nt.ToTimeDelta_1d, v: _nt.CoTimeDelta_1d, mode: _Mode = "valid") -> _nt.Array1D[np.timedelta64]: ... +def convolve(a: _nt.ToTimeDelta_1d, v: _nt.CoTimeDelta_1d, mode: _Mode = "full") -> _nt.Array1D[np.timedelta64]: ... @overload -def convolve(a: _nt.CoTimeDelta_1d, v: _nt.ToTimeDelta_1d, mode: _Mode = "valid") -> _nt.Array1D[np.timedelta64]: ... +def convolve(a: _nt.CoTimeDelta_1d, v: _nt.ToTimeDelta_1d, mode: _Mode = "full") -> _nt.Array1D[np.timedelta64]: ... @overload -def convolve(a: _nt.ToObject_1d, v: _nt.ToObject_1d, mode: _Mode = "valid") -> _nt.Array1D[np.object_]: ... +def convolve(a: _nt.ToObject_1d, v: _nt.ToObject_1d, mode: _Mode = "full") -> _nt.Array1D[np.object_]: ... @overload def convolve( a: _nt.CoComplex_1d | _nt.CoTimeDelta_1d | _nt.ToObject_1d, v: _nt.CoComplex_1d | _nt.CoTimeDelta_1d | _nt.ToObject_1d, - mode: _Mode = "valid", + mode: _Mode = "full", ) -> _nt.Array1D[Any]: ... #