Skip to content

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

Open
Peilin-Yang wants to merge 1 commit intotwitter:developfrom
Peilin-Yang:issue-1122
Open

Simple Fix of SketchMap's non-commutative (issue-1122)#1123
Peilin-Yang wants to merge 1 commit intotwitter:developfrom
Peilin-Yang:issue-1122

Conversation

@Peilin-Yang
Copy link
Copy Markdown

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
Copy Markdown

CLAassistant commented Jun 30, 2023

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link
Copy Markdown

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
Copy Markdown
Contributor

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
Copy Markdown
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.

}

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

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
Copy Markdown
Contributor

@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