8000 Merge pull request #19324 from BvB93/real_imag · numpy/numpy@c532dcd · GitHub
[go: up one dir, main page]

Skip to content

Commit c532dcd

Browse files
authored
Merge pull request #19324 from BvB93/real_imag
MAINT: Fixed the return-dtype of `ndarray.real` and `imag`
2 parents 209cca9 + cd33912 commit c532dcd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
8000

numpy/__init__.pyi

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,14 @@ _ArrayTD64_co = NDArray[Union[bool_, integer[Any], timedelta64]]
16451645
class _SupportsItem(Protocol[_T_co]):
16461646
def item(self, __args: Any) -> _T_co: ...
16471647

1648+
class _SupportsReal(Protocol[_T_co]):
1649+
@property
1650+
def real(self) -> _T_co: ...
1651+
1652+
class _SupportsImag(Protocol[_T_co]):
1653+
@property
1654+
def imag(self) -> _T_co: ...
1655+
16481656
class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
16491657
@property
16501658
def base(self) -> Optional[ndarray]: ...
@@ -1653,11 +1661,15 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
16531661
@property
16541662
def size(self) -> int: ...
16551663
@property
1656-
def real(self: _ArraySelf) -> _ArraySelf: ...
1664+
def real(
1665+
self: NDArray[_SupportsReal[_ScalarType]], # type: ignore[type-var]
1666+
) -> ndarray[_ShapeType, dtype[_ScalarType]]: ...
16571667
@real.setter
16581668
def real(self, value: ArrayLike) -> None: ...
16591669
@property
1660-
def imag(self: _ArraySelf) -> _ArraySelf: ...
1670+
def imag(
1671+
self: NDArray[_SupportsImag[_ScalarType]], # type: ignore[type-var]
1672+
) -> ndarray[_ShapeType, dtype[_ScalarType]]: ...
16611673
@imag.setter
16621674
def imag(self, value: ArrayLike) -> None: ...
16631675
def __new__(

0 commit comments

Comments
 (0)
0