-
Notifications
You must be signed in to change notification settings - Fork 393
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
Improve test coverage for VectorsCombiner and make vector aggregator efficient #168
Conversation
Codecov Report
@@ Coverage Diff @@
## master #168 +/- ##
==========================================
+ Coverage 80.84% 86.24% +5.39%
==========================================
Files 304 304
Lines 9920 9931 +11
Branches 334 549 +215
==========================================
+ Hits 8020 8565 +545
+ Misses 1900 1366 -534
Continue to review full report at Codecov.
|
* @throws IllegalArgumentException if the vectors have different sizes | ||
* @return vector subtraction | ||
*/ | ||
def -(that: OPVector): OPVector = (value - that.value).toOPVector |
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.
as long as you are adding addition and subtraction why not dot product and cross product?
* @return result vector | ||
*/ | ||
def combine(that: Vector, other: Vector*): Vector = | ||
com.salesforce.op.utils.spark.RichVector.combine(v +: that +: other) |
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.
do you need the full import here?
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.
this is to distinguish the object from the implicit class.
for {(v1, v2) <- vectors.zip(vectors)} { | ||
(v1 - v2) shouldBe (v1.value - v2.value).toOPVector | ||
} | ||
} |
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.
maybe tests for the errors when the vectors have different lengths?
@leahmcguire done |
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.
LGTM
Related issues
UnionVector
monoid aggregator is not efficient for sparse vectors.VectorsCombiner
stage has incomplete functional test coverage.Describe the proposed solution
VectorsCombiner.combine
method toRichVector
objectOpEstimatorSpec
base class toVectorsCombinerTest
to improve the functional test coverage+
,-
,dot
,combine
methods toOPVector
+ testOPVectorTest
combine
method toRichVector
+ testsUnionVector
monoid aggregator toCombineVector
and made use ofRichVector.combine
at reduveSumVector
monoid aggregatorDescribe alternatives you've considered
I could relocate
VectorsCombiner.combine
as-is toutils
subproject, but it felt valuable enough to add+
,-
,dot
andcombine
toOPVector
as well.