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:35:25 -04:00
parent 5d49c9797e
commit 09fe956a62
3 changed files with 12 additions and 2 deletions

View File

@ -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="psteitz" type="fix" issue="MATH-1252 due-to="John Bay"> <!-- backported to 3.6 -->
ResizableDoubleArray constructor does not work with double array of size 1.
</action>
<action dev="erans" type="fix" issue="MATH-1251"> <!-- backported to 3.6 -->
Fixed initial value of "number of calls" counter in class "KohonenUpdateAction"
(package "o.a.c.m.ml.neuralnet.sofm").
@ -65,7 +68,7 @@ If the output is not quite correct, check for invisible trailing spaces!
<action dev="erans" type="fix" issue="MATH-1248" due-to="Chris Popp"> <!-- backported to 3.6 -->
Removed unnecessary allocations in "BigFraction" (package "o.a.c.m.fraction").
</action>
<action dev="psteitz" type="fix" issue="MATH-1245">
<action dev="psteitz" type="fix" issue="MATH-1245"> <!-- backported to 3.6 -->
Fixed error in computing discrete distribution of D statistics for small-sample
2-sample Kolmogorov-Smirnov tests. Error was causing incorrect p-values returned
by exactP and monteCarloP methods (used by default for small, mid-size samples).

View File

@ -287,7 +287,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);
}
}

View File

@ -124,6 +124,13 @@ 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);
}
@Test