Skip to content

BUG? anything is allowed to cast to structured dtypes? #11114

Closed
@mhvk

Description

@mhvk

I found while writing a ufunc that takes structured dtypes for its inputs that casting of essentially everything is allowed to a structured dtype, which is surprising. This is reflected in can_cast:

np.can_cast('f8', 'u1')
# False
np.can_cast('f8', '2u1')
# True

I would have expected, at least for safe, that casting would only be allowed if the dtypes were the same (or, perhaps, that can_cast was applied recursively).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions