Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index can be created with multiple NaNs #245

Closed
flexatone opened this issue Sep 6, 2020 · 3 comments
Closed

Index can be created with multiple NaNs #245

flexatone opened this issue Sep 6, 2020 · 3 comments
Assignees

Comments

@flexatone
Copy link
Contributor

This was first identified in #242. An isolated example is below.

>>> sf.Index((1, np.nan)).union(np.array((np.nan,)))
<Index>
1.0
nan
nan
@flexatone
Copy link
Contributor Author

This is in part due to an issue in AutoMap:

brandtbucher/automap#5

@flexatone
Copy link
Contributor Author

This is also due to an issue in how NumPy chooses not to handle NaNs in some operations;

>>> np.union1d(np.array((1, np.nan)), np.array((np.nan,)))
array([ 1., nan, nan])
>>> np.unique((np.array((1, np.nan, np.nan))))
array([ 1., nan, nan])

This appears to be a 10-year old issue:
numpy/numpy#2111

@flexatone flexatone added discussion and removed bug labels Sep 8, 2020
@flexatone flexatone changed the title Invalid index can be created with multiple NaNs Index can be created with multiple NaNs Sep 8, 2020
@flexatone
Copy link
Contributor Author

As this is an issue common to dict as well as AutoMap, as it stands presently this is expected, though confusing behavior for a mapping object. I think the only option, from SF's perspective, is to consider disallowing NaNs in Index, though that option will cost performance.

>>> dict.fromkeys(np.array((np.nan, np.nan)))
{nan: None, nan: None}

@static-frame static-frame locked and limited conversation to collaborators Feb 18, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

1 participant