Skip to content

Array elements are not hashable #109

Closed
@StefanieSenger

Description

@StefanieSenger

In scikit-learn we use array values as dict keys, but trying this with array_api_strict array dtypes fails:

import array_api_strict

labels= array_api_strict.asarray([4, 5, 6])
label_to_index = {entry: idx for idx, entry in enumerate(labels)}

TypeError: unhashable type: 'Array'

Since the dtypes are all numbers or boolean, they are immutable and - I was thinking - also hashable? For numpy and torch arrays they are.

Is this a bug or on purpose for some reason?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions