8000 ENH: Add annotations for remaining `ndarray` / `generic` non-magic methods by BvB93 · Pull Request #17372 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Add annotations for remaining ndarray / generic non-magic methods #17372

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 6 commits into from
Oct 5, 2020
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: Moved a number of methods from _ArrayOrScalarCommon to `ndar…
…ray`

A number of  methods require a >= 1D array or are completelly absent from `generic`.
Move them to `ndarray`.
  • Loading branch information
Bas van Beek committed Sep 22, 2020
commit 40cce4f69f6e4dfbda45e76294238db1f3223a97
123 changes: 63 additions & 60 deletions numpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,6 @@ class _ArrayOrScalarCommon(
def argmin(
self, axis: Optional[_ShapeLike] = ..., out: _NdArraySubClass = ...
) -> _NdArraySubClass: ...
def argpartition(
self,
kth: _ArrayLikeIntOrBool,
axis: Optional[int] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> ndarray: ...
def argsort(
self,
axis: Optional[int] = ...,
Expand Down Expand Up @@ -545,8 +538,8 @@ class _ArrayOrScalarCommon(
) -> _NdArraySubClass: ...
@overload
def compress(
self: _ArraySelf, a: ArrayLike, axis: Optional[int] = ..., out: None = ...,
) -> _ArraySelf: ...
self, a: ArrayLike, axis: Optional[int] = ..., out: None = ...,
) -> ndarray: ...
@overload
def compress(
self, a: ArrayLike, axis: Optional[int] = ..., out: _NdArraySubClass = ...,
Expand Down Expand Up @@ -575,13 +568,6 @@ class _ArrayOrScalarCommon(
dtype: DtypeLike = ...,
out: _NdArraySubClass = ...,
) -> _NdArraySubClass: ...
def diagonal(
self: _ArraySelf, offset: int = ..., axis1: int = ..., axis2: int = ...
) -> _ArraySelf: ...
@overload
def dot(self, b: ArrayLike, out: None = ...) -> Union[number, ndarray]: ...
@overload
def dot(self, b: ArrayLike, out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
@overload
def max(
self,
Expand Down Expand Up @@ -661,14 +647,6 @@ class _ArrayOrScalarCommon(
where: _ArrayLikeBool = ...,
) -> _NdArraySubClass: ...
def newbyteorder(self: _ArraySelf, __new_order: _ByteOrder = ...) -> _ArraySelf: ...
def nonzero(self) -> Tuple[ndarray, ...]: ...
def partition(
self,
kth: _ArrayLikeIntOrBool,
axis: int = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> None: ...
@overload
def prod(
self,
Expand Down Expand Up @@ -714,9 +692,6 @@ class _ArrayOrScalarCommon(
out: _NdArraySubClass = ...,
keepdims: bool = ...,
) -> _NdArraySubClass: ...
def put(
self, ind: _ArrayLikeIntOrBool, v: ArrayLike, mode: _Mode = ...
) -> None: ...
def repeat(
self, repeats: _ArrayLikeIntOrBool, axis: Optional[int] = ...
) -> ndarray: ...
Expand All @@ -726,21 +701,6 @@ class _ArrayOrScalarCommon(
def round(
self, decimals: int = ..., out: _NdArraySubClass = ...
) -> _NdArraySubClass: ...
def searchsorted(
self,
v: ArrayLike,
side: _Side = ...,
sorter: Optional[_ArrayLikeIntOrBool] = ..., # 1D int array
) -> ndarray: ...
def setfield(
self, val: ArithmeticError, dtype: DtypeLike, offset: int = ...
) -> None: ...
def sort(
self,
axis: Optional[int] = ...,
kind: Optional[_SortKind] = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> None: ...
@overload
def std(
self,
Expand Down Expand Up @@ -823,24 +783,6 @@ class _ArrayOrScalarCommon(
mode: _Mode = ...,
) -> _NdArraySubClass: ...
@overload
def trace(
self, # >= 2D array
offset: int = ...,
axis1: int = ...,
axis2: int = ...,
dtype: DtypeLike = ...,
out: None = ...,
) -> Union[number, ndarray]: ...
@overload
def trace(
self, # >= 2D array
offset: int = ...,
axis1: int = ...,
axis2: int = ...,
dtype: DtypeLike = ...,
out: _NdArraySubClass = ...,
) -> _NdArraySubClass: ...
@overload
def var(
self,
axis: None = ...,
Expand Down Expand Up @@ -901,6 +843,67 @@ class ndarray(_ArrayOrScalarCommon, Iterable, Sized, Container):
def strides(self) -> _Shape: ...
@strides.setter
def strides(self, value: _ShapeLike): ...
def argpartition(
self,
kth: _ArrayLikeIntOrBool,
axis: Optional[int] = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> ndarray: ...
def diagonal(
self: _ArraySelf, offset: int = ..., axis1: int = ..., axis2: int = ...
) -> _ArraySelf: ...
@overload
def dot(self, b: ArrayLike, out: None = ...) -> Union[number, ndarray]: ...
@overload
def dot(self, b: ArrayLike, out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
# `nonzero()` is deprecated for 0d arrays/generics
def nonzero(self) -> Tuple[ndarray, ...]: ...
def partition(
self,
kth: _ArrayLikeIntOrBool,
axis: int = ...,
kind: _PartitionKind = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> None: ...
# `put` is technically available to `generic`,
# but is pointless as `generic`s are immutable
def put(
self, ind: _ArrayLikeIntOrBool, v: ArrayLike, mode: _Mode = ...
) -> None: ...
def searchsorted(
self, # >= 1D array
v: ArrayLike,
side: _Side = ...,
sorter: Optional[_ArrayLikeIntOrBool] = ..., # 1D int array
) -> ndarray: ...
def setfield(
self, val: ArrayLike, dtype: DtypeLike, offset: int = ...
) -> None: ...
def sort(
self,
axis: int = ...,
kind: Optional[_SortKind] = ...,
order: Union[None, str, Sequence[str]] = ...,
) -> None: ...
@overload
def trace(
self, # >= 2D array
offset: int = ...,
axis1: int = ...,
axis2: int = ...,
dtype: DtypeLike = ...,
out: None = ...,
) -> Union[number, ndarray]: ...
@overload
def trace(
self, # >= 2D array
offset: int = ...,
axis1: int = ...,
axis2: int = ...,
dtype: DtypeLike = ...,
out: _NdArraySubClass = ...,
) -> _NdArraySubClass: ...
# Many of these special methods are irrelevant currently, since protocols
# aren't supported yet. That said, I'm adding them for completeness.
# https://docs.python.org/3/reference/datamodel.html
Expand Down
0