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

Simple Fix of SketchMap's non-commutative (issue-1122) #1123

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Peilin-Yang
Copy link

This PR introduces a simple fix to SketchMap's non-commutative, as illustrated in #1122

The fix is simply to always put the DenseMatrix as the first param so that the update to it is correct.

@CLAassistant
Copy link

CLAassistant commented Jun 30, 2023

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.23 🎉

Comparison is base (f644ba4) 89.48% compared to head (abf56a8) 89.72%.

❗ Current head abf56a8 differs from pull request most recent head 6b8610d. Consider uploading reports for the commit 6b8610d to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1123      +/-   ##
===========================================
+ Coverage    89.48%   89.72%   +0.23%     
===========================================
  Files          124      124              
  Lines        10028    10030       +2     
  Branches       782      774       -8     
===========================================
+ Hits          8974     8999      +25     
+ Misses        1054     1031      -23     
Impacted Files Coverage Δ
...rc/main/scala/com/twitter/algebird/SketchMap.scala 92.72% <100.00%> (+0.27%) ⬆️

... and 11 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines +54 to +57
val newValuesTable = right.valuesTable match {
case DenseMatrix(_, _, _) => Monoid.plus(right.valuesTable, left.valuesTable)
case _ => Monoid.plus(left.valuesTable, right.valuesTable)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
val newValuesTable = right.valuesTable match {
case DenseMatrix(_, _, _) => Monoid.plus(right.valuesTable, left.valuesTable)
case _ => Monoid.plus(left.valuesTable, right.valuesTable)
}
val newValuesTable = right.valuesTable match {
case _: DenseMatrix[V] => Monoid.plus(right.valuesTable, left.valuesTable)
case _ => Monoid.plus(left.valuesTable, right.valuesTable)
}

Also, perhaps it would make more sense to address this here

override def plus(a: AdaptiveMatrix[V], b: AdaptiveMatrix[V]): AdaptiveMatrix[V] =

Copy link
Author

Choose a reason for hiding this comment

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

Also, perhaps it would make more sense to address this here

yeah, pretty much agreed.
I was afraid to touch AdaptiveMatrix due to unfamiliarity of it, but will try to see if I can fix that directly.

@@ -53,6 +55,38 @@ class SketchMapTest extends AnyWordSpec with Matchers {
assert(sm.totalValue == totalCount)
}

"plus should work commutatively" in {
implicit val m = Monoid.longMonoid
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this is not required

Copy link
Collaborator

@regadas regadas left a comment

Choose a reason for hiding this comment

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

thanks for the PR @Peilin-Yang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants