diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/__init__.pyi | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 5c552e901..610343dc7 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -1877,13 +1877,22 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]): self, *shape: SupportsIndex, order: _OrderACF = ... ) -> ndarray[Any, _DType_co]: ... - def __int__(self) -> int: ... + # Dispatch to the underlying `generic` via protocols + def __int__( + self: ndarray[Any, dtype[SupportsInt]], # type: ignore[type-var] + ) -> int: ... - def __float__(self) -> float: ... + def __float__( + self: ndarray[Any, dtype[SupportsFloat]], # type: ignore[type-var] + ) -> float: ... - def __complex__(self) -> complex: ... + def __complex__( + self: ndarray[Any, dtype[SupportsComplex]], # type: ignore[type-var] + ) -> complex: ... - def __index__(self) -> int: ... + def __index__( + self: ndarray[Any, dtype[SupportsIndex]], # type: ignore[type-var] + ) -> int: ... def __len__(self) -> int: ... def __setitem__(self, key, value): ... @@ -2987,6 +2996,11 @@ class object_(generic): def real(self: _ArraySelf) -> _ArraySelf: ... @property def imag(self: _ArraySelf) -> _ArraySelf: ... + # The 3 protocols below may or may not raise, + # depending on the underlying object + def __int__(self) -> int: ... + def __float__(self) -> float: ... + def __complex__(self) -> complex: ... object0 = object_ |