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

[Minor] [ML] When trainingSummary is None, it should throw RuntimeException. #11784

Closed
wants to merge 2 commits into from

Conversation

yanboliang
Copy link
Contributor

What changes were proposed in this pull request?

When trainingSummary is None, it should throw RuntimeException.
cc @mengxr

How was this patch tested?

Existing tests.

@SparkQA
Copy link

SparkQA commented Mar 17, 2016

Test build #53432 has finished for PR 11784 at commit d263159.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

def summary: LogisticRegressionTrainingSummary = trainingSummary.getOrElse {
throw new SparkException(
"No training summary available for this LogisticRegressionModel",
new RuntimeException())
Copy link
Member

Choose a reason for hiding this comment

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

Generally you don't use RuntimeException directly... why is the exception chained anyway and what was wrong with NPE? just kinda inaccurate? NoSuchElementException is what None.get throws.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree we usually don't use RuntimeException directly. But I think it's inappropriate use NullPointerException here, because NullPointerException was thrown when an application attempts to access null in a case. Here we throw the SparkException just want to handle the case that trainingSummary == None, we did not access null actually. Should we just throw an SparkException?

Copy link
Member

Choose a reason for hiding this comment

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

It already threw SparkException though, so I wasn't sure why it was worth changing. However, I also can't figure out the point of that chained NPE. This seems OK.

@SparkQA
Copy link

SparkQA commented Mar 18, 2016

Test build #53514 has finished for PR 11784 at commit a89bb5d.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member

srowen commented Mar 18, 2016

Merged to master

@asfgit asfgit closed this in 7783b6f Mar 18, 2016
roygao94 pushed a commit to roygao94/spark that referenced this pull request Mar 22, 2016
…ption.

## What changes were proposed in this pull request?
When trainingSummary is None, it should throw ```RuntimeException```.
cc mengxr
## How was this patch tested?
Existing tests.

Author: Yanbo Liang <ybliang8@gmail.com>

Closes apache#11784 from yanboliang/fix-summary.
@yanboliang yanboliang deleted the fix-summary branch May 5, 2016 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants