Signatures and behaviors of `argmax` and `argmin` are incompatible with NumPy
See original GitHub issueFirst, for the signature: In CuPy the signature for argmax()
and argmin()
is
cupy.argm*(a, axis=None, dtype=None, out=None, keepdims=False)
But in NumPy it’s
numpy.argm*(a, axis=None, out=None)
That is, dtype
and keepdims
should be removed.
Second, for the behavior: In CuPy the axis
could be a tuple, but in Numpy it can only be an integer:
>>> import cupy as cp
>>> a = cp.arange(60).reshape(3,4,5)
>>> a.argmax(axis=(0,1))
array([11, 11, 11, 11, 11], dtype=int64)
>>>
>>> import numpy as np
>>> a = np.arange(60).reshape(3,4,5)
>>> a.argmax(axis=(0,1))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object cannot be interpreted as an integer
I think both are easy to fix. Just add a few guards prior to calling the actual workhorses.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
numpy: what is the logic of the argmin() and argmax() functions?
By adding the axis argument, NumPy looks at the rows and columns individually. When it's not given, the array a is flattened into...
Read more >NumPy 1.22.0 Release Notes
When a function that respects numpy.ndarray subclasses is vectorized using numpy.vectorize , the vectorized function will now be subclass-safe also for cases ...
Read more >Supported NumPy features - Numba documentation
The following methods of NumPy arrays are supported: argmax() ( axis keyword argument supported). argmin() ( ...
Read more >What's New — pandas 0.23.2 documentation - PyData |
With NumPy 1.15 and pandas 0.23.1 or earlier, numpy.all() will no longer ... We've deprecated the current behavior of Series.argmax and Series.argmin ....
Read more >What's New - Xarray
Fix incompatibility with numpy 1.20. ... DataArray.argmin() and DataArray.argmax() now support sequences of 'dim' arguments, and if a sequence is passed ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We don’t have to remove any arguments? Then, #2872 fixes the remaining issue (
dtype
argument ofargmin/argmax
).Issue numpy/numpy#8710: “Add
keepdims
argument to argmin and argmax”