From 370fd53bee71047aa394b0f86ed883848d110fac Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Fri, 25 Dec 2015 15:27:00 +0100 Subject: [PATCH] Another round of deprecation warnings removal in tests. --- .../math3/distribution/ExponentialDistributionTest.java | 1 + .../commons/math3/distribution/GammaDistributionTest.java | 1 + .../math3/distribution/RealDistributionAbstractTest.java | 6 ++++++ .../fitting/leastsquares/RandomCirclePointGenerator.java | 3 +-- .../leastsquares/RandomStraightLinePointGenerator.java | 3 +-- .../commons/math3/random/EmpiricalDistributionTest.java | 7 +++++-- .../math3/transform/FastFourierTransformerTest.java | 2 ++ .../commons/math3/util/ResizableDoubleArrayTest.java | 3 +++ 8 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/apache/commons/math3/distribution/ExponentialDistributionTest.java b/src/test/java/org/apache/commons/math3/distribution/ExponentialDistributionTest.java index 35d6e607b..08627b60c 100644 --- a/src/test/java/org/apache/commons/math3/distribution/ExponentialDistributionTest.java +++ b/src/test/java/org/apache/commons/math3/distribution/ExponentialDistributionTest.java @@ -85,6 +85,7 @@ public class ExponentialDistributionTest extends RealDistributionAbstractTest { @Test public void testCumulativeProbability2() { + @SuppressWarnings("deprecation") double actual = getDistribution().cumulativeProbability(0.25, 0.75); Assert.assertEquals(0.0905214, actual, 10e-4); } diff --git a/src/test/java/org/apache/commons/math3/distribution/GammaDistributionTest.java b/src/test/java/org/apache/commons/math3/distribution/GammaDistributionTest.java index c07bbe1a6..01115b738 100644 --- a/src/test/java/org/apache/commons/math3/distribution/GammaDistributionTest.java +++ b/src/test/java/org/apache/commons/math3/distribution/GammaDistributionTest.java @@ -74,6 +74,7 @@ public class GammaDistributionTest extends RealDistributionAbstractTest { } //---------------------------- Additional test cases ------------------------- + @SuppressWarnings("deprecation") @Test public void testParameterAccessors() { GammaDistribution distribution = (GammaDistribution) getDistribution(); diff --git a/src/test/java/org/apache/commons/math3/distribution/RealDistributionAbstractTest.java b/src/test/java/org/apache/commons/math3/distribution/RealDistributionAbstractTest.java index 4ca1fb8a0..d795ee770 100644 --- a/src/test/java/org/apache/commons/math3/distribution/RealDistributionAbstractTest.java +++ b/src/test/java/org/apache/commons/math3/distribution/RealDistributionAbstractTest.java @@ -171,6 +171,7 @@ public abstract class RealDistributionAbstractTest { * Verifies that cumulative probability density calculations match expected values * using current test instance data */ + @SuppressWarnings("deprecation") protected void verifyCumulativeProbabilities() { // verify cumulativeProbability(double) for (int i = 0; i < cumulativeTestPoints.length; i++) { @@ -278,6 +279,7 @@ public abstract class RealDistributionAbstractTest { /** * Verifies that probability computations are consistent */ + @SuppressWarnings("deprecation") @Test public void testConsistency() { for (int i=1; i < cumulativeTestPoints.length; i++) { @@ -303,6 +305,7 @@ public abstract class RealDistributionAbstractTest { /** * Verifies that illegal arguments are correctly handled */ + @SuppressWarnings("deprecation") @Test public void testIllegalArguments() { try { @@ -351,6 +354,7 @@ public abstract class RealDistributionAbstractTest { * interval. Test points outside of the domain of the density function * are discarded. */ + @SuppressWarnings("deprecation") @Test public void testDensityIntegrals() { final double tol = 1.0e-9; @@ -386,6 +390,7 @@ public abstract class RealDistributionAbstractTest { * Verify that isSupportLowerBoundInclusvie returns true iff the lower bound * is finite and density is non-NaN, non-infinite there. */ + @SuppressWarnings("deprecation") @Test public void testIsSupportLowerBoundInclusive() { final double lowerBound = distribution.getSupportLowerBound(); @@ -402,6 +407,7 @@ public abstract class RealDistributionAbstractTest { * Verify that isSupportUpperBoundInclusvie returns true iff the upper bound * is finite and density is non-NaN, non-infinite there. */ + @SuppressWarnings("deprecation") @Test public void testIsSupportUpperBoundInclusive() { final double upperBound = distribution.getSupportUpperBound(); diff --git a/src/test/java/org/apache/commons/math3/fitting/leastsquares/RandomCirclePointGenerator.java b/src/test/java/org/apache/commons/math3/fitting/leastsquares/RandomCirclePointGenerator.java index 3f9a20d11..240ae944b 100644 --- a/src/test/java/org/apache/commons/math3/fitting/leastsquares/RandomCirclePointGenerator.java +++ b/src/test/java/org/apache/commons/math3/fitting/leastsquares/RandomCirclePointGenerator.java @@ -58,8 +58,7 @@ public class RandomCirclePointGenerator { NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY); cY = new NormalDistribution(rng, y, ySigma, NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY); - tP = new UniformRealDistribution(rng, 0, MathUtils.TWO_PI, - UniformRealDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY); + tP = new UniformRealDistribution(rng, 0, MathUtils.TWO_PI); } /** diff --git a/src/test/java/org/apache/commons/math3/fitting/leastsquares/RandomStraightLinePointGenerator.java b/src/test/java/org/apache/commons/math3/fitting/leastsquares/RandomStraightLinePointGenerator.java index 1c60cd21a..39c2009d7 100644 --- a/src/test/java/org/apache/commons/math3/fitting/leastsquares/RandomStraightLinePointGenerator.java +++ b/src/test/java/org/apache/commons/math3/fitting/leastsquares/RandomStraightLinePointGenerator.java @@ -65,8 +65,7 @@ public class RandomStraightLinePointGenerator { intercept = b; error = new NormalDistribution(rng, 0, sigma, NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY); - x = new UniformRealDistribution(rng, lo, hi, - UniformRealDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY); + x = new UniformRealDistribution(rng, lo, hi); } /** diff --git a/src/test/java/org/apache/commons/math3/random/EmpiricalDistributionTest.java b/src/test/java/org/apache/commons/math3/random/EmpiricalDistributionTest.java index c0dd2a488..9e3bc812c 100644 --- a/src/test/java/org/apache/commons/math3/random/EmpiricalDistributionTest.java +++ b/src/test/java/org/apache/commons/math3/random/EmpiricalDistributionTest.java @@ -358,7 +358,9 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes // First bin has mass 11 / 10000, the rest have mass 10 / 10000. final double bMinus = bin == 0 ? 0 : (bin - 1) * binMass + firstBinMass; final RealDistribution kernel = findKernel(lower, upper); + @SuppressWarnings("deprecation") final double withinBinKernelMass = kernel.cumulativeProbability(lower, upper); + @SuppressWarnings("deprecation") final double kernelCum = kernel.cumulativeProbability(lower, testPoints[i]); cumValues[i] = bMinus + (bin == 0 ? firstBinMass : binMass) * kernelCum/withinBinKernelMass; } @@ -377,6 +379,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes binBounds[bin - 1]; final double upper = binBounds[bin]; final RealDistribution kernel = findKernel(lower, upper); + @SuppressWarnings("deprecation") final double withinBinKernelMass = kernel.cumulativeProbability(lower, upper); final double density = kernel.density(testPoints[i]); densityValues[i] = density * (bin == 0 ? firstBinMass : binMass) / withinBinKernelMass; @@ -390,6 +393,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes * will face convergence problems. Only test within-bin integrals and spans * across no more than 3 bin boundaries. */ + @SuppressWarnings("deprecation") @Override @Test public void testDensityIntegrals() { @@ -566,8 +570,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes } @Override protected RealDistribution getKernel(SummaryStatistics bStats) { - return new UniformRealDistribution(randomData.getRandomGenerator(), bStats.getMin(), bStats.getMax(), - UniformRealDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY); + return new UniformRealDistribution(randomData.getRandomGenerator(), bStats.getMin(), bStats.getMax()); } } } diff --git a/src/test/java/org/apache/commons/math3/transform/FastFourierTransformerTest.java b/src/test/java/org/apache/commons/math3/transform/FastFourierTransformerTest.java index af70eed08..8791fc7e9 100644 --- a/src/test/java/org/apache/commons/math3/transform/FastFourierTransformerTest.java +++ b/src/test/java/org/apache/commons/math3/transform/FastFourierTransformerTest.java @@ -484,6 +484,7 @@ public final class FastFourierTransformerTest { * Additional tests for 2D data. */ + @SuppressWarnings("deprecation") @Test public void test2DData() { FastFourierTransformer transformer; @@ -525,6 +526,7 @@ public final class FastFourierTransformerTest { } } + @SuppressWarnings("deprecation") @Test public void test2DDataUnitary() { FastFourierTransformer transformer; diff --git a/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java b/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java index 1a7b45aa6..0ed58e68a 100644 --- a/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java +++ b/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java @@ -43,6 +43,7 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest { ra = new ResizableDoubleArray(); } + @SuppressWarnings("deprecation") @Test public void testConstructors() { float defaultExpansionFactor = 2.0f; @@ -339,6 +340,7 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest { iterations + 1 , eDA2.getNumElements() ); } + @SuppressWarnings("deprecation") @Test public void testWithInitialCapacityAndExpansionFactor() { @@ -447,6 +449,7 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest { } + @SuppressWarnings("deprecation") @Test public void testMutators() { ((ResizableDoubleArray)da).setContractionCriteria(10f);