Skip to content

persistent_dict can't store NaNs #287

Description

@matthiasdiener
frompytools.persistent_dictimportPersistentDictimportnumpyasnppdict=PersistentDict("pytools-test", safe_sync=True)
pdict[np.nan] =42assertpdict[np.nan] ==42
$ python t.py/Users/mdiener/Work/e12test/pytools/pytools/persistent_dict.py:602: CollisionWarning: pytools-test: key collision in cache at '/Users/mdiener/Work/e12test/loopy/xdg-cache/pytools' -- these are sufficiently unlikely that they're often indicative of a broken hash key implementation (that is not considering some elements relevant for equality comparison) return self.fetch(key)Traceback (most recent call last): File "/Users/mdiener/Work/e12test/pytools/t.py", line 8, in <module> assert pdict[np.nan] == 42 ~~~~~^^^^^^^^ File "/Users/mdiener/Work/e12test/pytools/pytools/persistent_dict.py", line 602, in __getitem__ return self.fetch(key) ^^^^^^^^^^^^^^^ File "/Users/mdiener/Work/e12test/pytools/pytools/persistent_dict.py", line 840, in fetch self._collision_check(key, stored_key) File "/Users/mdiener/Work/e12test/pytools/pytools/persistent_dict.py", line 552, in _collision_check raise NoSuchEntryCollisionError(key)pytools.persistent_dict.NoSuchEntryCollisionError: nan

🤦

Perhaps we should also check if the key contains a Nan in the collision check? Are there other cases that could be at issue here (inf seems to be fine)?

cc inducer/loopy#828 [major plot twist!]

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions