8000 ENH: Add annotations for `np.lib.type_check` by BvB93 · Pull Request #19286 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Add annotations for np.lib.type_check #19286

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

Merged
merged 3 commits into from
Jun 23, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MAINT: Fixed an issue with the return-dtype of ndarray.real and `imag
The latter two would previously return complex arrays if the initial array was also complex
  • Loading branch information
Bas van Beek authored and BvB93 committed Jun 20, 2021
commit c66ffd98ea1ca734862504bd68c382360152b61c
16 changes: 14 additions & 2 deletions numpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...
Expand All @@ -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__(
Expand Down
0