-
Notifications
You must be signed in to change notification settings - Fork 912
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
[REVIEW] Add support for string 'nan', 'inf' & '-inf'
values while type-casting to float
#9613
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
41e406a
handle float values correclty
galipremsagar 23313f5
add tests
galipremsagar 1a1aa70
add global variables
galipremsagar d082e92
typo
galipremsagar b2b1a77
add missing combination
galipremsagar a9fabee
Merge remote-tracking branch 'upstream/branch-21.12' into 7488
galipremsagar 8b3b7e3
add todo
galipremsagar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would all of these really happen?
If so, there are a couple of missing combinations:
nAn, -iNf, +iNf, iNf
If not, would suggest perhaps only supporting
NaN, nan, NAN; -Inf, -inf, -INF; +Inf, +inf, +INF; Inf, inf, INF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe helpful:
cudf/python/cudf/cudf/core/tools/numeric.py
Line 243 in 2ef82f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this @davidwendt. The string to float conversion happens via NumPy machinery. FWIW, it appears that NumPy converts all strings to lower case equivalent and then performs the type-cast which makes it easier to handle these kinds of combinations, for ex:
I had these combinations added to match this behavior, if you think performing a
.lower
operation and then replacing is a better alternative we can switch to that as well. But I suppose libcudf only supportsNaN
,Inf
values as opposed tonan
,inf
which rules out the.lower
operation for us.Did some benchmarks with a subset and comprehensive set:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I think it is reasonable for libcudf to support all uppercase for this as documented for
std::stof
here: https://en.cppreference.com/w/cpp/string/basic_string/stofThis way, you could call
.upper()
which should be faster than.replace()
.This change is not difficult so let me know if you want me to open a PR for this.
Since 21.12 is now in burndown, we could also go ahead with this PR as is and make the change to libcudf and change cudf to use
.upper()
in the next release as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both these code-paths should be unified a little bit, since David will be adding the all uppercase support in next release, I've added a TODO to merge these two paths.