Skip to content

Correct Min.semigroup #651

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

Merged
merged 3 commits into from
Feb 14, 2018
Merged

Conversation

kellen
Copy link
Contributor

@kellen kellen commented Feb 13, 2018

Min.semigroup was incorrectly returning the greater element.

This PR corrects the semigroup and adds tests to check the results from both Min.semigroup and Max.semigroup (which was already correct).

@CLAassistant
Copy link

CLAassistant commented Feb 13, 2018

CLA assistant check
All committers have signed the CLA.

@kellen
Copy link
Contributor Author

kellen commented Feb 13, 2018

Hmm, build failure seems unrelated to the PR changes.

@johnynek
Copy link
Collaborator

Amazing. It looks like the monoid was correct and since all the numeric types use that we were saved.

property("Max.semigroup returns the maximum item") {
forAll { v: NonEmptyVector[Int] =>
val maxItems = v.items.map { Max(_) }
v.sorted.last == Max.semigroup[Int].combineAllOption(maxItems).get.get
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you also test this for a custom type that does not have a special instance defined?

Also, scala has .max on Iterable. Can we just use that rather than sorted.last?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

forAll { v: NonEmptyVector[Int] =>
val minItems = v.items.map { Min(_) }
v.sorted.head == Min.semigroup[Int].combineAllOption(minItems).get.get
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comments as above.

@codecov-io
Copy link

codecov-io commented Feb 13, 2018

Codecov Report

Merging #651 into develop will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #651      +/-   ##
===========================================
+ Coverage    82.83%   82.89%   +0.05%     
===========================================
  Files          109      109              
  Lines         5209     5209              
  Branches       316      316              
===========================================
+ Hits          4315     4318       +3     
+ Misses         894      891       -3
Impacted Files Coverage Δ
...core/src/main/scala/com/twitter/algebird/Min.scala 89.47% <100%> (ø) ⬆️
...in/scala/com/twitter/algebird/scalacheck/Gen.scala 91.66% <0%> (-8.34%) ⬇️
...c/main/scala/com/twitter/algebird/MapAlgebra.scala 76.92% <0%> (-0.97%) ⬇️
.../main/scala/com/twitter/algebird/BloomFilter.scala 94.84% <0%> (+0.85%) ⬆️
...src/main/scala/com/twitter/algebird/Interval.scala 83.47% <0%> (+1.73%) ⬆️
...rc/main/scala/com/twitter/algebird/Semigroup.scala 83.92% <0%> (+1.78%) ⬆️
.../main/scala/com/twitter/algebird/Successible.scala 91.66% <0%> (+4.16%) ⬆️

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 03ca640...a075f07. Read the comment docs.

@johnynek
Copy link
Collaborator

👍

will merge when green.

@johnynek
Copy link
Collaborator

Thank you for taking the time to send a PR here.

@johnynek johnynek merged commit b5cd424 into twitter:develop Feb 14, 2018
@oscar-stripe
Copy link

This was broken in 0.13.2 by me. :( I'm sorry y'all...

#620

I just hit this in tests trying to update to the latest algebird. At least our tests caught it....

Will publish 0.13.4 presently.

@johnynek
Copy link
Collaborator

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.

5 participants