Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/numpy-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ from ._typing import (
_ArrayLikeObject_co,
_ArrayLikeTD64_co,
_DTypeLike,
_DTypeLikeVoid,
_NestedSequence,
_NumberLike_co,
_ScalarLike_co,
Expand Down Expand Up @@ -5025,7 +5024,7 @@ class void(flexible[bytes | tuple[Any, ...]]): # type: ignore[misc] # pyright:
@overload
def __new__(cls, length_or_data: _nt.CoInteger_0d | bytes, /, dtype: None = None) -> Self: ...
@overload
def __new__(cls, length_or_data: object, /, dtype: _DTypeLikeVoid) -> Self: ...
def __new__(cls, length_or_data: object, /, dtype: _nt.ToDTypeVoid) -> Self: ...

#
@type_check_only
Expand Down
41 changes: 21 additions & 20 deletions src/numpy-stubs/_core/einsumfunc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ from numpy._typing import (
_ArrayLikeInt_co,
_ArrayLikeObject_co,
_ArrayLikeUInt_co,
_DTypeLikeBool,
_DTypeLikeComplex,
_DTypeLikeComplex_co,
_DTypeLikeFloat,
_DTypeLikeInt,
_DTypeLikeObject,
_DTypeLikeUInt,
)

__all__ = ["einsum", "einsum_path"]
Expand All @@ -30,6 +23,14 @@ _OptimizeKind: TypeAlias = bool | Literal["greedy", "optimal"] | Sequence[str |
_CastingSafe: TypeAlias = Literal["no", "equiv", "safe", "same_kind", "same_value"]
_CastingUnsafe: TypeAlias = Literal["unsafe"]

_ToDTypeUInt: TypeAlias = (
_nt.ToDTypeUInt8 | _nt.ToDTypeUInt16 | _nt.ToDTypeUInt32 | _nt.ToDTypeUInt64 | _nt.ToDTypeULong
)
_ToDTypeInt: TypeAlias = _nt.ToDTypeInt8 | _nt.ToDTypeInt16 | _nt.ToDTypeInt32 | _nt.ToDTypeInt64 | _nt.ToDTypeLong
_ToDTypeFloat: TypeAlias = _nt.ToDTypeFloat16 | _nt.ToDTypeFloat32 | _nt.ToDTypeFloat64 | _nt.ToDTypeLongDouble
_ToDTypeComplex: TypeAlias = _nt.ToDTypeComplex64 | _nt.ToDTypeComplex128 | _nt.ToDTypeCLongDouble
_ToDTypeComplex_co: TypeAlias = _nt.ToDTypeBool | _ToDTypeUInt | _ToDTypeInt | _ToDTypeFloat | _ToDTypeComplex

# TODO: Properly handle the `casting`-based combinatorics
# TODO: We need to evaluate the content `__subscripts` in order
# to identify whether or an array or scalar is returned. At a cursory
Expand All @@ -43,7 +44,7 @@ def einsum(
*operands: _ArrayLikeBool_co,
out: None = None,
optimize: _OptimizeKind = False,
dtype: _DTypeLikeBool | None = None,
dtype: _nt.ToDTypeBool | None = None,
order: _OrderKACF = "K",
casting: _CastingSafe = "safe",
) -> Incomplete: ...
Expand All @@ -53,7 +54,7 @@ def einsum(
/,
*operands: _ArrayLikeUInt_co,
out: None = None,
dtype: _DTypeLikeUInt | None = None,
dtype: _ToDTypeUInt | None = None,
order: _OrderKACF = "K",
casting: _CastingSafe = "safe",
optimize: _OptimizeKind = False,
Expand All @@ -64,7 +65,7 @@ def einsum(
/,
*operands: _ArrayLikeInt_co,
out: None = None,
dtype: _DTypeLikeInt | None = None,
dtype: _ToDTypeInt | None = None,
order: _OrderKACF = "K",
casting: _CastingSafe = "safe",
optimize: _OptimizeKind = False,
Expand All @@ -75,7 +76,7 @@ def einsum(
/,
*operands: _ArrayLikeFloat_co,
out: None = None,
dtype: _DTypeLikeFloat | None = None,
dtype: _ToDTypeFloat | None = None,
order: _OrderKACF = "K",
casting: _CastingSafe = "safe",
optimize: _OptimizeKind = False,
Expand All @@ -86,7 +87,7 @@ def einsum(
/,
*operands: _ArrayLikeComplex_co,
out: None = None,
dtype: _DTypeLikeComplex | None = None,
dtype: _ToDTypeComplex | None = None,
order: _OrderKACF = "K",
casting: _CastingSafe = "safe",
optimize: _OptimizeKind = False,
Expand All @@ -97,7 +98,7 @@ def einsum(
/,
*operands: Any,
casting: _CastingUnsafe,
dtype: _DTypeLikeComplex_co | None = None,
dtype: _ToDTypeComplex_co | None = None,
out: None = None,
order: _OrderKACF = "K",
optimize: _OptimizeKind = False,
Expand All @@ -108,7 +109,7 @@ def einsum(
/,
*operands: _ArrayLikeComplex_co,
out: _ArrayT,
dtype: _DTypeLikeComplex_co | None = None,
dtype: _ToDTypeComplex_co | None = None,
order: _OrderKACF = "K",
casting: _CastingSafe = "safe",
optimize: _OptimizeKind = False,
Expand All @@ -120,7 +121,7 @@ def einsum(
*operands: Any,
out: _ArrayT,
casting: _CastingUnsafe,
dtype: _DTypeLikeComplex_co | None = None,
dtype: _ToDTypeComplex_co | None = None,
order: _OrderKACF = "K",
optimize: _OptimizeKind = False,
) -> _ArrayT: ...
Expand All @@ -130,7 +131,7 @@ def einsum(
/,
*operands: _ArrayLikeObject_co,
out: None = None,
dtype: _DTypeLikeObject | None = None,
dtype: _nt.ToDTypeObject | None = None,
order: _OrderKACF = "K",
casting: _CastingSafe = "safe",
optimize: _OptimizeKind = False,
Expand All @@ -141,7 +142,7 @@ def einsum(
/,
*operands: Any,
casting: _CastingUnsafe,
dtype: _DTypeLikeObject | None = None,
dtype: _nt.ToDTypeObject | None = None,
out: None = None,
order: _OrderKACF = "K",
optimize: _OptimizeKind = False,
Expand All @@ -152,7 +153,7 @@ def einsum(
/,
*operands: _ArrayLikeObject_co,
out: _ArrayT,
dtype: _DTypeLikeObject | None = None,
dtype: _nt.ToDTypeObject | None = None,
order: _OrderKACF = "K",
casting: _CastingSafe = "safe",
optimize: _OptimizeKind = False,
Expand All @@ -164,7 +165,7 @@ def einsum(
*operands: Any,
out: _ArrayT,
casting: _CastingUnsafe,
dtype: _DTypeLikeObject | None = None,
dtype: _nt.ToDTypeObject | None = None,
order: _OrderKACF = "K",
optimize: _OptimizeKind = False,
) -> _ArrayT: ...
Expand All @@ -175,7 +176,7 @@ def einsum(
def einsum_path(
subscripts: str | _ArrayLikeInt_co,
/,
*operands: _ArrayLikeComplex_co | _DTypeLikeObject,
*operands: _ArrayLikeComplex_co | _nt.ToDTypeObject,
optimize: _OptimizeKind = "greedy",
einsum_call: L[False] = False,
) -> tuple[list[str | tuple[int, ...]], str]: ...
Loading