|
| 1 | +import numpy as np |
1 | 2 | import abc |
2 | 3 | import ctypes as ct |
3 | 4 | import datetime as dt |
@@ -611,6 +612,8 @@ _DT64ItemT = TypeVar("_DT64ItemT", bound=dt.date | int | None) |
611 | 612 | _DT64ItemT_co = TypeVar("_DT64ItemT_co", bound=dt.date | int | None, default=dt.date | int | None, covariant=True) |
612 | 613 | _TD64UnitT = TypeVar("_TD64UnitT", bound=_TD64Unit, default=_TD64Unit) |
613 | 614 |
|
| 615 | +_Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_ScalarT]] |
| 616 | + |
614 | 617 | ### |
615 | 618 | # Type Aliases (for internal use only) |
616 | 619 |
|
@@ -2534,7 +2537,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]): |
2534 | 2537 | # TODO(jorenham): Support the "1d @ 1d -> scalar" case |
2535 | 2538 | # https://github.com/numpy/numtype/issues/197 |
2536 | 2539 | @overload |
2537 | | - def __matmul__(self: NDArray[_NumberT], rhs: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ... |
| 2540 | + def __matmul__(self: _Array1D[_ScalarT], rhs: _Array1D[_ScalarT], /) -> _ScalarT: ... |
2538 | 2541 | @overload |
2539 | 2542 | def __matmul__(self: NDArray[bool_], rhs: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... |
2540 | 2543 | @overload |
@@ -2566,12 +2569,14 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]): |
2566 | 2569 | @overload |
2567 | 2570 | def __matmul__(self: NDArray[bool_ | number], rhs: _ArrayLikeNumber_co, /) -> NDArray[Incomplete]: ... |
2568 | 2571 | @overload |
2569 | | - def __matmul__(self: NDArray[object_], rhs: object, /) -> NDArray[object_]: ... |
| 2572 | + def __matmul__(self: NDArray[object_], rhs: _ArrayLikeObject_co, /) -> NDArray[object_]: ... |
2570 | 2573 | @overload |
2571 | 2574 | def __matmul__(self, rhs: _ArrayLikeObject_co, /) -> NDArray[object_]: ... |
2572 | 2575 |
|
2573 | 2576 | # keep in sync with __matmul__ |
2574 | 2577 | @overload |
| 2578 | + def __rmatmul__(self: _Array1D[_ScalarT], rhs: _Array1D[_ScalarT], /) -> _ScalarT: ... |
| 2579 | + @overload |
2575 | 2580 | def __rmatmul__(self: NDArray[_NumberT], lhs: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ... |
2576 | 2581 | @overload |
2577 | 2582 | def __rmatmul__(self: NDArray[bool_], lhs: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... |
@@ -2604,7 +2609,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]): |
2604 | 2609 | @overload |
2605 | 2610 | def __rmatmul__(self: NDArray[bool_ | number], lhs: _ArrayLikeNumber_co, /) -> NDArray[Incomplete]: ... |
2606 | 2611 | @overload |
2607 | | - def __rmatmul__(self: NDArray[object_], lhs: object, /) -> NDArray[object_]: ... |
| 2612 | + def __rmatmul__(self: NDArray[object_], lhs: _ArrayLikeObject_co, /) -> NDArray[object_]: ... |
2608 | 2613 | @overload |
2609 | 2614 | def __rmatmul__(self, lhs: _ArrayLikeObject_co, /) -> NDArray[object_]: ... |
2610 | 2615 |
|
|
0 commit comments