Skip to content

Commit

Permalink
Merge pull request #20936 from charris/backport-20918
Browse files Browse the repository at this point in the history
MAINT, TYP: Added missing where typehints in fromnumeric.pyi
  • Loading branch information
charris committed Jan 29, 2022
2 parents 2a3900e + b48b73b commit 2f11271
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions numpy/__init__.pyi
Expand Up @@ -1040,20 +1040,26 @@ class _ArrayOrScalarCommon:
axis: None = ...,
out: None = ...,
keepdims: L[False] = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> bool_: ...
@overload
def all(
self,
axis: Optional[_ShapeLike] = ...,
out: None = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> Any: ...
@overload
def all(
self,
axis: Optional[_ShapeLike] = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> _NdArraySubClass: ...

@overload
Expand All @@ -1062,20 +1068,26 @@ class _ArrayOrScalarCommon:
axis: None = ...,
out: None = ...,
keepdims: L[False] = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> bool_: ...
@overload
def any(
self,
axis: Optional[_ShapeLike] = ...,
out: None = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> Any: ...
@overload
def any(
self,
axis: Optional[_ShapeLike] = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> _NdArraySubClass: ...

@overload
Expand Down Expand Up @@ -1258,6 +1270,8 @@ class _ArrayOrScalarCommon:
dtype: DTypeLike = ...,
out: None = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> Any: ...
@overload
def mean(
Expand All @@ -1266,6 +1280,8 @@ class _ArrayOrScalarCommon:
dtype: DTypeLike = ...,
out: _NdArraySubClass = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> _NdArraySubClass: ...

@overload
Expand Down Expand Up @@ -1349,6 +1365,8 @@ class _ArrayOrScalarCommon:
out: None = ...,
ddof: int = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> Any: ...
@overload
def std(
Expand All @@ -1358,6 +1376,8 @@ class _ArrayOrScalarCommon:
out: _NdArraySubClass = ...,
ddof: int = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> _NdArraySubClass: ...

@overload
Expand Down Expand Up @@ -1389,6 +1409,8 @@ class _ArrayOrScalarCommon:
out: None = ...,
ddof: int = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> Any: ...
@overload
def var(
Expand All @@ -1398,6 +1420,8 @@ class _ArrayOrScalarCommon:
out: _NdArraySubClass = ...,
ddof: int = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> _NdArraySubClass: ...

_DType = TypeVar("_DType", bound=dtype[Any])
Expand Down
14 changes: 14 additions & 0 deletions numpy/core/fromnumeric.pyi
Expand Up @@ -246,13 +246,17 @@ def all(
axis: None = ...,
out: None = ...,
keepdims: Literal[False] = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> bool_: ...
@overload
def all(
a: ArrayLike,
axis: Optional[_ShapeLike] = ...,
out: Optional[ndarray] = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> Any: ...

@overload
Expand All @@ -261,13 +265,17 @@ def any(
axis: None = ...,
out: None = ...,
keepdims: Literal[False] = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> bool_: ...
@overload
def any(
a: ArrayLike,
axis: Optional[_ShapeLike] = ...,
out: Optional[ndarray] = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> Any: ...

def cumsum(
Expand Down Expand Up @@ -342,6 +350,8 @@ def mean(
dtype: DTypeLike = ...,
out: Optional[ndarray] = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> Any: ...

def std(
Expand All @@ -351,6 +361,8 @@ def std(
out: Optional[ndarray] = ...,
ddof: int = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> Any: ...

def var(
Expand All @@ -360,4 +372,6 @@ def var(
out: Optional[ndarray] = ...,
ddof: int = ...,
keepdims: bool = ...,
*,
where: _ArrayLikeBool_co = ...,
) -> Any: ...

0 comments on commit 2f11271

Please sign in to comment.