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
This commit is contained in:
Phil Steitz 2015-07-23 20:21:38 -04:00
parent ae5d8f8a92
commit 9f148d41e0
3 changed files with 12 additions and 1 deletions

View File

@ -51,6 +51,9 @@ If the output is not quite correct, check for invisible trailing spaces!
</properties> </properties>
<body> <body>
<release version="3.6" date="XXXX-XX-XX" description=""> <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"> <action dev="erans" type="fix" issue="MATH-1251">
Fixed initial value of "number of calls" counter in class "KohonenUpdateAction" Fixed initial value of "number of calls" counter in class "KohonenUpdateAction"
(package "o.a.c.m.ml.neuralnet.sofm"). (package "o.a.c.m.ml.neuralnet.sofm").

View File

@ -411,7 +411,7 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
numElements = 0; numElements = 0;
startIndex = 0; startIndex = 0;
if (data != null && data.length > 1) { if (data != null && data.length > 0) {
addElements(data); addElements(data);
} }
} }

View File

@ -125,6 +125,14 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
ResizableDoubleArray copyDa = new ResizableDoubleArray(testDa); ResizableDoubleArray copyDa = new ResizableDoubleArray(testDa);
Assert.assertEquals(copyDa, testDa); Assert.assertEquals(copyDa, testDa);
Assert.assertEquals(testDa, copyDa); 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);
} }