Skip to content

Commit 2e7b695

Browse files
TYP: Add typing for the keepdims param. of 'average' and 'ma.average'
This is a follow-up to numpygh-21485.
1 parent e49478c commit 2e7b695

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

numpy/lib/function_base.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,55 +110,63 @@ def average(
110110
axis: None = ...,
111111
weights: None | _ArrayLikeFloat_co= ...,
112112
returned: L[False] = ...,
113+
keepdims: L[False] = ...,
113114
) -> floating[Any]: ...
114115
@overload
115116
def average(
116117
a: _ArrayLikeComplex_co,
117118
axis: None = ...,
118119
weights: None | _ArrayLikeComplex_co = ...,
119120
returned: L[False] = ...,
121+
keepdims: L[False] = ...,
120122
) -> complexfloating[Any, Any]: ...
121123
@overload
122124
def average(
123125
a: _ArrayLikeObject_co,
124126
axis: None = ...,
125127
weights: None | Any = ...,
126128
returned: L[False] = ...,
129+
keepdims: L[False] = ...,
127130
) -> Any: ...
128131
@overload
129132
def average(
130133
a: _ArrayLikeFloat_co,
131134
axis: None = ...,
132135
weights: None | _ArrayLikeFloat_co= ...,
133136
returned: L[True] = ...,
137+
keepdims: L[False] = ...,
134138
) -> _2Tuple[floating[Any]]: ...
135139
@overload
136140
def average(
137141
a: _ArrayLikeComplex_co,
138142
axis: None = ...,
139143
weights: None | _ArrayLikeComplex_co = ...,
140144
returned: L[True] = ...,
145+
keepdims: L[False] = ...,
141146
) -> _2Tuple[complexfloating[Any, Any]]: ...
142147
@overload
143148
def average(
144149
a: _ArrayLikeObject_co,
145150
axis: None = ...,
146151
weights: None | Any = ...,
147152
returned: L[True] = ...,
153+
keepdims: L[False] = ...,
148154
) -> _2Tuple[Any]: ...
149155
@overload
150156
def average(
151157
a: _ArrayLikeComplex_co | _ArrayLikeObject_co,
152158
axis: None | _ShapeLike = ...,
153159
weights: None | Any = ...,
154160
returned: L[False] = ...,
161+
keepdims: bool = ...,
155162
) -> Any: ...
156163
@overload
157164
def average(
158165
a: _ArrayLikeComplex_co | _ArrayLikeObject_co,
159166
axis: None | _ShapeLike = ...,
160167
weights: None | Any = ...,
161168
returned: L[True] = ...,
169+
keepdims: bool = ...,
162170
) -> _2Tuple[Any]: ...
163171

164172
@overload

numpy/ma/extras.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ diagflat: _fromnxfunction_single
4444

4545
def apply_along_axis(func1d, axis, arr, *args, **kwargs): ...
4646
def apply_over_axes(func, a, axes): ...
47-
def average(a, axis=..., weights=..., returned=...): ...
47+
def average(a, axis=..., weights=..., returned=..., keepdims=...): ...
4848
def median(a, axis=..., out=..., overwrite_input=..., keepdims=...): ...
4949
def compress_nd(x, axis=...): ...
5050
def compress_rowcols(x, axis=...): ...

0 commit comments

Comments
 (0)