8000 DEV: Audit internal uses of PyArray_EquivTypes · Issue #27751 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DEV: Audit internal uses of PyArray_EquivTypes #27751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ngoldbaum opened this issue Nov 13, 2024 · 0 comments
Open

DEV: Audit internal uses of PyArray_EquivTypes #27751

ngoldbaum opened this issue Nov 13, 2024 · 0 comments

Comments

@ngoldbaum
Copy link
Member

In #27715 we fixed a bug in nditer internals that affected fancy indexing for StringDType arrays. Ultimately this is caused by NumPy using PyArray_EquivTypes to check the cast between the DTypes is NPY_NO_CASTING. That is not a sufficient check in all cases, particularly for user DTypes like StringDType that store some array data on dtype instances. Instead, the correct thing to check is if the cast between the DTypes is NPY_NO_CASTING and the view_offset is 0.

We should audit all internal uses of PyArray_EquivTypes and see if it could be problematic for StringDType arrays. If the check is used to see whether or not a cast between the arrays is needed, it should probably be updated to use PyArray_SafeCast. We should also investigate whether we should update PyArray_EquivTypes itself to do this check (or to call PyArray_SafeCast) and instead replace any places where we want exactly just the check for NPY_NO_CASTING with a new function that replaces EquivTypes.

See also #26317 and #26147 which fixed similar issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0