Skip to content

np.nan appears multiple times in sets #9358

@Naereen

Description

@Naereen

Hi,
Here is a weird example, on Ubuntu 17.04 with Python 3.5.3 and Numpy 1.13.0:

In [0]: import numpy as np
In [1]: set([np.nan] * 5)
Out[1]: {nan}                        # OK
In [2]: set(np.array([np.nan] * 5))    
Out[2]: {nan, nan, nan, nan, nan}    # <--- ???
In [3]: set([10] * 5)
Out[3]: {10}
In [4]: set(np.array([10] * 5))    
Out[4]: {10}                         # only for np.nan ??

I don't understand how {nan,nan,nan,nan,nan} is even possible. The array was constructed with np.nan replicated 5 times (and the same works with np.full(5, np.nan)).

I searched on StackOverflow and on the documentation, but cannot find any explanation for this weird behavior.
Thanks in advance if I'm just misunderstanding something!
But in case it's a bug, I can try to help (if a maintainer advise me on the good direction).

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