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

#532 Declarative fix of AvgOf() bug on Double edge values #581

Merged
merged 15 commits into from
Jan 29, 2018
Merged

#532 Declarative fix of AvgOf() bug on Double edge values #581

merged 15 commits into from
Jan 29, 2018

Conversation

rexim
Copy link
Contributor

@rexim rexim commented Jan 26, 2018

#532 is mine now: #532 (comment) Based on #543

Close #532 close #543

@0crat
Copy link
Collaborator

0crat commented Jan 26, 2018

@yegor256/z please, pay attention to this pull request

@0crat 0crat added the scope label Jan 26, 2018
@0crat
Copy link
Collaborator

0crat commented Jan 26, 2018

Job #581 is now in scope, role is REV

@codecov-io
Copy link

codecov-io commented Jan 26, 2018

Codecov Report

Merging #581 into master will increase coverage by 0.46%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #581      +/-   ##
============================================
+ Coverage      67.4%   67.86%   +0.46%     
+ Complexity      994      971      -23     
============================================
  Files           207      207              
  Lines          3436     3277     -159     
  Branches        254      214      -40     
============================================
- Hits           2316     2224      -92     
+ Misses         1049      998      -51     
+ Partials         71       55      -16
Impacted Files Coverage Δ Complexity Δ
src/main/java/org/cactoos/scalar/AvgOf.java 100% <100%> (+35.32%) 16 <15> (-25) ⬇️
src/main/java/org/cactoos/scalar/Ternary.java 100% <0%> (+5.55%) 9% <0%> (+1%) ⬆️
...c/main/java/org/cactoos/scalar/NumberEnvelope.java 100% <0%> (+6.25%) 10% <0%> (+1%) ⬆️

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 78950e6...7d9e4f7. Read the comment docs.

@0crat
Copy link
Collaborator

0crat commented Jan 26, 2018

This pull request #581 is assigned to @neonailol/z. The budget is 15 minutes, see §4. Please, read §27 and when you decide to accept the changes, inform @yegor256/z (the architect) right in this ticket. If you decide that this PR should not be accepted ever, also inform the architect.

(len) -> len > 0,
(len) -> new Reduced<>(
BigDecimal.ZERO,
BigDecimal::add,
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably should use BigDecimal#add(java.math.BigDecimal, java.math.MathContext) to be consisted with divide below

});
this(
new Mapped<>(
(number) -> () -> number,
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary parenthises, does not correspond with style used in library

});
this(
new Mapped<>(
(number) -> () -> number,
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary parenthises, does not correspond with style used in library

});
this(
new Mapped<>(
(number) -> () -> number,
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary parenthises, does not correspond with style used in library

});
this(
new Mapped<>(
(number) -> () -> number,
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary parenthises, does not correspond with style used in library

BigDecimal.ZERO,
BigDecimal::add,
new Mapped<>(
(number) -> BigDecimal.valueOf(
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary parenthises, does not correspond with style used in library

BigDecimal.valueOf(len),
MathContext.DECIMAL128
).doubleValue(),
(len) -> 0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary parenthises, does not correspond with style used in library

}

@Test
public void withIterableOfScalars() {
Copy link
Contributor

Choose a reason for hiding this comment

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

in this test type of new IterableOf<Scalar<Number>>(() -> 1L, () -> 2L, () -> 10L) can be inferred, so params are not neccecary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without it the compiler complains:

[WARNING] yegor256/cactoos/src/test/java/org/cactoos/scalar/AvgOfTest.java:[358,17] unchecked generic array creation for varargs parameter of type org.cactoos.Scalar<java.lang.Number>[]

And we have -Werror enabled.

() -> new MinOf(1.0d, 2.0d),
() -> new MaxOf(2.0d, 4.0d),
() -> new SumOf(1.0d, 2.0d, 2.0d),
new Ternary<>(true, 5.0, 1.0d)
Copy link
Contributor

Choose a reason for hiding this comment

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

why just 5.0 without d or why d is need here at all?

Copy link
Contributor Author

@rexim rexim Jan 26, 2018

Choose a reason for hiding this comment

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

@neonailol typo. They (d-s) were in the original code I inherited. I kept using the for the consistency. I can remove them if it does not correspond with the style of the library. :)

public void withFloatScalarsIntValue() {
MatcherAssert.assertThat(
new AvgOf(
() -> 1f, () -> 2f, () -> 10f
Copy link
Contributor

Choose a reason for hiding this comment

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

please format floats as 1.0f

@rexim
Copy link
Contributor Author

rexim commented Jan 26, 2018

@neonailol fixed your remarks. Please take a look again.

@neonailol
Copy link
Contributor

Thank you, looks good to me

@neonailol
Copy link
Contributor

@yegor256 this pull request can be merged into master

@yegor256
Copy link
Owner

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Jan 29, 2018

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 7d9e4f7 into yegor256:master Jan 29, 2018
@rultor
Copy link
Collaborator

rultor commented Jan 29, 2018

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 12min)

@0crat
Copy link
Collaborator

0crat commented Jan 29, 2018

Order was successfully finished: +15 points just awarded to @neonailol/z, total is +180

@0crat
Copy link
Collaborator

0crat commented Jan 29, 2018

Payment to ARC for a closed pull request, as in §28: +15 points just awarded to @yegor256/z, total is +8755

@rexim rexim deleted the 532 branch January 29, 2018 13:23
@0crat
Copy link
Collaborator

0crat commented Jan 29, 2018

The job #581 is now out of scope

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

Successfully merging this pull request may close these issues.

AvgOf produces overflow for large values
8 participants