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

InsightLOCOTest Refactor #412

Merged
merged 15 commits into from
Oct 15, 2019
Merged

Conversation

AdamChit
Copy link
Collaborator

Related issues
Long test that needs to be refactored with the main goal of making it more readable and breaking it up into separate tests

Describe the proposed solution
First Change from FlatSpec to FunSpec then break up the test into 5 different test cases

Describe alternatives you've considered
could of put the data generation code into a function, but generating data is expensive so we wouldn't want to make repeated calls to it

@salesforce-cla
Copy link

Thanks for the contribution! It looks like @AdamChit is an internal user so signing the CLA is not required. However, we need to confirm this.

@codecov
Copy link

codecov bot commented Sep 30, 2019

Codecov Report

Merging #412 into master will decrease coverage by 3.67%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #412      +/-   ##
==========================================
- Coverage   86.99%   83.31%   -3.68%     
==========================================
  Files         337      337              
  Lines       11078    11078              
  Branches      369      597     +228     
==========================================
- Hits         9637     9230     -407     
- Misses       1441     1848     +407
Impacted Files Coverage Δ
...alesforce/op/cli/gen/templates/SimpleProject.scala 0% <0%> (-100%) ⬇️
.../scala/com/salesforce/op/cli/gen/ProblemKind.scala 0% <0%> (-100%) ⬇️
...cala/com/salesforce/op/cli/gen/FileInProject.scala 0% <0%> (-100%) ⬇️
...in/scala/com/salesforce/op/cli/CommandParser.scala 0% <0%> (-98.12%) ⬇️
...cala/com/salesforce/op/cli/gen/ProblemSchema.scala 0% <0%> (-96.56%) ⬇️
...src/main/scala/com/salesforce/op/cli/gen/Ops.scala 0% <0%> (-94%) ⬇️
...ain/scala/com/salesforce/op/cli/SchemaSource.scala 0% <0%> (-87.94%) ⬇️
...a/com/salesforce/op/cli/gen/ProjectGenerator.scala 0% <0%> (-87.5%) ⬇️
...in/scala/com/salesforce/op/cli/CliParameters.scala 0% <0%> (-80.96%) ⬇️
...src/main/scala/com/salesforce/op/cli/CliExec.scala 0% <0%> (-80%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a83bf46...a4a0e65. Read the comment docs.

testData: RecordInsightsTestData[LogisticRegressionModel]
): Unit = {
private def assertAggregatedWithPredicate(predicate: OpVectorColumnHistory => Boolean,
testData: RecordInsightsTestData[LogisticRegressionModel]): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you revert the formatting here to the way it was before to match scala style guidelines?

@@ -202,7 +202,8 @@ class RecordInsightsLOCOTest extends FlatSpec with TestSparkContext with RecordI
}
}

it should "return the most predictive features for data generated with a strong relation to the label" in {
describe("data strongly related to label. ") {
Copy link
Contributor

Choose a reason for hiding this comment

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

This description doesn't seem to match the following section. Can you add something more descriptive?

Copy link
Contributor

@crupley crupley left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -96,7 +96,7 @@ class RecordInsightsLOCOTest extends FlatSpec with TestSparkContext with RecordI
)
)
// scalastyle:on
Spec[RecordInsightsLOCO[_]] should "work with randomly generated features and binary logistic regression" in {
it ("should work with randomly generated features and binary logistic regression") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

replace it with Spec[RecordInsightsLOCO[_]]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can't directly do that with FunSpec, what worked best was wrapping describe(Spec[RecordInsightsLOCO[_]]) around the tests.

What the updated tests look like:

Screen Shot 2019-10-07 at 10 32 14 AM

Copy link
Collaborator

@tovbinm tovbinm left a comment

Choose a reason for hiding this comment

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

LGTM, just one comment - replace it with Spec[RecordInsightsLOCO[_]]

@@ -202,7 +202,8 @@ class RecordInsightsLOCOTest extends FlatSpec with TestSparkContext with RecordI
}
}

it should "return the most predictive features for data generated with a strong relation to the label" in {
describe("return the most predictive features for data that is strongly related to label. ") {
// Generate the data
Copy link
Contributor

@gerashegalov gerashegalov Oct 7, 2019

Choose a reason for hiding this comment

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

maybe we should wrap data generation in an informative describe or add informers info. This part still feels too long

@AdamChit
Copy link
Collaborator Author

AdamChit commented Oct 15, 2019

@AdamChit AdamChit closed this Oct 15, 2019
@AdamChit AdamChit reopened this Oct 15, 2019
@AdamChit AdamChit merged commit 5d38090 into salesforce:master Oct 15, 2019
@AdamChit AdamChit mentioned this pull request Oct 16, 2019
@nicodv nicodv mentioned this pull request Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants