-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-9723][ML] params getordefault should throw more useful error #8567
[SPARK-9723][ML] params getordefault should throw more useful error #8567
Conversation
try { | ||
defaultParamMap.get(param) | ||
} catch { | ||
case e: NoSuchElementException => |
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.
Can you check if the map contains
the param rather than wait for an exception? Really doesn't matter though. This looks OK except that you'll need a space after "param" in the error message below, and you could use string interpolation.
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 figured it was better to handle the exception case this way since the exception case should happen way less frequently. I'll switch it to string interpolation tomorrow :)
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.
We don't have performance issues here. So code readability is more important, e.g.,
defaultParamMap.getOrElse(param,
throw new NoSuchElementException(s"No default value for ${param.name} in ${this.getClass}.")
Test build #41918 has finished for PR 8567 at commit
|
Test build #41945 has finished for PR 8567 at commit
|
Test build #41949 has finished for PR 8567 at commit
|
Test build #41950 has finished for PR 8567 at commit
|
LGTM. Merged into master. Thanks! |
Params.getOrDefault should throw a more meaningful exception than what you get from a bad key lookup.