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 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"))

case _ => true

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

@tpoterba tpoterba Nov 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@iitalics iitalics Nov 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link

@tpoterba tpoterba left a comment

oops, need to add to functions rst files

Copy link

@tpoterba tpoterba commented Nov 5, 2019

(search for delimit and add in those places)

Copy link
Contributor Author

@iitalics 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.

Copy link

@danking 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
@iitalics iitalics deleted the 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

Successfully merging this pull request may close these issues.

3 participants