You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2024/08/24 17:46:03 UTC
(commons-math) 03/04: CheckStyle.
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit 9d54ae1b5bf548d398ffd3abffc388d873d5e832
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Sat Aug 24 12:47:44 2024 +0200
CheckStyle.
---
.../commons/math4/legacy/genetics/BinaryChromosome.java | 2 +-
.../org/apache/commons/math4/legacy/genetics/RandomKey.java | 10 +++++-----
.../commons/math4/legacy/genetics/RandomKeyMutation.java | 2 +-
.../commons/math4/legacy/genetics/TournamentSelection.java | 2 +-
.../math4/legacy/ml/clustering/KMeansPlusPlusClusterer.java | 4 ++--
.../commons/math4/legacy/genetics/ListPopulationTest.java | 12 ++++++------
6 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/BinaryChromosome.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/BinaryChromosome.java
index 32fc94d05..d37d4dc6b 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/BinaryChromosome.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/BinaryChromosome.java
@@ -67,7 +67,7 @@ public abstract class BinaryChromosome extends AbstractListChromosome<Integer> {
*/
public static List<Integer> randomBinaryRepresentation(int length) {
// random binary list
- List<Integer> rList= new ArrayList<> (length);
+ List<Integer> rList= new ArrayList<>(length);
for (int j=0; j<length; j++) {
rList.add(GeneticAlgorithm.getRandomGenerator().nextInt(2));
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/RandomKey.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/RandomKey.java
index 003c47661..4ccd2ee81 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/RandomKey.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/RandomKey.java
@@ -72,7 +72,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
public RandomKey(final List<Double> representation) throws InvalidRepresentationException {
super(representation);
// store the sorted representation
- List<Double> sortedRepr = new ArrayList<> (getRepresentation());
+ List<Double> sortedRepr = new ArrayList<>(getRepresentation());
Collections.sort(sortedRepr);
sortedRepresentation = Collections.unmodifiableList(sortedRepr);
// store the permutation of [0,1,...,n-1] list for toString() and isSame() methods
@@ -126,10 +126,10 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
}
// do not modify the original representation
- List<Double> reprCopy = new ArrayList<> (representation);
+ List<Double> reprCopy = new ArrayList<>(representation);
// now find the indices in the original repr and use them for permuting
- List<S> res = new ArrayList<> (l);
+ List<S> res = new ArrayList<>(l);
for (int i=0; i<l; i++) {
int index = reprCopy.indexOf(sortedRepr.get(i));
res.add(sequence.get(index));
@@ -264,7 +264,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
}
int l = originalData.size();
- List<S> origDataCopy = new ArrayList<> (originalData);
+ List<S> origDataCopy = new ArrayList<>(originalData);
Double[] res = new Double[l];
for (int i=0; i<l; i++) {
@@ -291,7 +291,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
* @return list of integers from 0 to l-1
*/
private static List<Integer> baseSequence(final int l) {
- List<Integer> baseSequence = new ArrayList<> (l);
+ List<Integer> baseSequence = new ArrayList<>(l);
for (int i=0; i<l; i++) {
baseSequence.add(i);
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/RandomKeyMutation.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/RandomKeyMutation.java
index be5d9f023..bc01a8b28 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/RandomKeyMutation.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/RandomKeyMutation.java
@@ -46,7 +46,7 @@ public class RandomKeyMutation implements MutationPolicy {
List<Double> repr = originalRk.getRepresentation();
int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size());
- List<Double> newRepr = new ArrayList<> (repr);
+ List<Double> newRepr = new ArrayList<>(repr);
newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble());
return originalRk.newFixedLengthChromosome(newRepr);
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/TournamentSelection.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/TournamentSelection.java
index 847c1bb34..0d3fe76e6 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/TournamentSelection.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/genetics/TournamentSelection.java
@@ -84,7 +84,7 @@ public class TournamentSelection implements SelectionPolicy {
};
// create a copy of the chromosome list
- List<Chromosome> chromosomes = new ArrayList<> (population.getChromosomes());
+ List<Chromosome> chromosomes = new ArrayList<>(population.getChromosomes());
for (int i=0; i<this.arity; i++) {
// select a random individual and add it to the tournament
int rind = GeneticAlgorithm.getRandomGenerator().nextInt(chromosomes.size());
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/KMeansPlusPlusClusterer.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/KMeansPlusPlusClusterer.java
index 7126c47f0..ffe122cf7 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/KMeansPlusPlusClusterer.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ml/clustering/KMeansPlusPlusClusterer.java
@@ -302,7 +302,7 @@ public class KMeansPlusPlusClusterer<T extends Clusterable> extends Clusterer<T>
// Convert to list for indexed access. Make it unmodifiable, since removal of items
// would screw up the logic of this method.
- final List<T> pointList = Collections.unmodifiableList(new ArrayList<> (points));
+ final List<T> pointList = Collections.unmodifiableList(new ArrayList<>(points));
// The number of points in the list.
final int numPoints = pointList.size();
@@ -386,7 +386,7 @@ public class KMeansPlusPlusClusterer<T extends Clusterable> extends Clusterer<T>
final T p = pointList.get(nextPointIndex);
- resultSet.add(new CentroidCluster<T> (p));
+ resultSet.add(new CentroidCluster<>(p));
// Mark it as taken.
taken[nextPointIndex] = true;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/ListPopulationTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/ListPopulationTest.java
index 8537f5c66..500e8428f 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/ListPopulationTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/ListPopulationTest.java
@@ -49,7 +49,7 @@ public class ListPopulationTest {
}
};
- ArrayList<Chromosome> chromosomes = new ArrayList<> ();
+ ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(c1);
chromosomes.add(c2);
chromosomes.add(c3);
@@ -67,7 +67,7 @@ public class ListPopulationTest {
@Test
public void testChromosomes() {
- final ArrayList<Chromosome> chromosomes = new ArrayList<> ();
+ final ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
@@ -115,7 +115,7 @@ public class ListPopulationTest {
@Test(expected = NotPositiveException.class)
public void testChromosomeListConstructorPopulationLimitNotPositive() {
- final ArrayList<Chromosome> chromosomes = new ArrayList<> ();
+ final ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
new ListPopulation(chromosomes, -10) {
@Override
@@ -128,7 +128,7 @@ public class ListPopulationTest {
@Test(expected = NumberIsTooLargeException.class)
public void testConstructorListOfChromosomesBiggerThanPopulationSize() {
- final ArrayList<Chromosome> chromosomes = new ArrayList<> ();
+ final ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
@@ -143,7 +143,7 @@ public class ListPopulationTest {
@Test(expected=NumberIsTooLargeException.class)
public void testAddTooManyChromosomes() {
- final ArrayList<Chromosome> chromosomes = new ArrayList<> ();
+ final ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
@@ -201,7 +201,7 @@ public class ListPopulationTest {
@Test(expected=NumberIsTooSmallException.class)
public void testSetPopulationLimitTooSmall() {
- final ArrayList<Chromosome> chromosomes = new ArrayList<> ();
+ final ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));