-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
BUG: partition/argpartition do not accept uint64 indices #19832
Copy link
Copy link
Closed
Labels
Description
The partition and argpartition functions currently raise when the kth indices are supplied as a uint64 array-like.
The functions in question check that the indice-type can safelly be cast to intp, which of course will fail in the case of uint64. I'm not quite sure how the likes of __getitem__ and take do manage to deal with uint64, but there it seems to work just fine.
numpy/numpy/core/src/multiarray/item_selection.c
Lines 1295 to 1299 in b3a66e8
| if (!PyArray_CanCastSafely(PyArray_TYPE(ktharray), NPY_INTP)) { | |
| PyErr_Format(PyExc_TypeError, "Partition index must be integer"); | |
| return NULL; | |
| } | |
Example
In [1]: import numpy as np
In [2]: ar = np.arange(10)
In [3]: ar.partition(np.uint64(5))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-fee31ee69481> in <module>
----> 1 ar.partition(np.uint64(5))
TypeError: Partition index must be integerNumPy/Python version information:
1.22.0.dev0+997.g8e4e40f60
3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:36:15)
[Clang 11.1.0 ]
Reactions are currently unavailable