From 6568c6b022e12ab6d71e7548314009ced6ccabe9 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Wed, 7 Jul 2021 22:00:03 +0530 Subject: ENH: Adding keepdims to np.argmin,np.argmax (#19211) * keepdims added to np.argmin,np.argmax * Added release notes entry * tested for axis=None,keepdims=True * Apply suggestions from code review * updated interface * updated interface * API changed, implementation to be done * Added reshape approach to C implementation * buggy implementation without reshape * TestArgMax, TestArgMin fixed, comments added * Fixed for matrix * removed unrequired changes * fixed CI failure * fixed linting issue * PyArray_ArgMaxKeepdims now only modifies shape and strides * Comments added to PyArray_ArgMaxKeepdims * Updated implementation of PyArray_ArgMinKeepdims to match with PyArray_ArgMaxKeepdims * Testing complete for PyArray_ArgMinKeepdims and PyArray_ArgMaxKeepdims * PyArray_ArgMinWithKeepdims both keepdims=True and keepdims=False * matched implementation of PyArray_ArgMaxKeepdims and PyArray_ArgMinKeepdims * simplified implementation * Added missing comment * removed unwanted header * addressed all the reviews * Removing unwanted changes * fixed docs * Added new lines * restored annotations * parametrized test * Apply suggestions from code review Co-authored-by: Sebastian Berg * keyword handling now done in np.argmin/np.argmax * corrected indendation * used with pytest.riases(ValueError) * fixed release notes * removed PyArray_ArgMaxWithKeepdims and PyArray_ArgMinWithKeepdims from public C-API * Apply suggestions from code review Co-authored-by: Eric Wieser * Apply suggestions from code review Co-authored-by: Eric Wieser Co-authored-by: Sebastian Berg Co-authored-by: Eric Wieser --- numpy/core/fromnumeric.pyi | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'numpy/core/fromnumeric.pyi') diff --git a/numpy/core/fromnumeric.pyi b/numpy/core/fromnumeric.pyi index 3342ec3ac..45057e4b1 100644 --- a/numpy/core/fromnumeric.pyi +++ b/numpy/core/fromnumeric.pyi @@ -130,12 +130,16 @@ def argmax( a: ArrayLike, axis: None = ..., out: Optional[ndarray] = ..., + *, + keepdims: Literal[False] = ..., ) -> intp: ... @overload def argmax( a: ArrayLike, axis: Optional[int] = ..., out: Optional[ndarray] = ..., + *, + keepdims: bool = ..., ) -> Any: ... @overload @@ -143,12 +147,16 @@ def argmin( a: ArrayLike, axis: None = ..., out: Optional[ndarray] = ..., + *, + keepdims: Literal[False] = ..., ) -> intp: ... @overload def argmin( a: ArrayLike, axis: Optional[int] = ..., out: Optional[ndarray] = ..., + *, + keepdims: bool = ..., ) -> Any: ... @overload -- cgit v1.2.1