Skip to content
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

[hail] variation of `hl.float`/`` that returns null on invalid string #7453

merged 8 commits into from Nov 6, 2019


Copy link

iitalics commented Nov 4, 2019

fixes #7408

stacked on #7452

adds new toplevel hail functions:

  • parse_float, parse_float32, parse_float64
  • parse_int, parse_int32, parse_int64

all of the above accept only tstr expressions, and return missing for invalid numbers.

>>> hl.eval(hl.parse_int("-5.3"))
>>> hl.eval(hl.parse_int("asdf"))
>>> hl.eval(hl.parse_int("-5"))
>>> hl.eval(hl.parse_float("-NaM"))
>>> hl.eval(hl.parse_float("-NaN"))
>>> hl.eval(hl.parse_float("5.3"))
@iitalics iitalics force-pushed the iitalics:parse-or-null branch from bd431e8 to b8cb01d Nov 4, 2019
@iitalics iitalics force-pushed the iitalics:parse-or-null branch from b8cb01d to 8be0cf8 Nov 5, 2019
@tpoterba tpoterba removed the stacked PR label Nov 5, 2019
case _ => true

def isValidFloat64(s: String): Boolean = parseSpecialNum(s) match {

This comment has been minimized.

Copy link

tpoterba Nov 5, 2019


You're parsing twice here -- once for the check and once for the parse. That's not ideal, but I do see the reason why it's not easy to do it just once in generated code without boxing.

This comment has been minimized.

Copy link

iitalics Nov 5, 2019

Author Contributor

yeah :I if we could catch exceptions in asm4s then that would be one nicer way to handle this.

Copy link

tpoterba left a comment

oops, need to add to functions rst files


This comment has been minimized.

Copy link

tpoterba commented Nov 5, 2019

(search for delimit and add in those places)


This comment has been minimized.

Copy link
Contributor Author

iitalics commented Nov 6, 2019

what the hell, bytecode verify errors from using locals? i saw another code-function creating locals so i assumed it was safe to do so, but apparently it isn't.

iitalics added 2 commits Nov 6, 2019

This comment has been minimized.

Copy link

danking commented Nov 6, 2019

I extremely like this. Eventually, I'd like to be able to write the table reading code in Python. That import_matrix_table only supports certain types is frustrating and it'd be easier to fix with more parsing functions like this!

@danking danking merged commit 315a0a7 into hail-is:master Nov 6, 2019
1 check passed
1 check passed
ci-test success
@iitalics iitalics deleted the iitalics:parse-or-null branch Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.