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 2019/12/17 01:35:52 UTC

[commons-math] 02/04: Use "Arrays.copyOf" from JDK.

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 f4dd17aa7d68509e41c906dd8e53265985b878b4
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Tue Dec 17 02:17:55 2019 +0100

    Use "Arrays.copyOf" from JDK.
---
 .../fitting/leastsquares/StatisticalReferenceDataset.java    | 10 +++++-----
 .../apache/commons/math4/linear/RealVectorAbstractTest.java  |  4 ++--
 .../commons/math4/stat/descriptive/rank/PercentileTest.java  |  3 +--
 .../math4/stat/inference/KolmogorovSmirnovTestTest.java      | 12 ++++++------
 4 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java
index 491a463..9af6c8b 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/StatisticalReferenceDataset.java
@@ -19,10 +19,10 @@ package org.apache.commons.math4.fitting.leastsquares;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 import org.apache.commons.math4.analysis.MultivariateMatrixFunction;
 import org.apache.commons.math4.analysis.MultivariateVectorFunction;
-import org.apache.commons.math4.util.MathArrays;
 
 /**
  * This class gives access to the statistical reference datasets provided by the
@@ -199,7 +199,7 @@ public abstract class StatisticalReferenceDataset {
      */
     public double[][] getData() {
         return new double[][] {
-            MathArrays.copyOf(x), MathArrays.copyOf(y)
+            Arrays.copyOf(x, x.length), Arrays.copyOf(y, y.length)
         };
     }
 
@@ -238,7 +238,7 @@ public abstract class StatisticalReferenceDataset {
      * @return the values of the parameters
      */
     public double[] getParameters() {
-        return MathArrays.copyOf(a);
+        return Arrays.copyOf(a, a.length);
     }
 
     /**
@@ -257,7 +257,7 @@ public abstract class StatisticalReferenceDataset {
      * @return the standard deviations of the parameters
      */
     public double[] getParametersStandardDeviations() {
-        return MathArrays.copyOf(sigA);
+        return Arrays.copyOf(sigA, sigA.length);
     }
 
     /**
@@ -297,7 +297,7 @@ public abstract class StatisticalReferenceDataset {
      * @return the starting point
      */
     public double[] getStartingPoint(final int i) {
-        return MathArrays.copyOf(startingValues[i]);
+        return Arrays.copyOf(startingValues[i], startingValues[i].length);
     }
 
     /**
diff --git a/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java b/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
index 0324ffc..167566e 100644
--- a/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
@@ -223,7 +223,7 @@ public abstract class RealVectorAbstractTest {
     public void testSetEntry() {
         final double x = getPreferredEntryValue();
         final double[] data = {x, 1d, 2d, x, x};
-        final double[] expected = MathArrays.copyOf(data);
+        final double[] expected = Arrays.copyOf(data, data.length);
         final RealVector actual = create(data);
 
         /*
@@ -270,7 +270,7 @@ public abstract class RealVectorAbstractTest {
         final double x = getPreferredEntryValue();
         final double[] data1 = {x, 1d, 2d, x, x};
 
-        final double[] expected = MathArrays.copyOf(data1);
+        final double[] expected = Arrays.copyOf(data1, data1.length);
         final RealVector actual = create(data1);
 
         /*
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java
index aa2c4c1..b56c610 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PercentileTest.java
@@ -32,7 +32,6 @@ import org.apache.commons.math4.stat.descriptive.rank.Percentile.EstimationType;
 import org.apache.commons.math4.stat.ranking.NaNStrategy;
 import org.apache.commons.math4.util.CentralPivotingStrategy;
 import org.apache.commons.math4.util.KthSelector;
-import org.apache.commons.math4.util.MathArrays;
 import org.apache.commons.math4.util.MedianOf3PivotingStrategy;
 import org.apache.commons.math4.util.PivotingStrategyInterface;
 import org.apache.commons.math4.util.RandomPivotingStrategy;
@@ -630,7 +629,7 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
     public void testAllEstimationTechniquesOnlyLimits() {
         final int N=testArray.length;
 
-        final double[] input=MathArrays.copyOf(testArray);
+        final double[] input = Arrays.copyOf(testArray, testArray.length);
         Arrays.sort(input);
         final double min = input[0];
         final double max=input[input.length-1];
diff --git a/src/test/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTestTest.java b/src/test/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTestTest.java
index e0cea55..852d4f4 100644
--- a/src/test/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTestTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTestTest.java
@@ -709,8 +709,8 @@ public class KolmogorovSmirnovTestTest {
     public void testFixTiesNoOp() throws Exception {
         final double[] x = {0, 1, 2, 3, 4};
         final double[] y = {5, 6, 7, 8};
-        final double[] origX = MathArrays.copyOf(x);
-        final double[] origY = MathArrays.copyOf(y);
+        final double[] origX = Arrays.copyOf(x, x.length);
+        final double[] origY = Arrays.copyOf(y, y.length);
         fixTies(x,y);
         Assert.assertArrayEquals(origX, x, 0);
         Assert.assertArrayEquals(origY, y, 0);
@@ -724,11 +724,11 @@ public class KolmogorovSmirnovTestTest {
     public void testFixTiesConsistency() throws Exception {
         final double[] x = {0, 1, 2, 3, 4, 2};
         final double[] y = {5, 6, 7, 8, 1, 2};
-        final double[] xP = MathArrays.copyOf(x);
-        final double[] yP = MathArrays.copyOf(y);
+        final double[] xP = Arrays.copyOf(x, x.length);
+        final double[] yP = Arrays.copyOf(y, y.length);
         checkFixTies(x, y);
-        final double[] fixedX = MathArrays.copyOf(x);
-        final double[] fixedY = MathArrays.copyOf(y);
+        final double[] fixedX = Arrays.copyOf(x, x.length);
+        final double[] fixedY = Arrays.copyOf(y, y.length);
         checkFixTies(xP, yP);
         Assert.assertArrayEquals(fixedX, xP, 0);
         Assert.assertArrayEquals(fixedY, yP, 0);