Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: np.dtype object does not produce consistent hashes. #17864

Closed as duplicate of#7242
@theXYZT

Description

@theXYZT

It seems that np.dtype(...) does not produce consistent hashes and does not equal the hash of the contained dtype. I feel like these should be consistent with each other so that the following will return true:

np.empty(1).dtype in {np.float32, np.float64}  # False

Reproducing code example:

In [1]: np.float64 == np.dtype(np.float64)
Out[1]: True

In [2]: np.float64 in {np.dtype(np.float64)}
Out[2]: False

In [3]: hash(np.float64)
Out[3]: 8793996338852

In [4]: hash(np.dtype(np.float64))
Out[4]: 3855163183283070272

hash(np.dtype(np.float64)) returns a different value when called in different runtimes too.


Would this be worth fixing?

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