java 8 improvements. #217
java 8 improvements. #217arturobernalg wants to merge 1 commit intoapache:masterfrom arturobernalg:feature/java8
Conversation
arturobernalg
commented
Oct 20, 2022
- Replaced Anonymous type with lambda
- Replace Collections.sort() with List.sort()
- Replace Lambda with method reference
- Simplifiable 'Map' operations
Codecov Report
@@ Coverage Diff @@
## master #217 +/- ##
============================================
- Coverage 86.55% 86.53% -0.02%
+ Complexity 9810 9798 -12
============================================
Files 533 533
Lines 35579 35559 -20
Branches 6212 6207 -5
============================================
- Hits 30796 30772 -24
+ Misses 3524 3523 -1
- Partials 1259 1264 +5
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
aherbert
left a comment
There was a problem hiding this comment.
Thanks for the updates. A few small changes required.
Note that CI is failing on checkstyle unused imports.
| shiftedP[i] = shiftedP[i - 1]; | ||
| } | ||
| // shift rows | ||
| if (shiftedP.length - 1 >= 0) System.arraycopy(shiftedP, 0, shiftedP, 1, shiftedP.length - 1); |
There was a problem hiding this comment.
Should this be if (shiftedP.length -1 > 0) (since we cannot copy length=0).
Please add enclosing braces.
| return normalization == Norm.ORTHO ? | ||
| f -> TransformUtils.scaleInPlace(fct(f), Math.sqrt(2d / (f.length - 1))) : | ||
| f -> fct(f); | ||
| this::fct; |
| return normalization == Norm.ORTHO ? | ||
| f -> TransformUtils.scaleInPlace(fst(f), Math.sqrt(2d / f.length)) : | ||
| f -> fst(f); | ||
| this::fst; |
|
done. @aherbert |
|
Still failing on the same checkstyle violation. Run locally: |
hi @aherbert |
aherbert
left a comment
There was a problem hiding this comment.
Some minor reversions please. Thanks.
| public SparseGradient copySign(final SparseGradient sign) { | ||
| final long m = Double.doubleToLongBits(value); | ||
| final long s = Double.doubleToLongBits(sign.value); | ||
| if ((m >= 0 && s >= 0) || (m < 0 && s < 0)) { // Sign is currently OK |
There was a problem hiding this comment.
Didn't notice this before. I would not remove the extra parentheses as it makes it obvious over knowing the operator precedence of && over ||.
| public SparseGradient copySign(final double sign) { | ||
| final long m = Double.doubleToLongBits(value); | ||
| final long s = Double.doubleToLongBits(sign); | ||
| if ((m >= 0 && s >= 0) || (m < 0 && s < 0)) { // Sign is currently OK |
| private boolean isBetween(double value, | ||
| double boundary1, | ||
| double boundary2) { | ||
| return (value >= boundary1 && value <= boundary2) || |
| // shift rows | ||
| shiftedP[i] = shiftedP[i - 1]; | ||
| // shift rows | ||
| if (shiftedP.length - 1 >= 0) { |
aherbert
left a comment
There was a problem hiding this comment.
A couple of whitespace issues to fix please
| double boundary2) { | ||
| return (value >= boundary1 && value <= boundary2) || | ||
| (value >= boundary2 && value <= boundary1); | ||
| (value >= boundary2 && value <= boundary1); |
There was a problem hiding this comment.
Please revert the indentation too
| return eval.isBetterScore(1, 2) ? | ||
| clusters -> 1 / eval.score(clusters) : | ||
| clusters -> eval.score(clusters); | ||
| eval::score; |
There was a problem hiding this comment.
This has incorrect indentation
* Replace Collections.sort() with List.sort() * Replace Lambda with method reference * Simplifiable 'Map' operations