Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

DEV: Audit internal uses of PyArray_EquivTypes #27751

Copy link
Copy link
Open
@ngoldbaum

Description

@ngoldbaum
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.