summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/__init__.pyi16
1 files changed, 14 insertions, 2 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index 7efe73010..531a46ee6 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -1633,6 +1633,14 @@ _ArrayTD64_co = NDArray[Union[bool_, integer[Any], timedelta64]]
class _SupportsItem(Protocol[_T_co]):
def item(self, __args: Any) -> _T_co: ...
+class _SupportsReal(Protocol[_T_co]):
+ @property
+ def real(self) -> _T_co: ...
+
+class _SupportsImag(Protocol[_T_co]):
+ @property
+ def imag(self) -> _T_co: ...
+
class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
@property
def base(self) -> Optional[ndarray]: ...
@@ -1641,11 +1649,15 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
@property
def size(self) -> int: ...
@property
- def real(self: _ArraySelf) -> _ArraySelf: ...
+ def real(
+ self: NDArray[_SupportsReal[_ScalarType]], # type: ignore[type-var]
+ ) -> ndarray[_ShapeType, dtype[_ScalarType]]: ...
@real.setter
def real(self, value: ArrayLike) -> None: ...
@property
- def imag(self: _ArraySelf) -> _ArraySelf: ...
+ def imag(
+ self: NDArray[_SupportsImag[_ScalarType]], # type: ignore[type-var]
+ ) -> ndarray[_ShapeType, dtype[_ScalarType]]: ...
@imag.setter
def imag(self, value: ArrayLike) -> None: ...
def __new__(