commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject [1/2] [math] Fixed error message for unknown parameter name in ODE.
Date Thu, 11 Jun 2015 12:10:39 GMT
Repository: commons-math
Updated Branches:
  refs/heads/master a55ae8544 -> 2990f6caa


Fixed error message for unknown parameter name in ODE.

JIRA: MATH-1232

Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/8f35fcb8
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/8f35fcb8
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/8f35fcb8

Branch: refs/heads/master
Commit: 8f35fcb8f7b17c7201a31f157e7d77bf3e6fe2b5
Parents: 12ec160
Author: Luc Maisonobe <luc@apache.org>
Authored: Thu Jun 11 13:50:04 2015 +0200
Committer: Luc Maisonobe <luc@apache.org>
Committed: Thu Jun 11 13:50:04 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |  3 +++
 .../math4/ode/UnknownParameterException.java    |  2 +-
 .../commons/math4/ode/JacobianMatricesTest.java | 25 +++++++++++++++-----
 3 files changed, 23 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/8f35fcb8/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 228a7f3..4094a48 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,9 @@ If the output is not quite correct, check for invisible trailing spaces!
     </release>
 
     <release version="4.0" date="XXXX-XX-XX" description="">
+      <action dev="luc" type="fix" issue="MATH-1232"> <!-- backported to 3.6 -->
+        Fixed error message for unknown parameter name in ODE.
+      </action>
       <action dev="luc" type="fix" issue="MATH-1226"> <!-- backported to 3.6 -->
         Fixed wrong event detection in case of close events pairs.
       </action>

http://git-wip-us.apache.org/repos/asf/commons-math/blob/8f35fcb8/src/main/java/org/apache/commons/math4/ode/UnknownParameterException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/UnknownParameterException.java b/src/main/java/org/apache/commons/math4/ode/UnknownParameterException.java
index 75c6210..bbbaa4a 100644
--- a/src/main/java/org/apache/commons/math4/ode/UnknownParameterException.java
+++ b/src/main/java/org/apache/commons/math4/ode/UnknownParameterException.java
@@ -38,7 +38,7 @@ public class UnknownParameterException extends MathIllegalArgumentException
{
      * @param name parameter name.
      */
     public UnknownParameterException(final String name) {
-        super(LocalizedFormats.UNKNOWN_PARAMETER);
+        super(LocalizedFormats.UNKNOWN_PARAMETER, name);
         this.name = name;
     }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/8f35fcb8/src/test/java/org/apache/commons/math4/ode/JacobianMatricesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/ode/JacobianMatricesTest.java b/src/test/java/org/apache/commons/math4/ode/JacobianMatricesTest.java
index b50fe7a..b4e20ed 100644
--- a/src/test/java/org/apache/commons/math4/ode/JacobianMatricesTest.java
+++ b/src/test/java/org/apache/commons/math4/ode/JacobianMatricesTest.java
@@ -103,19 +103,32 @@ public class JacobianMatricesTest {
     }
 
     @Test
+    public void testWrongParameterName() {
+        final String name = "an-unknown-parameter";
+        try {
+            ParamBrusselator brusselator = new ParamBrusselator(2.9);
+            brusselator.setParameter(name, 3.0);
+            Assert.fail("an exception should have been thrown");
+        } catch (UnknownParameterException upe) {
+            Assert.assertTrue(upe.getMessage().contains(name));
+            Assert.assertEquals(name, upe.getName());
+        }
+    }
+
+    @Test
     public void testInternalDifferentiation()
-        throws NumberIsTooSmallException, DimensionMismatchException,
-               MaxCountExceededException, NoBracketingException,
-               UnknownParameterException, MismatchedEquations {
+                    throws NumberIsTooSmallException, DimensionMismatchException,
+                    MaxCountExceededException, NoBracketingException,
+                    UnknownParameterException, MismatchedEquations {
         AbstractIntegrator integ =
-            new DormandPrince54Integrator(1.0e-8, 100.0, new double[] { 1.0e-4, 1.0e-4 },
new double[] { 1.0e-4, 1.0e-4 });
+                        new DormandPrince54Integrator(1.0e-8, 100.0, new double[] { 1.0e-4,
1.0e-4 }, new double[] { 1.0e-4, 1.0e-4 });
         double hP = 1.0e-12;
         double hY = 1.0e-12;
         SummaryStatistics residualsP0 = new SummaryStatistics();
         SummaryStatistics residualsP1 = new SummaryStatistics();
         for (double b = 2.88; b < 3.08; b += 0.001) {
-            ParamBrusselator brusselator = new ParamBrusselator(b);
-            brusselator.setParameter(ParamBrusselator.B, b);
+                ParamBrusselator brusselator = new ParamBrusselator(b);
+                brusselator.setParameter(ParamBrusselator.B, b);
             double[] z = { 1.3, b };
             double[][] dZdZ0 = new double[2][2];
             double[]   dZdP  = new double[2];


Mime
View raw message