diff --git a/src/main/java/org/apache/commons/math/ConvergenceException.java b/src/main/java/org/apache/commons/math/ConvergenceException.java deleted file mode 100644 index cf3c3bd54..000000000 --- a/src/main/java/org/apache/commons/math/ConvergenceException.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.math; - -import org.apache.commons.math.exception.util.Localizable; -import org.apache.commons.math.exception.util.LocalizedFormats; - -/** - * Error thrown when a numerical computation can not be performed because the - * numerical result failed to converge to a finite value. - * - * @version $Id$ - */ -public class ConvergenceException extends MathException { - - /** Serializable version identifier */ - private static final long serialVersionUID = -1111352570797662604L; - - /** - * Default constructor. - */ - public ConvergenceException() { - super(LocalizedFormats.CONVERGENCE_FAILED); - } - - /** - * Constructs an exception with specified formatted detail message. - * Message formatting is delegated to {@link java.text.MessageFormat}. - * @param pattern format specifier - * @param arguments format arguments - * @since 2.2 - */ - public ConvergenceException(Localizable pattern, Object ... arguments) { - super(pattern, arguments); - } - - /** - * Create an exception with a given root cause. - * @param cause the exception or error that caused this exception to be thrown - */ - public ConvergenceException(Throwable cause) { - super(cause); - } - - /** - * Constructs an exception with specified formatted detail message and root cause. - * Message formatting is delegated to {@link java.text.MessageFormat}. - * @param cause the exception or error that caused this exception to be thrown - * @param pattern format specifier - * @param arguments format arguments - * @since 2.2 - */ - public ConvergenceException(Throwable cause, Localizable pattern, Object ... arguments) { - super(cause, pattern, arguments); - } - -} diff --git a/src/main/java/org/apache/commons/math/fraction/FractionConversionException.java b/src/main/java/org/apache/commons/math/fraction/FractionConversionException.java index 581325c54..560e0f998 100644 --- a/src/main/java/org/apache/commons/math/fraction/FractionConversionException.java +++ b/src/main/java/org/apache/commons/math/fraction/FractionConversionException.java @@ -17,7 +17,7 @@ package org.apache.commons.math.fraction; -import org.apache.commons.math.ConvergenceException; +import org.apache.commons.math.exception.ConvergenceException; import org.apache.commons.math.exception.util.LocalizedFormats; /** diff --git a/src/main/java/org/apache/commons/math/fraction/FractionFormat.java b/src/main/java/org/apache/commons/math/fraction/FractionFormat.java index 2338666a6..613bc78f3 100644 --- a/src/main/java/org/apache/commons/math/fraction/FractionFormat.java +++ b/src/main/java/org/apache/commons/math/fraction/FractionFormat.java @@ -23,7 +23,7 @@ import java.text.ParseException; import java.text.ParsePosition; import java.util.Locale; -import org.apache.commons.math.ConvergenceException; +import org.apache.commons.math.exception.ConvergenceException; import org.apache.commons.math.MathRuntimeException; import org.apache.commons.math.exception.util.LocalizedFormats; diff --git a/src/main/java/org/apache/commons/math/optimization/OptimizationException.java b/src/main/java/org/apache/commons/math/optimization/OptimizationException.java index 8e4e46bd0..85c7c5b21 100644 --- a/src/main/java/org/apache/commons/math/optimization/OptimizationException.java +++ b/src/main/java/org/apache/commons/math/optimization/OptimizationException.java @@ -17,7 +17,7 @@ package org.apache.commons.math.optimization; -import org.apache.commons.math.ConvergenceException; +import org.apache.commons.math.exception.ConvergenceException; import org.apache.commons.math.exception.util.Localizable; /** @@ -44,12 +44,4 @@ public class OptimizationException extends ConvergenceException { super(specifier, parts); } - /** - * Create an exception with a given root cause. - * @param cause the exception or error that caused this exception to be thrown - */ - public OptimizationException(Throwable cause) { - super(cause); - } - } diff --git a/src/main/java/org/apache/commons/math/optimization/linear/AbstractLinearOptimizer.java b/src/main/java/org/apache/commons/math/optimization/linear/AbstractLinearOptimizer.java index 5e14f209e..54b689da7 100644 --- a/src/main/java/org/apache/commons/math/optimization/linear/AbstractLinearOptimizer.java +++ b/src/main/java/org/apache/commons/math/optimization/linear/AbstractLinearOptimizer.java @@ -90,13 +90,13 @@ public abstract class AbstractLinearOptimizer implements LinearOptimizer { } /** Increment the iterations counter by 1. - * @exception OptimizationException if the maximal number + * @exception MaxCountExceededException if the maximal number * of iterations is exceeded */ protected void incrementIterationsCounter() - throws OptimizationException { + throws MaxCountExceededException { if (++iterations > maxIterations) { - throw new OptimizationException(new MaxCountExceededException(maxIterations)); + throw new MaxCountExceededException(maxIterations); } } diff --git a/src/site/xdoc/changes.xml b/src/site/xdoc/changes.xml index 851b1da2d..27a7fd4f5 100644 --- a/src/site/xdoc/changes.xml +++ b/src/site/xdoc/changes.xml @@ -52,6 +52,9 @@ The type attribute can be add,update,fix,remove. If the output is not quite correct, check for invisible trailing spaces! --> + + The checked ConvergenceException has been replaced by an unchecked ConvergenceException. + ODE step interpolation with Jacobians is now fully merged with classical step interpolation. diff --git a/src/test/java/org/apache/commons/math/ConvergenceExceptionTest.java b/src/test/java/org/apache/commons/math/ConvergenceExceptionTest.java deleted file mode 100644 index 21d047765..000000000 --- a/src/test/java/org/apache/commons/math/ConvergenceExceptionTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math; - - -import java.util.Locale; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @version $Id$ - */ -public class ConvergenceExceptionTest { - - @Test - public void testConstructor(){ - ConvergenceException ex = new ConvergenceException(); - Assert.assertNull(ex.getCause()); - Assert.assertNotNull(ex.getMessage()); - Assert.assertNotNull(ex.getMessage(Locale.FRENCH)); - Assert.assertFalse(ex.getMessage().equals(ex.getMessage(Locale.FRENCH))); - } - - @Test - public void testConstructorCause(){ - String inMsg = "inner message"; - Exception cause = new Exception(inMsg); - ConvergenceException ex = new ConvergenceException(cause); - Assert.assertEquals(cause, ex.getCause()); - } -} diff --git a/src/test/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegratorTest.java b/src/test/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegratorTest.java index d82971320..71c26074c 100644 --- a/src/test/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegratorTest.java +++ b/src/test/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegratorTest.java @@ -18,7 +18,6 @@ package org.apache.commons.math.analysis.integration; import java.util.Random; -import org.apache.commons.math.ConvergenceException; import org.apache.commons.math.MathException; import org.apache.commons.math.analysis.QuinticFunction; import org.apache.commons.math.analysis.SinFunction; @@ -76,8 +75,7 @@ public class LegendreGaussIntegratorTest { } @Test - public void testExactIntegration() - throws ConvergenceException { + public void testExactIntegration() { Random random = new Random(86343623467878363l); for (int n = 2; n < 6; ++n) { LegendreGaussIntegrator integrator = @@ -105,7 +103,7 @@ public class LegendreGaussIntegratorTest { } @Test - public void testIssue464() throws ConvergenceException { + public void testIssue464() { final double value = 0.2; UnivariateRealFunction f = new UnivariateRealFunction() { public double value(double x) { diff --git a/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java b/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java index 05f85bce6..be5f9dcaa 100644 --- a/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java +++ b/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java @@ -19,8 +19,8 @@ package org.apache.commons.math.fraction; import java.math.BigDecimal; import java.math.BigInteger; -import org.apache.commons.math.ConvergenceException; import org.apache.commons.math.TestUtils; +import org.apache.commons.math.exception.ConvergenceException; import org.apache.commons.math.exception.NullArgumentException; import org.apache.commons.math.util.FastMath; import org.junit.Assert; diff --git a/src/test/java/org/apache/commons/math/fraction/FractionTest.java b/src/test/java/org/apache/commons/math/fraction/FractionTest.java index daa1a0e34..124c9ac89 100644 --- a/src/test/java/org/apache/commons/math/fraction/FractionTest.java +++ b/src/test/java/org/apache/commons/math/fraction/FractionTest.java @@ -16,7 +16,7 @@ */ package org.apache.commons.math.fraction; -import org.apache.commons.math.ConvergenceException; +import org.apache.commons.math.exception.ConvergenceException; import org.apache.commons.math.exception.MathIllegalArgumentException; import org.apache.commons.math.exception.MathArithmeticException; import org.apache.commons.math.TestUtils; @@ -65,15 +65,10 @@ public class FractionTest { assertFraction(15, 1, new Fraction(15.0000000000001)); } - @Test + @Test(expected=ConvergenceException.class) public void testGoldenRatio() { - try { - // the golden ratio is notoriously a difficult number for continuous fraction - new Fraction((1 + FastMath.sqrt(5)) / 2, 1.0e-12, 25); - Assert.fail("an exception should have been thrown"); - } catch (ConvergenceException ce) { - // expected behavior - } + // the golden ratio is notoriously a difficult number for continuous fraction + new Fraction((1 + FastMath.sqrt(5)) / 2, 1.0e-12, 25); } // MATH-179