-
-
Notifications
You must be signed in to change notification settings - Fork 6
🩹 add overload for ndarray.__matmul__
#286
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ from typing import ( | |
) | ||
from typing_extensions import Buffer, CapsuleType, LiteralString, Never, Protocol, Self, TypeVar, Unpack, deprecated, override | ||
|
||
import numpy as np | ||
|
||
from . import ( | ||
__config__ as __config__, | ||
_array_api_info as _array_api_info, | ||
|
@@ -611,6 +613,8 @@ _DT64ItemT = TypeVar("_DT64ItemT", bound=dt.date | int | None) | |
_DT64ItemT_co = TypeVar("_DT64ItemT_co", bound=dt.date | int | None, default=dt.date | int | None, covariant=True) | ||
_TD64UnitT = TypeVar("_TD64UnitT", bound=_TD64Unit, default=_TD64Unit) | ||
|
||
_Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_ScalarT]] | ||
|
||
|
||
### | ||
# Type Aliases (for internal use only) | ||
|
||
|
@@ -2530,9 +2534,8 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]): | |
def __imul__(self: NDArray[complexfloating], rhs: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __imul__(self: NDArray[object_], rhs: object, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ... | ||
|
||
# TODO(jorenham): Support the "1d @ 1d -> scalar" case | ||
# https://github.com/numpy/numtype/issues/197 | ||
@overload | ||
def __matmul__(self: _Array1D[_ScalarT], rhs: _Array1D[_ScalarT], /) -> _ScalarT: ... | ||
|
||
@overload | ||
def __matmul__(self: NDArray[_NumberT], rhs: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ... | ||
@overload | ||
|
@@ -2566,12 +2569,14 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]): | |
@overload | ||
def __matmul__(self: NDArray[bool_ | number], rhs: _ArrayLikeNumber_co, /) -> NDArray[Incomplete]: ... | ||
@overload | ||
def __matmul__(self: NDArray[object_], rhs: object, /) -> NDArray[object_]: ... | ||
def __matmul__(self: NDArray[object_], rhs: _ArrayLikeObject_co, /) -> NDArray[object_]: ... | ||
|
||
@overload | ||
def __matmul__(self, rhs: _ArrayLikeObject_co, /) -> NDArray[object_]: ... | ||
|
||
# keep in sync with __matmul__ | ||
@overload | ||
def __rmatmul__(self: _Array1D[_ScalarT], rhs: _Array1D[_ScalarT], /) -> _ScalarT: ... | ||
|
||
@overload | ||
def __rmatmul__(self: NDArray[_NumberT], lhs: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ... | ||
@overload | ||
def __rmatmul__(self: NDArray[bool_], lhs: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... | ||
|
@@ -2604,7 +2609,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]): | |
@overload | ||
def __rmatmul__(self: NDArray[bool_ | number], lhs: _ArrayLikeNumber_co, /) -> NDArray[Incomplete]: ... | ||
@overload | ||
def __rmatmul__(self: NDArray[object_], lhs: object, /) -> NDArray[object_]: ... | ||
def __rmatmul__(self: NDArray[object_], lhs: _ArrayLikeObject_co, /) -> NDArray[object_]: ... | ||
@overload | ||
def __rmatmul__(self, lhs: _ArrayLikeObject_co, /) -> NDArray[object_]: ... | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.