From 5321415bc5e6fe2fc3b6a68f53447a72050d407f Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Fri, 1 Oct 2010 02:03:04 +0000 Subject: [PATCH] Unthrown Exceptions git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1003355 13f79535-47bb-0310-9956-ffa450edef68 --- ...icubicSplineInterpolatingFunctionTest.java | 2 +- .../distribution/BetaDistributionTest.java | 4 +-- ...bleMultivariateVectorialOptimizerTest.java | 4 +-- ...ltiStartMultivariateRealOptimizerTest.java | 3 +-- .../direct/MultiDirectionalTest.java | 10 +++----- .../optimization/fitting/CurveFitterTest.java | 7 +++--- ...nLinearConjugateGradientOptimizerTest.java | 25 +++++++++---------- 7 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/test/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java b/src/test/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java index 35526363b..6f5765dc4 100644 --- a/src/test/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java +++ b/src/test/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java @@ -33,7 +33,7 @@ public final class TricubicSplineInterpolatingFunctionTest { * Test preconditions. */ @Test - public void testPreconditions() throws MathException { + public void testPreconditions() throws Exception { double[] xval = new double[] {3, 4, 5, 6.5}; double[] yval = new double[] {-4, -3, -1, 2.5}; double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5}; diff --git a/src/test/java/org/apache/commons/math/distribution/BetaDistributionTest.java b/src/test/java/org/apache/commons/math/distribution/BetaDistributionTest.java index af8166e69..5faac01ce 100644 --- a/src/test/java/org/apache/commons/math/distribution/BetaDistributionTest.java +++ b/src/test/java/org/apache/commons/math/distribution/BetaDistributionTest.java @@ -150,7 +150,7 @@ public class BetaDistributionTest extends TestCase { } } - public void testDensity() throws MathException { + public void testDensity() { double[] x = new double[]{1e-6, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}; checkDensity(0.1, 0.1, x, new double[]{ @@ -280,7 +280,7 @@ public class BetaDistributionTest extends TestCase { } - private void checkDensity(double alpha, double beta, double[] x, double[] expected) throws MathException { + private void checkDensity(double alpha, double beta, double[] x, double[] expected) { BetaDistribution d = new BetaDistributionImpl(alpha, beta); for (int i = 0; i < x.length; i++) { assertEquals(String.format("density at x=%.1f for alpha=%.1f, beta=%.1f", x[i], alpha, beta), expected[i], d.density(x[i]), 1e-5); diff --git a/src/test/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizerTest.java b/src/test/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizerTest.java index 8824c70c1..81d79e6bb 100644 --- a/src/test/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizerTest.java +++ b/src/test/java/org/apache/commons/math/optimization/MultiStartDifferentiableMultivariateVectorialOptimizerTest.java @@ -101,7 +101,7 @@ import org.junit.Test; public class MultiStartDifferentiableMultivariateVectorialOptimizerTest { @Test - public void testTrivial() throws FunctionEvaluationException, OptimizationException { + public void testTrivial() throws FunctionEvaluationException { LinearProblem problem = new LinearProblem(new double[][] { { 2 } }, new double[] { 3 }); DifferentiableMultivariateVectorialOptimizer underlyingOptimizer = @@ -139,7 +139,7 @@ public class MultiStartDifferentiableMultivariateVectorialOptimizerTest { } @Test(expected = ConvergenceException.class) - public void testNoOptimum() throws FunctionEvaluationException, OptimizationException { + public void testNoOptimum() throws FunctionEvaluationException { DifferentiableMultivariateVectorialOptimizer underlyingOptimizer = new GaussNewtonOptimizer(true); JDKRandomGenerator g = new JDKRandomGenerator(); diff --git a/src/test/java/org/apache/commons/math/optimization/MultiStartMultivariateRealOptimizerTest.java b/src/test/java/org/apache/commons/math/optimization/MultiStartMultivariateRealOptimizerTest.java index 385455816..5a2cae850 100644 --- a/src/test/java/org/apache/commons/math/optimization/MultiStartMultivariateRealOptimizerTest.java +++ b/src/test/java/org/apache/commons/math/optimization/MultiStartMultivariateRealOptimizerTest.java @@ -20,7 +20,6 @@ package org.apache.commons.math.optimization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.apache.commons.math.ConvergenceException; import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.analysis.MultivariateRealFunction; import org.apache.commons.math.optimization.direct.NelderMead; @@ -34,7 +33,7 @@ public class MultiStartMultivariateRealOptimizerTest { @Test public void testRosenbrock() - throws FunctionEvaluationException, ConvergenceException { + throws FunctionEvaluationException { Rosenbrock rosenbrock = new Rosenbrock(); NelderMead underlying = new NelderMead(); diff --git a/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java b/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java index dc2435bf7..36aaaac21 100644 --- a/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java +++ b/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java @@ -17,11 +17,9 @@ package org.apache.commons.math.optimization.direct; -import org.apache.commons.math.ConvergenceException; import org.apache.commons.math.FunctionEvaluationException; import org.apache.commons.math.analysis.MultivariateRealFunction; import org.apache.commons.math.optimization.GoalType; -import org.apache.commons.math.optimization.OptimizationException; import org.apache.commons.math.optimization.RealPointValuePair; import org.apache.commons.math.optimization.SimpleScalarValueChecker; import org.apache.commons.math.util.FastMath; @@ -69,7 +67,7 @@ public class MultiDirectionalTest { @Test public void testMinimizeMaximize() - throws FunctionEvaluationException, ConvergenceException { + throws FunctionEvaluationException { // the following function has 4 local extrema: final double xM = -3.841947088256863675365; @@ -130,7 +128,7 @@ public class MultiDirectionalTest { @Test public void testRosenbrock() - throws FunctionEvaluationException, ConvergenceException { + throws FunctionEvaluationException { MultivariateRealFunction rosenbrock = new MultivariateRealFunction() { @@ -162,7 +160,7 @@ public class MultiDirectionalTest { @Test public void testPowell() - throws FunctionEvaluationException, ConvergenceException { + throws FunctionEvaluationException { MultivariateRealFunction powell = new MultivariateRealFunction() { @@ -192,7 +190,7 @@ public class MultiDirectionalTest { @Test public void testMath283() - throws FunctionEvaluationException, OptimizationException { + throws FunctionEvaluationException { // fails because MultiDirectional.iterateSimplex is looping forever // the while(true) should be replaced with a convergence check MultiDirectional multiDirectional = new MultiDirectional(); diff --git a/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java b/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java index 5604e86b2..39c8aea5a 100644 --- a/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java +++ b/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java @@ -18,7 +18,6 @@ package org.apache.commons.math.optimization.fitting; import org.apache.commons.math.FunctionEvaluationException; -import org.apache.commons.math.optimization.OptimizationException; import org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizer; import org.apache.commons.math.util.FastMath; import org.junit.Assert; @@ -28,7 +27,7 @@ public class CurveFitterTest { @Test public void testMath303() - throws OptimizationException, FunctionEvaluationException { + throws FunctionEvaluationException { LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer(); CurveFitter fitter = new CurveFitter(optimizer); @@ -52,7 +51,7 @@ public class CurveFitterTest { @Test public void testMath304() - throws OptimizationException, FunctionEvaluationException { + throws FunctionEvaluationException { LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer(); CurveFitter fitter = new CurveFitter(optimizer); @@ -75,7 +74,7 @@ public class CurveFitterTest { @Test public void testMath372() - throws OptimizationException, FunctionEvaluationException { + throws FunctionEvaluationException { LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer(); CurveFitter curveFitter = new CurveFitter(optimizer); diff --git a/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java b/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java index 8fb034ef7..4db8b4aaf 100644 --- a/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java +++ b/src/test/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizerTest.java @@ -31,7 +31,6 @@ import org.apache.commons.math.analysis.solvers.BrentSolver; import org.apache.commons.math.linear.BlockRealMatrix; import org.apache.commons.math.linear.RealMatrix; import org.apache.commons.math.optimization.GoalType; -import org.apache.commons.math.optimization.OptimizationException; import org.apache.commons.math.optimization.RealPointValuePair; import org.apache.commons.math.optimization.SimpleScalarValueChecker; @@ -104,7 +103,7 @@ extends TestCase { super(name); } - public void testTrivial() throws FunctionEvaluationException, OptimizationException { + public void testTrivial() throws FunctionEvaluationException { LinearProblem problem = new LinearProblem(new double[][] { { 2 } }, new double[] { 3 }); NonLinearConjugateGradientOptimizer optimizer = @@ -117,7 +116,7 @@ extends TestCase { assertEquals(0.0, optimum.getValue(), 1.0e-10); } - public void testColumnsPermutation() throws FunctionEvaluationException, OptimizationException { + public void testColumnsPermutation() throws FunctionEvaluationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, -1.0 }, { 0.0, 2.0 }, { 1.0, -2.0 } }, @@ -135,7 +134,7 @@ extends TestCase { } - public void testNoDependency() throws FunctionEvaluationException, OptimizationException { + public void testNoDependency() throws FunctionEvaluationException { LinearProblem problem = new LinearProblem(new double[][] { { 2, 0, 0, 0, 0, 0 }, { 0, 2, 0, 0, 0, 0 }, @@ -155,7 +154,7 @@ extends TestCase { } } - public void testOneSet() throws FunctionEvaluationException, OptimizationException { + public void testOneSet() throws FunctionEvaluationException { LinearProblem problem = new LinearProblem(new double[][] { { 1, 0, 0 }, @@ -174,7 +173,7 @@ extends TestCase { } - public void testTwoSets() throws FunctionEvaluationException, OptimizationException { + public void testTwoSets() throws FunctionEvaluationException { final double epsilon = 1.0e-7; LinearProblem problem = new LinearProblem(new double[][] { { 2, 1, 0, 4, 0, 0 }, @@ -213,7 +212,7 @@ extends TestCase { } - public void testNonInversible() throws FunctionEvaluationException, OptimizationException { + public void testNonInversible() throws FunctionEvaluationException { LinearProblem problem = new LinearProblem(new double[][] { { 1, 2, -3 }, @@ -229,7 +228,7 @@ extends TestCase { assertTrue(optimum.getValue() > 0.5); } - public void testIllConditioned() throws FunctionEvaluationException, OptimizationException { + public void testIllConditioned() throws FunctionEvaluationException { LinearProblem problem1 = new LinearProblem(new double[][] { { 10.0, 7.0, 8.0, 7.0 }, { 7.0, 5.0, 6.0, 5.0 }, @@ -267,7 +266,7 @@ extends TestCase { } public void testMoreEstimatedParametersSimple() - throws FunctionEvaluationException, OptimizationException { + throws FunctionEvaluationException { LinearProblem problem = new LinearProblem(new double[][] { { 3.0, 2.0, 0.0, 0.0 }, @@ -286,7 +285,7 @@ extends TestCase { } public void testMoreEstimatedParametersUnsorted() - throws FunctionEvaluationException, OptimizationException { + throws FunctionEvaluationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 1.0, 1.0, 1.0, 0.0 }, @@ -303,7 +302,7 @@ extends TestCase { assertEquals(0, optimum.getValue(), 1.0e-10); } - public void testRedundantEquations() throws FunctionEvaluationException, OptimizationException { + public void testRedundantEquations() throws FunctionEvaluationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0 }, { 1.0, -1.0 }, @@ -321,7 +320,7 @@ extends TestCase { } - public void testInconsistentEquations() throws FunctionEvaluationException, OptimizationException { + public void testInconsistentEquations() throws FunctionEvaluationException { LinearProblem problem = new LinearProblem(new double[][] { { 1.0, 1.0 }, { 1.0, -1.0 }, @@ -338,7 +337,7 @@ extends TestCase { } - public void testCircleFitting() throws FunctionEvaluationException, OptimizationException { + public void testCircleFitting() throws FunctionEvaluationException { Circle circle = new Circle(); circle.addPoint( 30.0, 68.0); circle.addPoint( 50.0, -6.0);