Conversation
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
| 0, 1, | ||
| NPY_ARRAY_SAME_KIND_CASTING | NPY_ARRAY_DEFAULT, | ||
| NULL); | ||
|
|
There was a problem hiding this comment.
Is the contiguous important for determining when to copy?
There was a problem hiding this comment.
I don't fully understand what you're asking. The code used to do PyArray_ContiguousFromAny which is PyArray_FromAny(..., NPY_ARRAY_DEFAULT, NULL). So I'm just expanding the macro here and adding NPY_ARRAY_SAME_KIND_CASTING effectively. Are you asking if contiguous was important in the first place before my change?
There was a problem hiding this comment.
I did not try to understand why before but I now see that in this PR and in np.put, both functions skip the array machinery and take the raw pointer to the data. So yes, contiguity is required because they can't jump elements with strides. counts = (npy_intp *)PyArray_DATA(repeats); a few lines below.
PR summary
np.repeatnow castsrepeatswith same-kind casting, following #26610 (np.take) and #28355 (np.bincount). Integer arrays such asuint64, orint64on 32-bit platforms, no longer raise aTypeError.Closes #4384.
AI Disclosure
An AI model was used to investigate the history of the issue and draft the changes.