Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Wrong behavior for nan converting from float to int #1761

Closed
TobyRoseman opened this issue Apr 22, 2019 · 2 comments · Fixed by #2557
Closed

Wrong behavior for nan converting from float to int #1761

TobyRoseman opened this issue Apr 22, 2019 · 2 comments · Fixed by #2557
Assignees

Comments

@TobyRoseman
Copy link
Collaborator

When changing the dtype of an SArray from float to int, nan get converted to very large number:

In [1]: import turicreate as tc

In [2]: sa = tc.SArray([1.0,2.0,float('nan'),3.0])

In [3]: sa
Out[3]: 
dtype: float
Rows: 4
[1.0, 2.0, nan, 3.0]

In [4]: sa.astype(int)
Out[4]: 
dtype: int
Rows: 4
[1, 2, -9223372036854775808, 3]

I'm not certain what the best behavior would be here; it seems nan is a floating point only representation. It would probably be best to turn the nan into None. Raising an exception is also probably reasonable.

@hoytak hoytak added the bug label Apr 24, 2019
@syoutsey syoutsey added the p3 label Aug 15, 2019
@hoytak
Copy link
Collaborator

hoytak commented Aug 15, 2019

We should turn this into a None. It should be a simple fix.

@dhivyaaxim
Copy link
Contributor

@TobyRoseman Please assign this ticket to me as I would like to try fixing it and contribute. Thanks in advance!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants