Skip to content

java 8 improvements. #217

Closed
arturobernalg wants to merge 1 commit intoapache:masterfrom
arturobernalg:feature/java8
Closed

java 8 improvements. #217
arturobernalg wants to merge 1 commit intoapache:masterfrom
arturobernalg:feature/java8

Conversation

@arturobernalg
Copy link
Member

  • Replaced Anonymous type with lambda
  • Replace Collections.sort() with List.sort()
  • Replace Lambda with method reference
  • Simplifiable 'Map' operations

@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2022

Codecov Report

Merging #217 (5fbb985) into master (ec7eb8b) will decrease coverage by 0.01%.
The diff coverage is 93.54%.

❗ Current head 5fbb985 differs from pull request most recent head 05c89f4. Consider uploading reports for the commit 05c89f4 to get more accurate results

@@             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     
Impacted Files Coverage Δ
...s/math4/legacy/ml/clustering/ClusterEvaluator.java 50.00% <ø> (+16.66%) ⬆️
...e/commons/math4/transform/FastCosineTransform.java 100.00% <ø> (ø)
...che/commons/math4/transform/FastSineTransform.java 100.00% <ø> (ø)
...ommons/math4/legacy/fitting/SimpleCurveFitter.java 74.07% <50.00%> (ø)
...y/ode/nonstiff/AdamsNordsieckFieldTransformer.java 98.61% <66.66%> (-1.39%) ⬇️
...egacy/analysis/differentiation/SparseGradient.java 96.88% <100.00%> (+0.57%) ⬆️
...ons/math4/legacy/analysis/solvers/BrentSolver.java 77.27% <100.00%> (ø)
...pache/commons/math4/legacy/genetics/RandomKey.java 89.55% <100.00%> (ø)
...linear/scalar/MultiStartMultivariateOptimizer.java 73.68% <100.00%> (ø)
...linear/scalar/noderiv/HedarFukushimaTransform.java 69.76% <100.00%> (ø)
... and 8 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@aherbert aherbert 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 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);
Copy link
Contributor

Choose a reason for hiding this comment

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

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace indentation

return normalization == Norm.ORTHO ?
f -> TransformUtils.scaleInPlace(fst(f), Math.sqrt(2d / f.length)) :
f -> fst(f);
this::fst;
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation again

@arturobernalg
Copy link
Member Author

done. @aherbert

@aherbert
Copy link
Contributor

Still failing on the same checkstyle violation. Run locally: mvn checkstyle:check and fix the neuralnetworks module (and maybe others).

@arturobernalg
Copy link
Member Author

Still failing on the same checkstyle violation. Run locally: mvn checkstyle:check and fix the neuralnetworks module (and maybe others).

hi @aherbert
Done

Copy link
Contributor

@aherbert aherbert left a comment

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

Didn't notice this before. I would not remove the extra parentheses as it makes it obvious over knowing the operator precedence of && over ||.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

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

Choose a reason for hiding this comment

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

Again please revert

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

private boolean isBetween(double value,
double boundary1,
double boundary2) {
return (value >= boundary1 && value <= boundary2) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

// shift rows
shiftedP[i] = shiftedP[i - 1];
// shift rows
if (shiftedP.length - 1 >= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

use > 0

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

Copy link
Contributor

@aherbert aherbert left a comment

Choose a reason for hiding this comment

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

A couple of whitespace issues to fix please

double boundary2) {
return (value >= boundary1 && value <= boundary2) ||
(value >= boundary2 && value <= boundary1);
(value >= boundary2 && value <= boundary1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert the indentation too

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

return eval.isBetterScore(1, 2) ?
clusters -> 1 / eval.score(clusters) :
clusters -> eval.score(clusters);
eval::score;
Copy link
Contributor

Choose a reason for hiding this comment

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

This has incorrect indentation

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

* Replace Collections.sort() with List.sort()
* Replace Lambda with method reference
* Simplifiable 'Map' operations
@arturobernalg arturobernalg closed this by deleting the head repository Jun 21, 2023
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.

3 participants