brandtbucher / automap

High-performance autoincremented integer-valued mappings. 🗺️
Other
16 stars 4 forks source link

Inconsistent NaN behavior #8

Closed chaburkland closed 2 years ago

chaburkland commented 2 years ago
from automap import FrozenAutoMap

FrozenAutoMap((float("nan") for _ in range(3)))       # This works!
FrozenAutoMap((np.float64("nan") for _ in range(3)))  # This works!
FrozenAutoMap((np.nan for _ in range(3)))             # This fails!
brandtbucher commented 2 years ago

Pretty sure this is a duplicate of #5. Note that these lines are not doing the same thing, and automap's behavior is consistent with Python's built-in hash table types:

>>> {float("nan") for _ in range(3)}
{nan, nan, nan}
>>> {np.float64("nan") for _ in range(3)}
{nan, nan, nan}
>>> {np.nan for _ in range(3)}
{nan}

(Feel free to reopen if I missed something!)