You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2015/07/24 02:22:18 UTC
[math] Changed data size check to be positive length,
not > 1 to fix ResizableDoubleArray constructor failure on input
array of length 1.
Repository: commons-math
Updated Branches:
refs/heads/MATH_3_X ae5d8f8a9 -> 9f148d41e
Changed data size check to be positive length, not > 1 to fix
ResizableDoubleArray constructor failure on input array of
length 1.
JIRA: MATH-1252
Thanks to John Bay
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/9f148d41
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/9f148d41
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/9f148d41
Branch: refs/heads/MATH_3_X
Commit: 9f148d41e0cb5839e8680bd3b4c4bc21510e444b
Parents: ae5d8f8
Author: Phil Steitz <ph...@gmail.com>
Authored: Thu Jul 23 20:21:38 2015 -0400
Committer: Phil Steitz <ph...@gmail.com>
Committed: Thu Jul 23 20:21:38 2015 -0400
----------------------------------------------------------------------
src/changes/changes.xml | 3 +++
.../org/apache/commons/math3/util/ResizableDoubleArray.java | 2 +-
.../apache/commons/math3/util/ResizableDoubleArrayTest.java | 8 ++++++++
3 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9f148d41/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 066aa0f..d613ede 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -51,6 +51,9 @@ If the output is not quite correct, check for invisible trailing spaces!
</properties>
<body>
<release version="3.6" date="XXXX-XX-XX" description="">
+ <action dev="psteitz" type="fix" issue="MATH-1252 due-to="John Bay">
+ ResizableDoubleArray constructor does not work with double array of size 1.
+ </action>
<action dev="erans" type="fix" issue="MATH-1251">
Fixed initial value of "number of calls" counter in class "KohonenUpdateAction"
(package "o.a.c.m.ml.neuralnet.sofm").
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9f148d41/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java b/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
index 468ed74..dae2b3b 100644
--- a/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
+++ b/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
@@ -411,7 +411,7 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
numElements = 0;
startIndex = 0;
- if (data != null && data.length > 1) {
+ if (data != null && data.length > 0) {
addElements(data);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/9f148d41/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java
----------------------------------------------------------------------
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 6d9d244..3a1a1d7 100644
--- a/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java
+++ b/src/test/java/org/apache/commons/math3/util/ResizableDoubleArrayTest.java
@@ -125,6 +125,14 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
ResizableDoubleArray copyDa = new ResizableDoubleArray(testDa);
Assert.assertEquals(copyDa, testDa);
Assert.assertEquals(testDa, copyDa);
+
+ // JIRA: MATH-1252
+ final double[] values = {1};
+ testDa = new ResizableDoubleArray(values);
+ Assert.assertArrayEquals(values, testDa.getElements(), 0);
+ Assert.assertEquals(1, testDa.getNumElements());
+ Assert.assertEquals(1, testDa.getElement(0), 0);
+
}