Simplify assertions with simpler equivalent. (#196)
This commit is contained in:
parent
872b655950
commit
1e4662de5a
|
@ -522,10 +522,10 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
T t1a = build(1.0);
|
||||
T t1b = build(1.0);
|
||||
T t2 = build(2.0);
|
||||
Assert.assertTrue(t1a.equals(t1a));
|
||||
Assert.assertTrue(t1a.equals(t1b));
|
||||
Assert.assertFalse(t1a.equals(t2));
|
||||
Assert.assertFalse(t1a.equals(new Object()));
|
||||
Assert.assertEquals(t1a, t1a);
|
||||
Assert.assertEquals(t1a, t1b);
|
||||
Assert.assertNotEquals(t1a, t2);
|
||||
Assert.assertNotEquals(t1a, new Object());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -39,26 +39,26 @@ public class PairTest {
|
|||
|
||||
// Check that both APIs refer to the same data.
|
||||
|
||||
Assert.assertTrue(p.getFirst() == p.getKey());
|
||||
Assert.assertTrue(p.getSecond() == p.getValue());
|
||||
Assert.assertSame(p.getFirst(), p.getKey());
|
||||
Assert.assertSame(p.getSecond(), p.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
Pair<Integer, Double> p1 = new Pair<>(null, null);
|
||||
Assert.assertFalse(p1.equals(null));
|
||||
Assert.assertNotEquals(p1, null);
|
||||
|
||||
Pair<Integer, Double> p2 = new Pair<>(null, null);
|
||||
Assert.assertTrue(p1.equals(p2));
|
||||
Assert.assertEquals(p1, p2);
|
||||
|
||||
p1 = new Pair<>(new Integer(1), new Double(2));
|
||||
Assert.assertFalse(p1.equals(p2));
|
||||
Assert.assertNotEquals(p1, p2);
|
||||
|
||||
p2 = new Pair<>(new Integer(1), new Double(2));
|
||||
Assert.assertTrue(p1.equals(p2));
|
||||
Assert.assertEquals(p1, p2);
|
||||
|
||||
Pair<Integer, Float> p3 = new Pair<>(new Integer(1), new Float(2));
|
||||
Assert.assertFalse(p1.equals(p3));
|
||||
Assert.assertNotEquals(p1, p3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -69,11 +69,11 @@ public class PairTest {
|
|||
final Pair<MyInteger, MyInteger> p1 = new Pair<>(m1, m1);
|
||||
final Pair<MyInteger, MyInteger> p2 = new Pair<>(m2, m2);
|
||||
// Same contents, same hash code.
|
||||
Assert.assertTrue(p1.hashCode() == p2.hashCode());
|
||||
Assert.assertEquals(p1.hashCode(), p2.hashCode());
|
||||
|
||||
// Different contents, different hash codes.
|
||||
m2.set(2);
|
||||
Assert.assertFalse(p1.hashCode() == p2.hashCode());
|
||||
Assert.assertNotEquals(p1.hashCode(), p2.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1433,12 +1433,12 @@ public class AccurateMathTest {
|
|||
// Note: Long.MAX_VALUE isn't actually an infinity, so its parity affects the sign of resulting zero.
|
||||
for (double d : DOUBLES) {
|
||||
if (Math.abs(d) > 1.0) {
|
||||
assertTrue(AccurateMath.pow(d, Long.MIN_VALUE + 1L) == 0.0);
|
||||
assertEquals(0.0, AccurateMath.pow(d, Long.MIN_VALUE + 1L), 0.0);
|
||||
}
|
||||
}
|
||||
for (double d : DOUBLES) {
|
||||
if (Math.abs(d) < 1.0) {
|
||||
assertTrue(AccurateMath.pow(d, Long.MAX_VALUE) == 0.0);
|
||||
assertEquals(0.0, AccurateMath.pow(d, Long.MAX_VALUE), 0.0);
|
||||
}
|
||||
}
|
||||
// If the absolute value of the first argument equals 1 and the second argument is infinite, then the result is NaN. <- Impossible with int.
|
||||
|
@ -1962,8 +1962,8 @@ public class AccurateMathTest {
|
|||
|
||||
x = 4503599627370497.0; // x = Math.pow(2, 52) + 1;
|
||||
assertEquals("4503599627370497", new BigDecimal(x).toString());
|
||||
assertTrue(x == Math.rint(x));
|
||||
assertTrue(x == AccurateMath.round(x));
|
||||
assertEquals(x, Math.rint(x), 0.0);
|
||||
assertEquals(x, AccurateMath.round(x), 0.0);
|
||||
//assertTrue(x == Math.round(x)); // fails with Java 7, fixed in Java 8
|
||||
}
|
||||
|
||||
|
|
|
@ -93,9 +93,9 @@ public class ExceptionContextTest {
|
|||
ObjectInputStream ois = new ObjectInputStream(bis);
|
||||
ExceptionContext cIn = (ExceptionContext) ois.readObject();
|
||||
|
||||
Assert.assertTrue(cOut.getMessage().equals(cIn.getMessage()));
|
||||
Assert.assertEquals(cOut.getMessage(), cIn.getMessage());
|
||||
for (String key : cIn.getKeys()) {
|
||||
Assert.assertTrue(cOut.getValue(key).equals(cIn.getValue(key)));
|
||||
Assert.assertEquals(cOut.getValue(key), cIn.getValue(key));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1233,7 +1233,7 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest<De
|
|||
|
||||
DerivativeStructure plusZero = new DerivativeStructure(1, 1, 0, +0.0);
|
||||
Assert.assertEquals(+0.0, plusZero.signum().getPartialDerivative(0), 1.0e-15);
|
||||
Assert.assertTrue(Double.doubleToLongBits(plusZero.signum().getValue()) == 0);
|
||||
Assert.assertEquals(0, Double.doubleToLongBits(plusZero.signum().getValue()));
|
||||
Assert.assertEquals( 0.0, plusZero.signum().getPartialDerivative(1), 1.0e-15);
|
||||
|
||||
}
|
||||
|
|
|
@ -857,7 +857,7 @@ public class SparseGradientTest extends ExtendedFieldElementAbstractTest<SparseG
|
|||
|
||||
SparseGradient plusZero = SparseGradient.createVariable(0, +0.0);
|
||||
Assert.assertEquals(+0.0, plusZero.signum().getValue(), 1.0e-15);
|
||||
Assert.assertTrue(Double.doubleToLongBits(plusZero.signum().getValue()) == 0);
|
||||
Assert.assertEquals(0, Double.doubleToLongBits(plusZero.signum().getValue()));
|
||||
Assert.assertEquals( 0.0, plusZero.signum().getDerivative(0), 1.0e-15);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.analysis.polynomials;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
|
||||
|
@ -62,7 +61,7 @@ public class PolynomialSplineFunctionTest {
|
|||
public void testConstructor() {
|
||||
PolynomialSplineFunction spline =
|
||||
new PolynomialSplineFunction(knots, polynomials);
|
||||
Assert.assertTrue(Arrays.equals(knots, spline.getKnots()));
|
||||
Assert.assertArrayEquals(knots, spline.getKnots(), 0.0);
|
||||
Assert.assertEquals(1d, spline.getPolynomials()[0].getCoefficients()[2], 0);
|
||||
Assert.assertEquals(3, spline.getN());
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.commons.math4.legacy.distribution.fitting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math4.legacy.distribution.MixtureMultivariateNormalDistribution;
|
||||
|
@ -182,7 +181,7 @@ public class MultivariateNormalMixtureExpectationMaximizationTest {
|
|||
Math.ulp(1d));
|
||||
|
||||
final double[] means = component.getValue().getMeans();
|
||||
Assert.assertTrue(Arrays.equals(correctMeans[i], means));
|
||||
Assert.assertArrayEquals(correctMeans[i], means, 0.0);
|
||||
|
||||
final RealMatrix covMat = component.getValue().getCovariances();
|
||||
Assert.assertEquals(correctCovMats[i], covMat);
|
||||
|
@ -236,7 +235,7 @@ public class MultivariateNormalMixtureExpectationMaximizationTest {
|
|||
final double[] mean = mvn.getMeans();
|
||||
final RealMatrix covMat = mvn.getCovariances();
|
||||
Assert.assertEquals(correctWeights[i], weight, Math.ulp(1d));
|
||||
Assert.assertTrue(Arrays.equals(correctMeans[i], mean));
|
||||
Assert.assertArrayEquals(correctMeans[i], mean, 0.0);
|
||||
Assert.assertEquals(correctCovMats[i], covMat);
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -524,10 +524,10 @@ public abstract class ExtendedFieldElementAbstractTest<T extends RealFieldElemen
|
|||
T t1a = build(1.0);
|
||||
T t1b = build(1.0);
|
||||
T t2 = build(2.0);
|
||||
Assert.assertTrue(t1a.equals(t1a));
|
||||
Assert.assertTrue(t1a.equals(t1b));
|
||||
Assert.assertFalse(t1a.equals(t2));
|
||||
Assert.assertFalse(t1a.equals(new Object()));
|
||||
Assert.assertEquals(t1a, t1a);
|
||||
Assert.assertEquals(t1a, t1b);
|
||||
Assert.assertNotEquals(t1a, t2);
|
||||
Assert.assertNotEquals(t1a, new Object());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -87,11 +87,11 @@ public class WeightedObservedPointsTest {
|
|||
store.add(new WeightedObservedPoint(2, -3, -4));
|
||||
|
||||
final List<WeightedObservedPoint> list = store.toList();
|
||||
Assert.assertTrue(list.size() == 2);
|
||||
Assert.assertEquals(2, list.size());
|
||||
|
||||
// Adding an element to "list" has no impact on "store".
|
||||
list.add(new WeightedObservedPoint(1.2, 3.4, 5.6));
|
||||
Assert.assertFalse(list.size() == store.toList().size());
|
||||
Assert.assertNotEquals(list.size(), store.toList().size());
|
||||
|
||||
// Clearing "store" has no impact on "list".
|
||||
store.clear();
|
||||
|
|
|
@ -36,13 +36,13 @@ public class EvaluationRmsCheckerTest {
|
|||
|
||||
//action + verify
|
||||
//just matches rel tol
|
||||
Assert.assertEquals(true, checker.converged(0, e200, mockEvaluation(210)));
|
||||
Assert.assertTrue(checker.converged(0, e200, mockEvaluation(210)));
|
||||
//just matches abs tol
|
||||
Assert.assertEquals(true, checker.converged(0, e1, mockEvaluation(1.9)));
|
||||
Assert.assertTrue(checker.converged(0, e1, mockEvaluation(1.9)));
|
||||
//matches both
|
||||
Assert.assertEquals(true, checker.converged(0, e1, mockEvaluation(1.01)));
|
||||
Assert.assertTrue(checker.converged(0, e1, mockEvaluation(1.01)));
|
||||
//matches neither
|
||||
Assert.assertEquals(false, checker.converged(0, e200, mockEvaluation(300)));
|
||||
Assert.assertFalse(checker.converged(0, e200, mockEvaluation(300)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,7 +106,7 @@ public final class Array2DRowRealMatrixTest {
|
|||
Assert.assertTrue("testData is square",m.isSquare());
|
||||
Assert.assertEquals("testData2 row dimension",m2.getRowDimension(),2);
|
||||
Assert.assertEquals("testData2 column dimension",m2.getColumnDimension(),3);
|
||||
Assert.assertTrue("testData2 is not square",!m2.isSquare());
|
||||
Assert.assertFalse("testData2 is not square", m2.isSquare());
|
||||
}
|
||||
|
||||
/** test copy functions */
|
||||
|
@ -895,9 +895,9 @@ public final class Array2DRowRealMatrixTest {
|
|||
Assert.assertEquals(m.hashCode(), m1.hashCode());
|
||||
Assert.assertEquals(m, m);
|
||||
Assert.assertEquals(m, m1);
|
||||
Assert.assertFalse(m.equals(null));
|
||||
Assert.assertFalse(m.equals(mt));
|
||||
Assert.assertFalse(m.equals(new Array2DRowRealMatrix(bigSingular)));
|
||||
Assert.assertNotEquals(m, null);
|
||||
Assert.assertNotEquals(m, mt);
|
||||
Assert.assertNotEquals(m, new Array2DRowRealMatrix(bigSingular));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -152,9 +152,9 @@ public class BiDiagonalTransformerTest {
|
|||
Assert.assertEquals(0, v.subtract(vRef).getNorm(), 1.0e-14);
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(u == transformer.getU());
|
||||
Assert.assertTrue(b == transformer.getB());
|
||||
Assert.assertTrue(v == transformer.getV());
|
||||
Assert.assertSame(u, transformer.getU());
|
||||
Assert.assertSame(b, transformer.getB());
|
||||
Assert.assertSame(v, transformer.getV());
|
||||
|
||||
}
|
||||
|
||||
|
@ -185,9 +185,9 @@ public class BiDiagonalTransformerTest {
|
|||
Assert.assertEquals(0, v.subtract(vRef).getNorm(), 1.0e-14);
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(u == transformer.getU());
|
||||
Assert.assertTrue(b == transformer.getB());
|
||||
Assert.assertTrue(v == transformer.getV());
|
||||
Assert.assertSame(u, transformer.getU());
|
||||
Assert.assertSame(b, transformer.getB());
|
||||
Assert.assertSame(v, transformer.getV());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class BigRealFieldTest {
|
|||
public void testSerial() {
|
||||
// deserializing the singleton should give the singleton itself back
|
||||
BigRealField field = BigRealField.getInstance();
|
||||
Assert.assertTrue(field == TestUtils.serializeAndRecover(field));
|
||||
Assert.assertSame(field, TestUtils.serializeAndRecover(field));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -166,15 +166,15 @@ public class BigRealTest {
|
|||
public void testEqualsAndHashCode() {
|
||||
BigReal zero = new BigReal(0.0);
|
||||
BigReal nullReal = null;
|
||||
Assert.assertTrue(zero.equals(zero));
|
||||
Assert.assertFalse(zero.equals(nullReal));
|
||||
Assert.assertEquals(zero, zero);
|
||||
Assert.assertNotEquals(zero, nullReal);
|
||||
Assert.assertFalse(zero.equals(Double.valueOf(0)));
|
||||
BigReal zero2 = new BigReal(0.0);
|
||||
Assert.assertTrue(zero.equals(zero2));
|
||||
Assert.assertEquals(zero, zero2);
|
||||
Assert.assertEquals(zero.hashCode(), zero2.hashCode());
|
||||
BigReal one = new BigReal(1.0);
|
||||
Assert.assertFalse(one.equals(zero) || zero.equals(one));
|
||||
Assert.assertTrue(one.equals(BigReal.ONE));
|
||||
Assert.assertEquals(one, BigReal.ONE);
|
||||
BigReal oneWithScaleOne = new BigReal(new BigDecimal("1.0"));
|
||||
BigReal oneWithScaleTwo = new BigReal(new BigDecimal("1.00"));
|
||||
Assert.assertEquals(oneWithScaleOne, oneWithScaleTwo);
|
||||
|
|
|
@ -164,7 +164,7 @@ public final class BlockFieldMatrixTest {
|
|||
Assert.assertTrue("testData is square",m.isSquare());
|
||||
Assert.assertEquals("testData2 row dimension",m2.getRowDimension(),2);
|
||||
Assert.assertEquals("testData2 column dimension",m2.getColumnDimension(),3);
|
||||
Assert.assertTrue("testData2 is not square",!m2.isSquare());
|
||||
Assert.assertFalse("testData2 is not square", m2.isSquare());
|
||||
}
|
||||
|
||||
/** test copy functions */
|
||||
|
@ -1025,7 +1025,7 @@ public final class BlockFieldMatrixTest {
|
|||
@Test
|
||||
public void testSetRow() {
|
||||
FieldMatrix<Dfp> m = new BlockFieldMatrix<>(subTestData);
|
||||
Assert.assertTrue(subRow3[0][0] != m.getRow(0)[0]);
|
||||
Assert.assertNotSame(subRow3[0][0], m.getRow(0)[0]);
|
||||
m.setRow(0, subRow3[0]);
|
||||
checkArrays(subRow3[0], m.getRow(0));
|
||||
try {
|
||||
|
@ -1088,7 +1088,7 @@ public final class BlockFieldMatrixTest {
|
|||
public void testSetColumn() {
|
||||
FieldMatrix<Dfp> m = new BlockFieldMatrix<>(subTestData);
|
||||
Dfp[] mColumn3 = columnToArray(subColumn3);
|
||||
Assert.assertTrue(mColumn3[0] != m.getColumn(1)[0]);
|
||||
Assert.assertNotSame(mColumn3[0], m.getColumn(1)[0]);
|
||||
m.setColumn(1, mColumn3);
|
||||
checkArrays(mColumn3, m.getColumn(1));
|
||||
try {
|
||||
|
@ -1150,9 +1150,9 @@ public final class BlockFieldMatrixTest {
|
|||
Assert.assertEquals(m.hashCode(), m1.hashCode());
|
||||
Assert.assertEquals(m, m);
|
||||
Assert.assertEquals(m, m1);
|
||||
Assert.assertFalse(m.equals(null));
|
||||
Assert.assertFalse(m.equals(mt));
|
||||
Assert.assertFalse(m.equals(new BlockFieldMatrix<>(bigSingular)));
|
||||
Assert.assertNotEquals(m, null);
|
||||
Assert.assertNotEquals(m, mt);
|
||||
Assert.assertNotEquals(m, new BlockFieldMatrix<>(bigSingular));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -106,7 +106,7 @@ public final class BlockRealMatrixTest {
|
|||
Assert.assertTrue("testData is square",m.isSquare());
|
||||
Assert.assertEquals("testData2 row dimension",m2.getRowDimension(),2);
|
||||
Assert.assertEquals("testData2 column dimension",m2.getColumnDimension(),3);
|
||||
Assert.assertTrue("testData2 is not square",!m2.isSquare());
|
||||
Assert.assertFalse("testData2 is not square", m2.isSquare());
|
||||
}
|
||||
|
||||
/** test copy functions */
|
||||
|
@ -1054,9 +1054,9 @@ public final class BlockRealMatrixTest {
|
|||
Assert.assertEquals(m.hashCode(), m1.hashCode());
|
||||
Assert.assertEquals(m, m);
|
||||
Assert.assertEquals(m, m1);
|
||||
Assert.assertFalse(m.equals(null));
|
||||
Assert.assertFalse(m.equals(mt));
|
||||
Assert.assertFalse(m.equals(new BlockRealMatrix(bigSingular)));
|
||||
Assert.assertNotEquals(m, null);
|
||||
Assert.assertNotEquals(m, mt);
|
||||
Assert.assertNotEquals(m, new BlockRealMatrix(bigSingular));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -132,7 +132,7 @@ public class CholeskyDecompositionTest {
|
|||
Assert.assertEquals(0, lt.subtract(lRef.transpose()).getNorm(), 1.0e-13);
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(l == llt.getL());
|
||||
Assert.assertTrue(lt == llt.getLT());
|
||||
Assert.assertSame(l, llt.getL());
|
||||
Assert.assertSame(lt, llt.getLT());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class DiagonalMatrixTest {
|
|||
|
||||
// Check that the underlying was copied.
|
||||
d[0] = 0;
|
||||
Assert.assertFalse(d[0] == m.getEntry(0, 0));
|
||||
Assert.assertNotEquals(d[0], m.getEntry(0, 0), 0.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -72,7 +72,7 @@ public class DiagonalMatrixTest {
|
|||
|
||||
// Check that the underlying is referenced.
|
||||
d[0] = 0;
|
||||
Assert.assertTrue(d[0] == m.getEntry(0, 0));
|
||||
Assert.assertEquals(d[0], m.getEntry(0, 0), 0.0);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -253,9 +253,9 @@ public class FieldLUDecompositionTest {
|
|||
}
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(l == lu.getL());
|
||||
Assert.assertTrue(u == lu.getU());
|
||||
Assert.assertTrue(p == lu.getP());
|
||||
Assert.assertSame(l, lu.getL());
|
||||
Assert.assertSame(u, lu.getU());
|
||||
Assert.assertSame(p, lu.getP());
|
||||
|
||||
}
|
||||
|
||||
|
@ -294,9 +294,9 @@ public class FieldLUDecompositionTest {
|
|||
}
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(l == lu.getL());
|
||||
Assert.assertTrue(u == lu.getU());
|
||||
Assert.assertTrue(p == lu.getP());
|
||||
Assert.assertSame(l, lu.getL());
|
||||
Assert.assertSame(u, lu.getU());
|
||||
Assert.assertSame(p, lu.getP());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -106,7 +106,7 @@ public final class FieldMatrixImplTest {
|
|||
Assert.assertTrue("testData is square",m.isSquare());
|
||||
Assert.assertEquals("testData2 row dimension",m2.getRowDimension(),2);
|
||||
Assert.assertEquals("testData2 column dimension",m2.getColumnDimension(),3);
|
||||
Assert.assertTrue("testData2 is not square",!m2.isSquare());
|
||||
Assert.assertFalse("testData2 is not square", m2.isSquare());
|
||||
}
|
||||
|
||||
/** test copy functions */
|
||||
|
@ -784,7 +784,7 @@ public final class FieldMatrixImplTest {
|
|||
@Test
|
||||
public void testSetRow() {
|
||||
FieldMatrix<Dfp> m = new Array2DRowFieldMatrix<>(subTestData);
|
||||
Assert.assertTrue(subRow3[0][0] != m.getRow(0)[0]);
|
||||
Assert.assertNotSame(subRow3[0][0], m.getRow(0)[0]);
|
||||
m.setRow(0, subRow3[0]);
|
||||
checkArrays(subRow3[0], m.getRow(0));
|
||||
try {
|
||||
|
@ -826,7 +826,7 @@ public final class FieldMatrixImplTest {
|
|||
public void testSetColumn() {
|
||||
FieldMatrix<Dfp> m = new Array2DRowFieldMatrix<>(subTestData);
|
||||
Dfp[] mColumn3 = columnToArray(subColumn3);
|
||||
Assert.assertTrue(mColumn3[0] != m.getColumn(1)[0]);
|
||||
Assert.assertNotSame(mColumn3[0], m.getColumn(1)[0]);
|
||||
m.setColumn(1, mColumn3);
|
||||
checkArrays(mColumn3, m.getColumn(1));
|
||||
try {
|
||||
|
@ -867,9 +867,9 @@ public final class FieldMatrixImplTest {
|
|||
Assert.assertEquals(m.hashCode(), m1.hashCode());
|
||||
Assert.assertEquals(m, m);
|
||||
Assert.assertEquals(m, m1);
|
||||
Assert.assertFalse(m.equals(null));
|
||||
Assert.assertFalse(m.equals(mt));
|
||||
Assert.assertFalse(m.equals(new Array2DRowFieldMatrix<>(bigSingular)));
|
||||
Assert.assertNotEquals(m, null);
|
||||
Assert.assertNotEquals(m, mt);
|
||||
Assert.assertNotEquals(m, new Array2DRowFieldMatrix<>(bigSingular));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -218,7 +218,7 @@ public class HessenbergTransformerTest {
|
|||
Assert.assertEquals(0, h.subtract(MatrixUtils.createRealMatrix(hRef)).getNorm(), 1.0e-14);
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(p == transformer.getP());
|
||||
Assert.assertTrue(h == transformer.getH());
|
||||
Assert.assertSame(p, transformer.getP());
|
||||
Assert.assertSame(h, transformer.getH());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,9 +243,9 @@ public class LUDecompositionTest {
|
|||
}
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(l == lu.getL());
|
||||
Assert.assertTrue(u == lu.getU());
|
||||
Assert.assertTrue(p == lu.getP());
|
||||
Assert.assertSame(l, lu.getL());
|
||||
Assert.assertSame(u, lu.getU());
|
||||
Assert.assertSame(p, lu.getP());
|
||||
|
||||
}
|
||||
|
||||
|
@ -284,8 +284,8 @@ public class LUDecompositionTest {
|
|||
}
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(l == lu.getL());
|
||||
Assert.assertTrue(u == lu.getU());
|
||||
Assert.assertTrue(p == lu.getP());
|
||||
Assert.assertSame(l, lu.getL());
|
||||
Assert.assertSame(u, lu.getU());
|
||||
Assert.assertSame(p, lu.getP());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,9 +147,9 @@ public class OpenIntToFieldTest {
|
|||
@Test
|
||||
public void testGetFromEmpty() {
|
||||
OpenIntToFieldHashMap<Dfp> map = new OpenIntToFieldHashMap<>(field);
|
||||
Assert.assertTrue(field.getZero().equals(map.get(5)));
|
||||
Assert.assertTrue(field.getZero().equals(map.get(0)));
|
||||
Assert.assertTrue(field.getZero().equals(map.get(50)));
|
||||
Assert.assertEquals(field.getZero(), map.get(5));
|
||||
Assert.assertEquals(field.getZero(), map.get(0));
|
||||
Assert.assertEquals(field.getZero(), map.get(50));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -160,7 +160,7 @@ public class OpenIntToFieldTest {
|
|||
for (Map.Entry<Integer, Dfp> mapEntry : javaMap.entrySet()) {
|
||||
map.remove(mapEntry.getKey());
|
||||
Assert.assertEquals(--mapSize, map.size());
|
||||
Assert.assertTrue(field.getZero().equals(map.get(mapEntry.getKey())));
|
||||
Assert.assertEquals(field.getZero(), map.get(mapEntry.getKey()));
|
||||
}
|
||||
|
||||
/* Ensure that put and get still work correctly after removals */
|
||||
|
@ -178,7 +178,7 @@ public class OpenIntToFieldTest {
|
|||
keysInMap.remove(mapEntry.getKey());
|
||||
map.remove(mapEntry.getKey());
|
||||
Assert.assertEquals(--mapSize, map.size());
|
||||
Assert.assertTrue(field.getZero().equals(map.get(mapEntry.getKey())));
|
||||
Assert.assertEquals(field.getZero(), map.get(mapEntry.getKey()));
|
||||
if (count++ > 5) {
|
||||
break;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class OpenIntToFieldTest {
|
|||
@Test
|
||||
public void testRemoveFromEmpty() {
|
||||
OpenIntToFieldHashMap<Dfp> map = new OpenIntToFieldHashMap<>(field);
|
||||
Assert.assertTrue(field.getZero().equals(map.remove(50)));
|
||||
Assert.assertEquals(field.getZero(), map.remove(50));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -204,7 +204,7 @@ public class OpenIntToFieldTest {
|
|||
for (Map.Entry<Integer, Dfp> mapEntry : generated.entrySet()) {
|
||||
map.remove(mapEntry.getKey());
|
||||
Assert.assertEquals(mapSize, map.size());
|
||||
Assert.assertTrue(field.getZero().equals(map.get(mapEntry.getKey())));
|
||||
Assert.assertEquals(field.getZero(), map.get(mapEntry.getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -234,9 +234,9 @@ public class QRDecompositionTest {
|
|||
Assert.assertEquals(0, h.subtract(hRef).getNorm(), 1.0e-13);
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(q == qr.getQ());
|
||||
Assert.assertTrue(r == qr.getR());
|
||||
Assert.assertTrue(h == qr.getH());
|
||||
Assert.assertSame(q, qr.getQ());
|
||||
Assert.assertSame(r, qr.getR());
|
||||
Assert.assertSame(h, qr.getH());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1337,11 +1337,11 @@ public abstract class RealVectorAbstractTest {
|
|||
public void testEquals() {
|
||||
final RealVector v = create(new double[] { 0, 1, 2 });
|
||||
|
||||
Assert.assertTrue(v.equals(v));
|
||||
Assert.assertTrue(v.equals(v.copy()));
|
||||
Assert.assertFalse(v.equals(null));
|
||||
Assert.assertFalse(v.equals(v.getSubVector(0, v.getDimension() - 1)));
|
||||
Assert.assertTrue(v.equals(v.getSubVector(0, v.getDimension())));
|
||||
Assert.assertEquals(v, v);
|
||||
Assert.assertEquals(v, v.copy());
|
||||
Assert.assertNotEquals(v, null);
|
||||
Assert.assertNotEquals(v, v.getSubVector(0, v.getDimension() - 1));
|
||||
Assert.assertEquals(v, v.getSubVector(0, v.getDimension()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -199,7 +199,7 @@ public class SchurTransformerTest {
|
|||
Assert.assertEquals(0, t.subtract(MatrixUtils.createRealMatrix(hRef)).getNorm(), 1.0e-14);
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(p == transformer.getP());
|
||||
Assert.assertTrue(t == transformer.getT());
|
||||
Assert.assertSame(p, transformer.getP());
|
||||
Assert.assertSame(t, transformer.getT());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,9 +194,9 @@ public class SingularValueDecompositionTest {
|
|||
Assert.assertEquals(0, v.subtract(vRef).getNorm(), normTolerance);
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(u == svd.getU());
|
||||
Assert.assertTrue(s == svd.getS());
|
||||
Assert.assertTrue(v == svd.getV());
|
||||
Assert.assertSame(u, svd.getU());
|
||||
Assert.assertSame(s, svd.getS());
|
||||
Assert.assertSame(v, svd.getV());
|
||||
|
||||
}
|
||||
|
||||
|
@ -233,9 +233,9 @@ public class SingularValueDecompositionTest {
|
|||
Assert.assertEquals(0, v.subtract(vRef).getNorm(), normTolerance);
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(u == svd.getU());
|
||||
Assert.assertTrue(s == svd.getS());
|
||||
Assert.assertTrue(v == svd.getV());
|
||||
Assert.assertSame(u, svd.getU());
|
||||
Assert.assertSame(s, svd.getS());
|
||||
Assert.assertSame(v, svd.getV());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ public class SparseFieldMatrixTest {
|
|||
Assert.assertTrue("testData is square", m.isSquare());
|
||||
Assert.assertEquals("testData2 row dimension", m2.getRowDimension(), 2);
|
||||
Assert.assertEquals("testData2 column dimension", m2.getColumnDimension(), 3);
|
||||
Assert.assertTrue("testData2 is not square", !m2.isSquare());
|
||||
Assert.assertFalse("testData2 is not square", m2.isSquare());
|
||||
}
|
||||
|
||||
/** test copy functions */
|
||||
|
@ -568,9 +568,9 @@ public class SparseFieldMatrixTest {
|
|||
Assert.assertEquals(m.hashCode(), m1.hashCode());
|
||||
Assert.assertEquals(m, m);
|
||||
Assert.assertEquals(m, m1);
|
||||
Assert.assertFalse(m.equals(null));
|
||||
Assert.assertFalse(m.equals(mt));
|
||||
Assert.assertFalse(m.equals(createSparseMatrix(bigSingular)));
|
||||
Assert.assertNotEquals(m, null);
|
||||
Assert.assertNotEquals(m, mt);
|
||||
Assert.assertNotEquals(m, createSparseMatrix(bigSingular));
|
||||
}
|
||||
|
||||
/* Disable for now
|
||||
|
|
|
@ -115,7 +115,7 @@ public final class SparseRealMatrixTest {
|
|||
Assert.assertTrue("testData is square", m.isSquare());
|
||||
Assert.assertEquals("testData2 row dimension", m2.getRowDimension(), 2);
|
||||
Assert.assertEquals("testData2 column dimension", m2.getColumnDimension(), 3);
|
||||
Assert.assertTrue("testData2 is not square", !m2.isSquare());
|
||||
Assert.assertFalse("testData2 is not square", m2.isSquare());
|
||||
}
|
||||
|
||||
/** test copy functions */
|
||||
|
@ -565,9 +565,9 @@ public final class SparseRealMatrixTest {
|
|||
Assert.assertEquals(m.hashCode(), m1.hashCode());
|
||||
Assert.assertEquals(m, m);
|
||||
Assert.assertEquals(m, m1);
|
||||
Assert.assertFalse(m.equals(null));
|
||||
Assert.assertFalse(m.equals(mt));
|
||||
Assert.assertFalse(m.equals(createSparseMatrix(bigSingular)));
|
||||
Assert.assertNotEquals(m, null);
|
||||
Assert.assertNotEquals(m, mt);
|
||||
Assert.assertNotEquals(m, createSparseMatrix(bigSingular));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -171,7 +171,7 @@ public class TriDiagonalTransformerTest {
|
|||
Assert.assertEquals(0, t.subtract(MatrixUtils.createRealMatrix(tData)).getNorm(), 1.0e-14);
|
||||
|
||||
// check the same cached instance is returned the second time
|
||||
Assert.assertTrue(q == transformer.getQ());
|
||||
Assert.assertTrue(t == transformer.getT());
|
||||
Assert.assertSame(q, transformer.getQ());
|
||||
Assert.assertSame(t, transformer.getT());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class FirstOrderConverterTest {
|
|||
for (int i = 1; i < 10; ++i) {
|
||||
SecondOrderDifferentialEquations eqn2 = new Equations(i, 0.2);
|
||||
FirstOrderConverter eqn1 = new FirstOrderConverter(eqn2);
|
||||
Assert.assertTrue(eqn1.getDimension() == (2 * eqn2.getDimension()));
|
||||
Assert.assertEquals(eqn1.getDimension(), 2 * eqn2.getDimension());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest {
|
|||
Assert.assertEquals(regularArray.length, fieldArray.length);
|
||||
for (int i = 0; i < regularArray.length; ++i) {
|
||||
if (regularArray[i] == 0) {
|
||||
Assert.assertTrue(0.0 == fieldArray[i].getReal());
|
||||
Assert.assertEquals(0.0, fieldArray[i].getReal(), 0.0);
|
||||
} else {
|
||||
Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), AccurateMath.ulp(regularArray[i]));
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest {
|
|||
Assert.assertEquals(regularArray.length, fieldArray.length);
|
||||
for (int i = 0; i < regularArray.length; ++i) {
|
||||
if (regularArray[i] == 0) {
|
||||
Assert.assertTrue(0.0 == fieldArray[i].getReal());
|
||||
Assert.assertEquals(0.0, fieldArray[i].getReal(), 0.0);
|
||||
} else {
|
||||
Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), AccurateMath.ulp(regularArray[i]));
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ public abstract class EmbeddedRungeKuttaFieldIntegratorAbstractTest {
|
|||
Assert.assertEquals(regularArray.length, fieldArray.length);
|
||||
for (int i = 0; i < regularArray.length; ++i) {
|
||||
if (regularArray[i] == 0) {
|
||||
Assert.assertTrue(0.0 == fieldArray[i].getReal());
|
||||
Assert.assertEquals(0.0, fieldArray[i].getReal(), 0.0);
|
||||
} else {
|
||||
Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), AccurateMath.ulp(regularArray[i]));
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public abstract class RungeKuttaFieldIntegratorAbstractTest {
|
|||
Assert.assertEquals(regularArray.length, fieldArray.length);
|
||||
for (int i = 0; i < regularArray.length; ++i) {
|
||||
if (regularArray[i] == 0) {
|
||||
Assert.assertTrue(0.0 == fieldArray[i].getReal());
|
||||
Assert.assertEquals(0.0, fieldArray[i].getReal(), 0.0);
|
||||
} else {
|
||||
Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), AccurateMath.ulp(regularArray[i]));
|
||||
}
|
||||
|
|
|
@ -36,19 +36,19 @@ public class PointValuePairTest {
|
|||
public void testEquals() {
|
||||
final double[] p1 = new double[] { 1 };
|
||||
final PointValuePair pv1 = new PointValuePair(p1, 2);
|
||||
Assert.assertFalse(pv1.equals(null));
|
||||
Assert.assertNotEquals(pv1, null);
|
||||
|
||||
final PointValuePair pv2 = new PointValuePair(pv1.getPointRef(), 3);
|
||||
// Same array reference, different objective values.
|
||||
Assert.assertFalse(pv1.equals(pv2));
|
||||
Assert.assertNotEquals(pv1, pv2);
|
||||
|
||||
final PointValuePair pv3 = new PointValuePair(pv2.getPoint(), pv2.getValue());
|
||||
// Different array reference, same array values, same objective values.
|
||||
Assert.assertTrue(pv2.equals(pv3));
|
||||
Assert.assertEquals(pv2, pv3);
|
||||
|
||||
final double[] p2 = new double[] { p1[0] + 1 };
|
||||
final PointValuePair pv4 = new PointValuePair(p2, pv2.getValue());
|
||||
// Different array values, same objective values.
|
||||
Assert.assertFalse(pv2.equals(pv4));
|
||||
Assert.assertNotEquals(pv2, pv4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@ public class SimplexTest {
|
|||
for (int i = 0; i < size; i++) {
|
||||
final double[] e = expected[i];
|
||||
final double[] a = simplex.get(i).getPoint();
|
||||
Assert.assertTrue("i=" + i + ": e=" + Arrays.toString(e) + " a=" + Arrays.toString(a),
|
||||
Arrays.equals(e, a));
|
||||
Assert.assertArrayEquals("i=" + i + ": e=" + Arrays.toString(e) + " a=" + Arrays.toString(a), e, a, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +77,7 @@ public class SimplexTest {
|
|||
final String msg = "i=" + i +
|
||||
": e=" + Arrays.toString(e) +
|
||||
" a=" + Arrays.toString(a);
|
||||
Assert.assertTrue(msg, Arrays.equals(e, a));
|
||||
Assert.assertArrayEquals(msg, e, a, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,8 +117,8 @@ public class SimplexTest {
|
|||
final PointValuePair p = list.get(i);
|
||||
final double[] a = simplex.get(i).getPointRef();
|
||||
final double[] b = p.getPointRef();
|
||||
Assert.assertFalse(a == b);
|
||||
Assert.assertTrue(Arrays.equals(a, b));
|
||||
Assert.assertNotSame(a, b);
|
||||
Assert.assertArrayEquals(a, b, 0.0);
|
||||
Assert.assertTrue(Double.isNaN(p.getValue()));
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +192,7 @@ public class SimplexTest {
|
|||
final double eV = 586;
|
||||
|
||||
final PointValuePair pv = Simplex.newPoint(a, s, b, f);
|
||||
Assert.assertTrue(Arrays.equals(eP, pv.getPoint()));
|
||||
Assert.assertArrayEquals(eP, pv.getPoint(), 0.0);
|
||||
Assert.assertEquals(eV, pv.getValue(), 0d);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ public class MultiStartUnivariateOptimizerTest {
|
|||
}
|
||||
|
||||
// Ensure that the exception was thrown because no optimum was found.
|
||||
Assert.assertTrue(optimizer.getOptima()[0] == null);
|
||||
Assert.assertNull(optimizer.getOptima()[0]);
|
||||
}
|
||||
|
||||
private static class LocalException extends RuntimeException {
|
||||
|
|
|
@ -70,12 +70,8 @@ public final class StatUtilsTest {
|
|||
|
||||
values = new double[] { ONE };
|
||||
|
||||
Assert.assertTrue(
|
||||
"Mean of n = 1 set should be value of single item n1",
|
||||
StatUtils.mean(values) == ONE);
|
||||
Assert.assertTrue(
|
||||
"Variance of n = 1 set should be zero",
|
||||
StatUtils.variance(values) == 0);
|
||||
Assert.assertEquals("Mean of n = 1 set should be value of single item n1", ONE, StatUtils.mean(values), 0.0);
|
||||
Assert.assertEquals("Variance of n = 1 set should be zero", 0, StatUtils.variance(values), 0.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -282,12 +282,12 @@ public class MultivariateSummaryStatisticsTest {
|
|||
MultivariateSummaryStatistics u = createMultivariateSummaryStatistics(2, true);
|
||||
MultivariateSummaryStatistics t = null;
|
||||
int emptyHash = u.hashCode();
|
||||
Assert.assertTrue(u.equals(u));
|
||||
Assert.assertFalse(u.equals(t));
|
||||
Assert.assertEquals(u, u);
|
||||
Assert.assertNotEquals(u, t);
|
||||
Assert.assertFalse(u.equals(Double.valueOf(0)));
|
||||
t = createMultivariateSummaryStatistics(2, true);
|
||||
Assert.assertTrue(t.equals(u));
|
||||
Assert.assertTrue(u.equals(t));
|
||||
Assert.assertEquals(t, u);
|
||||
Assert.assertEquals(u, t);
|
||||
Assert.assertEquals(emptyHash, t.hashCode());
|
||||
|
||||
// Add some data to u
|
||||
|
|
|
@ -462,7 +462,7 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
|
|||
Assert.assertFalse(first.equals(other));
|
||||
|
||||
// Reflexive
|
||||
Assert.assertTrue(first.equals(first));
|
||||
Assert.assertEquals(first, first);
|
||||
|
||||
// Non-argument constructor
|
||||
ResizableDoubleArray second = new ResizableDoubleArray();
|
||||
|
@ -568,15 +568,15 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
|
|||
}
|
||||
|
||||
private void verifyEquality(ResizableDoubleArray a, ResizableDoubleArray b) {
|
||||
Assert.assertTrue(b.equals(a));
|
||||
Assert.assertTrue(a.equals(b));
|
||||
Assert.assertEquals(b, a);
|
||||
Assert.assertEquals(a, b);
|
||||
Assert.assertEquals(a.hashCode(), b.hashCode());
|
||||
}
|
||||
|
||||
private void verifyInequality(ResizableDoubleArray a, ResizableDoubleArray b) {
|
||||
Assert.assertFalse(b.equals(a));
|
||||
Assert.assertFalse(a.equals(b));
|
||||
Assert.assertFalse(a.hashCode() == b.hashCode());
|
||||
Assert.assertNotEquals(b, a);
|
||||
Assert.assertNotEquals(a, b);
|
||||
Assert.assertNotEquals(a.hashCode(), b.hashCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,11 +41,11 @@ public final class StatisticalSummaryValuesTest {
|
|||
public void testEqualsAndHashCode() {
|
||||
StatisticalSummaryValues u = new StatisticalSummaryValues(1, 2, 3, 4, 5, 6);
|
||||
StatisticalSummaryValues t = null;
|
||||
Assert.assertTrue("reflexive", u.equals(u));
|
||||
Assert.assertFalse("non-null compared to null", u.equals(t));
|
||||
Assert.assertEquals("reflexive", u, u);
|
||||
Assert.assertNotEquals("non-null compared to null", u, t);
|
||||
Assert.assertFalse("wrong type", u.equals(Double.valueOf(0)));
|
||||
t = new StatisticalSummaryValues(1, 2, 3, 4, 5, 6);
|
||||
Assert.assertTrue("instances with same data should be equal", t.equals(u));
|
||||
Assert.assertEquals("instances with same data should be equal", t, u);
|
||||
Assert.assertEquals("hash code", u.hashCode(), t.hashCode());
|
||||
|
||||
u = new StatisticalSummaryValues(Double.NaN, 2, 3, 4, 5, 6);
|
||||
|
|
|
@ -108,40 +108,40 @@ public abstract class StorelessUnivariateStatisticAbstractTest
|
|||
(StorelessUnivariateStatistic) getUnivariateStatistic();
|
||||
StorelessUnivariateStatistic statistic2 = null;
|
||||
|
||||
Assert.assertTrue("non-null, compared to null", !statistic.equals(statistic2));
|
||||
Assert.assertTrue("reflexive, non-null", statistic.equals(statistic));
|
||||
Assert.assertFalse("non-null, compared to null", statistic.equals(statistic2));
|
||||
Assert.assertEquals("reflexive, non-null", statistic, statistic);
|
||||
|
||||
int emptyHash = statistic.hashCode();
|
||||
statistic2 = (StorelessUnivariateStatistic) getUnivariateStatistic();
|
||||
Assert.assertTrue("empty stats should be equal", statistic.equals(statistic2));
|
||||
Assert.assertEquals("empty stats should be equal", statistic, statistic2);
|
||||
Assert.assertEquals("empty stats should have the same hashcode",
|
||||
emptyHash, statistic2.hashCode());
|
||||
|
||||
statistic.increment(1d);
|
||||
Assert.assertTrue("reflexive, non-empty", statistic.equals(statistic));
|
||||
Assert.assertTrue("non-empty, compared to empty", !statistic.equals(statistic2));
|
||||
Assert.assertTrue("non-empty, compared to empty", !statistic2.equals(statistic));
|
||||
Assert.assertEquals("reflexive, non-empty", statistic, statistic);
|
||||
Assert.assertNotEquals("non-empty, compared to empty", statistic, statistic2);
|
||||
Assert.assertNotEquals("non-empty, compared to empty", statistic2, statistic);
|
||||
Assert.assertTrue("non-empty stat should have different hashcode from empty stat",
|
||||
statistic.hashCode() != emptyHash);
|
||||
|
||||
statistic2.increment(1d);
|
||||
Assert.assertTrue("stats with same data should be equal", statistic.equals(statistic2));
|
||||
Assert.assertEquals("stats with same data should be equal", statistic, statistic2);
|
||||
Assert.assertEquals("stats with same data should have the same hashcode",
|
||||
statistic.hashCode(), statistic2.hashCode());
|
||||
|
||||
statistic.increment(Double.POSITIVE_INFINITY);
|
||||
Assert.assertTrue("stats with different n's should not be equal", !statistic2.equals(statistic));
|
||||
Assert.assertNotEquals("stats with different n's should not be equal", statistic2, statistic);
|
||||
Assert.assertTrue("stats with different n's should have different hashcodes",
|
||||
statistic.hashCode() != statistic2.hashCode());
|
||||
|
||||
statistic2.increment(Double.POSITIVE_INFINITY);
|
||||
Assert.assertTrue("stats with same data should be equal", statistic.equals(statistic2));
|
||||
Assert.assertEquals("stats with same data should be equal", statistic, statistic2);
|
||||
Assert.assertEquals("stats with same data should have the same hashcode",
|
||||
statistic.hashCode(), statistic2.hashCode());
|
||||
|
||||
statistic.clear();
|
||||
statistic2.clear();
|
||||
Assert.assertTrue("cleared stats should be equal", statistic.equals(statistic2));
|
||||
Assert.assertEquals("cleared stats should be equal", statistic, statistic2);
|
||||
Assert.assertEquals("cleared stats should have thashcode of empty stat",
|
||||
emptyHash, statistic2.hashCode());
|
||||
Assert.assertEquals("cleared stats should have thashcode of empty stat",
|
||||
|
@ -198,16 +198,16 @@ public abstract class StorelessUnivariateStatisticAbstractTest
|
|||
replica = master.copy();
|
||||
|
||||
// Check same
|
||||
Assert.assertTrue(replica.equals(master));
|
||||
Assert.assertTrue(master.equals(replica));
|
||||
Assert.assertEquals(replica, master);
|
||||
Assert.assertEquals(master, replica);
|
||||
|
||||
// Now add second part to both and check again
|
||||
master.incrementAll(testArray,
|
||||
(int) index, (int) (testArray.length - index));
|
||||
replica.incrementAll(testArray,
|
||||
(int) index, (int) (testArray.length - index));
|
||||
Assert.assertTrue(replica.equals(master));
|
||||
Assert.assertTrue(master.equals(replica));
|
||||
Assert.assertEquals(replica, master);
|
||||
Assert.assertEquals(master, replica);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -84,14 +84,10 @@ public class SummaryStatisticsTest {
|
|||
|
||||
/* n=1 */
|
||||
u.addValue(one);
|
||||
Assert.assertTrue("mean should be one (n = 1)",
|
||||
u.getMean() == one);
|
||||
Assert.assertTrue("geometric should be one (n = 1) instead it is " + u.getGeometricMean(),
|
||||
u.getGeometricMean() == one);
|
||||
Assert.assertTrue("Std should be zero (n = 1)",
|
||||
u.getStandardDeviation() == 0.0);
|
||||
Assert.assertTrue("variance should be zero (n = 1)",
|
||||
u.getVariance() == 0.0);
|
||||
Assert.assertEquals("mean should be one (n = 1)", one, u.getMean(), 0.0);
|
||||
Assert.assertEquals("geometric should be one (n = 1) instead it is " + u.getGeometricMean(), one, u.getGeometricMean(), 0.0);
|
||||
Assert.assertEquals("Std should be zero (n = 1)", 0.0, u.getStandardDeviation(), 0.0);
|
||||
Assert.assertEquals("variance should be zero (n = 1)", 0.0, u.getVariance(), 0.0);
|
||||
|
||||
/* n=2 */
|
||||
u.addValue(twoF);
|
||||
|
@ -188,12 +184,12 @@ public class SummaryStatisticsTest {
|
|||
SummaryStatistics u = createSummaryStatistics();
|
||||
SummaryStatistics t = null;
|
||||
int emptyHash = u.hashCode();
|
||||
Assert.assertTrue("reflexive", u.equals(u));
|
||||
Assert.assertFalse("non-null compared to null", u.equals(t));
|
||||
Assert.assertEquals("reflexive", u, u);
|
||||
Assert.assertNotEquals("non-null compared to null", u, t);
|
||||
Assert.assertFalse("wrong type", u.equals(Double.valueOf(0)));
|
||||
t = createSummaryStatistics();
|
||||
Assert.assertTrue("empty instances should be equal", t.equals(u));
|
||||
Assert.assertTrue("empty instances should be equal", u.equals(t));
|
||||
Assert.assertEquals("empty instances should be equal", t, u);
|
||||
Assert.assertEquals("empty instances should be equal", u, t);
|
||||
Assert.assertEquals("empty hash code", emptyHash, t.hashCode());
|
||||
|
||||
// Add some data to u
|
||||
|
@ -201,8 +197,8 @@ public class SummaryStatisticsTest {
|
|||
u.addValue(1d);
|
||||
u.addValue(3d);
|
||||
u.addValue(4d);
|
||||
Assert.assertFalse("different n's should make instances not equal", t.equals(u));
|
||||
Assert.assertFalse("different n's should make instances not equal", u.equals(t));
|
||||
Assert.assertNotEquals("different n's should make instances not equal", t, u);
|
||||
Assert.assertNotEquals("different n's should make instances not equal", u, t);
|
||||
Assert.assertTrue("different n's should make hashcodes different",
|
||||
u.hashCode() != t.hashCode());
|
||||
|
||||
|
@ -211,16 +207,16 @@ public class SummaryStatisticsTest {
|
|||
t.addValue(1d);
|
||||
t.addValue(3d);
|
||||
t.addValue(4d);
|
||||
Assert.assertTrue("summaries based on same data should be equal", t.equals(u));
|
||||
Assert.assertTrue("summaries based on same data should be equal", u.equals(t));
|
||||
Assert.assertEquals("summaries based on same data should be equal", t, u);
|
||||
Assert.assertEquals("summaries based on same data should be equal", u, t);
|
||||
Assert.assertEquals("summaries based on same data should have same hashcodes",
|
||||
u.hashCode(), t.hashCode());
|
||||
|
||||
// Clear and make sure summaries are indistinguishable from empty summary
|
||||
u.clear();
|
||||
t.clear();
|
||||
Assert.assertTrue("empty instances should be equal", t.equals(u));
|
||||
Assert.assertTrue("empty instances should be equal", u.equals(t));
|
||||
Assert.assertEquals("empty instances should be equal", t, u);
|
||||
Assert.assertEquals("empty instances should be equal", u, t);
|
||||
Assert.assertEquals("empty hash code", emptyHash, t.hashCode());
|
||||
Assert.assertEquals("empty hash code", emptyHash, u.hashCode());
|
||||
}
|
||||
|
|
|
@ -82,16 +82,16 @@ public class PSquarePercentileTest extends
|
|||
replica = master.copy();
|
||||
|
||||
// Check same
|
||||
Assert.assertTrue(replica.equals(master));
|
||||
Assert.assertTrue(master.equals(replica));
|
||||
Assert.assertEquals(replica, master);
|
||||
Assert.assertEquals(master, replica);
|
||||
|
||||
// Now add second part to both and check again
|
||||
master.incrementAll(testArray, (int) index,
|
||||
(int) (testArray.length - index));
|
||||
replica.incrementAll(testArray, (int) index,
|
||||
(int) (testArray.length - index));
|
||||
Assert.assertTrue(replica.equals(master));
|
||||
Assert.assertTrue(master.equals(replica));
|
||||
Assert.assertEquals(replica, master);
|
||||
Assert.assertEquals(master, replica);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,17 +116,17 @@ public class PSquarePercentileTest extends
|
|||
replica = master.copy();
|
||||
|
||||
// Check same
|
||||
Assert.assertTrue(replica.equals(master));
|
||||
Assert.assertTrue(master.equals(replica));
|
||||
Assert.assertEquals(replica, master);
|
||||
Assert.assertEquals(master, replica);
|
||||
// Now add second part to both and check again
|
||||
master.incrementAll(testArray, (int) index,
|
||||
(int) (testArray.length - index));
|
||||
replica.incrementAll(testArray, (int) index,
|
||||
(int) (testArray.length - index));
|
||||
Assert.assertTrue(master.equals(master));
|
||||
Assert.assertTrue(replica.equals(replica));
|
||||
Assert.assertTrue(replica.equals(master));
|
||||
Assert.assertTrue(master.equals(replica));
|
||||
Assert.assertEquals(master, master);
|
||||
Assert.assertEquals(replica, replica);
|
||||
Assert.assertEquals(replica, master);
|
||||
Assert.assertEquals(master, replica);
|
||||
}
|
||||
|
||||
@Test(expected = MathIllegalArgumentException.class)
|
||||
|
@ -146,9 +146,9 @@ public class PSquarePercentileTest extends
|
|||
Arrays.asList(new Double[] { 0.02, 1.18, 9.15, 21.91,
|
||||
38.62 }), p);
|
||||
// Markers equality
|
||||
Assert.assertTrue(markers.equals(markers));
|
||||
Assert.assertFalse(markers.equals(null));
|
||||
Assert.assertFalse(markers.equals(""));
|
||||
Assert.assertEquals(markers, markers);
|
||||
Assert.assertNotEquals(markers, null);
|
||||
Assert.assertNotEquals(markers, "");
|
||||
// Check for null markers test during equality testing
|
||||
// Until 5 elements markers are not initialized
|
||||
PSquarePercentile p1 = new PSquarePercentile();
|
||||
|
@ -160,12 +160,12 @@ public class PSquarePercentileTest extends
|
|||
// Move p2 alone with more values just to make sure markers are not null
|
||||
// for p2
|
||||
p2.incrementAll(new double[] { 5.0, 7.0, 11.0 });
|
||||
Assert.assertFalse(p1.equals(p2));
|
||||
Assert.assertFalse(p2.equals(p1));
|
||||
Assert.assertNotEquals(p1, p2);
|
||||
Assert.assertNotEquals(p2, p1);
|
||||
// Next add different data to p1 to make number of elements match and
|
||||
// markers are not null however actual results will vary
|
||||
p1.incrementAll(new double[] { 20, 21, 22, 23 });
|
||||
Assert.assertFalse(p1.equals(p2));// though markers are non null, N
|
||||
Assert.assertNotEquals(p1, p2);// though markers are non null, N
|
||||
// matches, results wont
|
||||
|
||||
}
|
||||
|
@ -197,10 +197,10 @@ public class PSquarePercentileTest extends
|
|||
Arrays.asList(new Double[] { 0.02, 1.18, 9.15, 21.91,
|
||||
38.62 }), p);
|
||||
|
||||
Assert.assertTrue(markers.equals(markersNew));
|
||||
Assert.assertEquals(markers, markersNew);
|
||||
// If just one element of markers got changed then its still false.
|
||||
markersNew.processDataPoint(39);
|
||||
Assert.assertFalse(markers.equals(markersNew));
|
||||
Assert.assertNotEquals(markers, markersNew);
|
||||
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ public class PSquarePercentileTest extends
|
|||
Arrays.asList(new Double[] { 95.1772, 95.1567, 95.1937,
|
||||
95.1959, 95.1442, 95.0610, 95.1591, 95.1195,
|
||||
95.1772, 95.0925, 95.1990, 95.1682 }), 0.0);
|
||||
Assert.assertTrue(m1.equals(m2));
|
||||
Assert.assertEquals(m1, m2);
|
||||
Set<PSquareMarkers> setMarkers = new LinkedHashSet<>();
|
||||
Assert.assertTrue(setMarkers.add(m1));
|
||||
Assert.assertFalse(setMarkers.add(m2));
|
||||
|
@ -252,16 +252,16 @@ public class PSquarePercentileTest extends
|
|||
Arrays.asList(new Double[] { 95.1772, 95.1567, 95.1937,
|
||||
95.1959, 95.1442, 95.0610, 95.1591, 95.1195,
|
||||
95.1772, 95.0925, 95.1990, 95.1682 }), 0.50);
|
||||
Assert.assertTrue(mThis.equals(mThis));
|
||||
Assert.assertFalse(mThis.equals(mThat));
|
||||
Assert.assertEquals(mThis, mThis);
|
||||
Assert.assertNotEquals(mThis, mThat);
|
||||
String s1="";
|
||||
Assert.assertFalse(mThis.equals(s1));
|
||||
Assert.assertNotEquals(mThis, s1);
|
||||
for (int i = 0; i < testArray.length; i++) {
|
||||
mThat.processDataPoint(testArray[i]);
|
||||
}
|
||||
setMarkers.add(mThat);
|
||||
setMarkers.add(mThis);
|
||||
Assert.assertTrue(mThat.equals(mThat));
|
||||
Assert.assertEquals(mThat, mThat);
|
||||
Assert.assertTrue(setMarkers.contains(mThat));
|
||||
Assert.assertTrue(setMarkers.contains(mThis));
|
||||
Assert.assertEquals(3, setMarkers.size());
|
||||
|
@ -321,8 +321,8 @@ public class PSquarePercentileTest extends
|
|||
public void testPSquaredEqualsAndMin() {
|
||||
PSquarePercentile ptile = new PSquarePercentile(0);
|
||||
Assert.assertEquals(ptile, ptile);
|
||||
Assert.assertFalse(ptile.equals(null));
|
||||
Assert.assertFalse(ptile.equals(""));
|
||||
Assert.assertNotEquals(ptile, null);
|
||||
Assert.assertNotEquals(ptile, "");
|
||||
// Just to check if there is no data get result for zeroth and 100th
|
||||
// ptile returns NAN
|
||||
Assert.assertTrue(Double.isNaN(ptile.getResult()));
|
||||
|
|
|
@ -198,8 +198,8 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
|
|||
Assert.assertTrue(Double.isInfinite(percentile.evaluate(specialValues)));
|
||||
specialValues = new double[] {1d, 1d, Double.NaN,
|
||||
Double.NaN};
|
||||
Assert.assertTrue(!Double.isNaN(percentile.evaluate(specialValues)));
|
||||
Assert.assertTrue(1d==percentile.evaluate(specialValues));
|
||||
Assert.assertFalse(Double.isNaN(percentile.evaluate(specialValues)));
|
||||
Assert.assertEquals(1d, percentile.evaluate(specialValues), 0.0);
|
||||
specialValues = new double[] {1d, 1d, Double.NEGATIVE_INFINITY,
|
||||
Double.NEGATIVE_INFINITY};
|
||||
// Interpolation results in NEGATIVE_INFINITY + POSITIVE_INFINITY
|
||||
|
@ -571,8 +571,8 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
|
|||
public void testPercentileWithTechnique() {
|
||||
reset (50, Percentile.EstimationType.LEGACY);
|
||||
final Percentile p = getUnivariateStatistic();
|
||||
Assert.assertTrue(Percentile.EstimationType.LEGACY.equals(p.getEstimationType()));
|
||||
Assert.assertFalse(Percentile.EstimationType.R_1.equals(p.getEstimationType()));
|
||||
Assert.assertEquals(Percentile.EstimationType.LEGACY, p.getEstimationType());
|
||||
Assert.assertNotEquals(Percentile.EstimationType.R_1, p.getEstimationType());
|
||||
}
|
||||
|
||||
static final int TINY = 10;
|
||||
|
@ -615,8 +615,8 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
|
|||
reset(50.0, Percentile.EstimationType.R_7);
|
||||
final Percentile p = getUnivariateStatistic();
|
||||
p.setData(testArray);
|
||||
Assert.assertTrue(Percentile.EstimationType.R_7.equals(p.getEstimationType()));
|
||||
Assert.assertFalse(Percentile.EstimationType.R_1.equals(p.getEstimationType()));
|
||||
Assert.assertEquals(Percentile.EstimationType.R_7, p.getEstimationType());
|
||||
Assert.assertNotEquals(Percentile.EstimationType.R_1, p.getEstimationType());
|
||||
Assert.assertEquals(12d, p.evaluate(), 0d);
|
||||
Assert.assertEquals(12.16d, p.evaluate(60d), 0d);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ChiSquareTestTest {
|
|||
Assert.assertEquals( "chi-square test statistic", 9.023307936427388, testStatistic.chiSquare(expected1, observed1), 1E-10);
|
||||
Assert.assertEquals("chi-square p-value", 0.06051952647453607, testStatistic.chiSquareTest(expected1, observed1), 1E-9);
|
||||
Assert.assertTrue("chi-square test reject", testStatistic.chiSquareTest(expected1, observed1, 0.08));
|
||||
Assert.assertTrue("chi-square test accept", !testStatistic.chiSquareTest(expected1, observed1, 0.05));
|
||||
Assert.assertFalse("chi-square test accept", testStatistic.chiSquareTest(expected1, observed1, 0.05));
|
||||
|
||||
try {
|
||||
testStatistic.chiSquareTest(expected1, observed1, 95);
|
||||
|
@ -110,12 +110,12 @@ public class ChiSquareTestTest {
|
|||
Assert.assertEquals( "chi-square test statistic", 22.709027688, testStatistic.chiSquare(counts), 1E-9);
|
||||
Assert.assertEquals("chi-square p-value", 0.000144751460134, testStatistic.chiSquareTest(counts), 1E-9);
|
||||
Assert.assertTrue("chi-square test reject", testStatistic.chiSquareTest(counts, 0.0002));
|
||||
Assert.assertTrue("chi-square test accept", !testStatistic.chiSquareTest(counts, 0.0001));
|
||||
Assert.assertFalse("chi-square test accept", testStatistic.chiSquareTest(counts, 0.0001));
|
||||
|
||||
long[][] counts2 = {{10, 15}, {30, 40}, {60, 90} };
|
||||
Assert.assertEquals( "chi-square test statistic", 0.168965517241, testStatistic.chiSquare(counts2), 1E-9);
|
||||
Assert.assertEquals("chi-square p-value",0.918987499852, testStatistic.chiSquareTest(counts2), 1E-9);
|
||||
Assert.assertTrue("chi-square test accept", !testStatistic.chiSquareTest(counts2, 0.1));
|
||||
Assert.assertFalse("chi-square test accept", testStatistic.chiSquareTest(counts2, 0.1));
|
||||
|
||||
// ragged input array
|
||||
long[][] counts3 = { {40, 22, 43}, {91, 21, 28}, {60, 10}};
|
||||
|
|
|
@ -55,7 +55,7 @@ public class InferenceTestUtilsTest {
|
|||
Assert.assertEquals( "chi-square test statistic", 9.023307936427388, InferenceTestUtils.chiSquare(expected1, observed1), 1E-10);
|
||||
Assert.assertEquals("chi-square p-value", 0.06051952647453607, InferenceTestUtils.chiSquareTest(expected1, observed1), 1E-9);
|
||||
Assert.assertTrue("chi-square test reject", InferenceTestUtils.chiSquareTest(expected1, observed1, 0.07));
|
||||
Assert.assertTrue("chi-square test accept", !InferenceTestUtils.chiSquareTest(expected1, observed1, 0.05));
|
||||
Assert.assertFalse("chi-square test accept", InferenceTestUtils.chiSquareTest(expected1, observed1, 0.05));
|
||||
|
||||
try {
|
||||
InferenceTestUtils.chiSquareTest(expected1, observed1, 95);
|
||||
|
@ -113,12 +113,12 @@ public class InferenceTestUtilsTest {
|
|||
Assert.assertEquals( "chi-square test statistic", 22.709027688, InferenceTestUtils.chiSquare(counts), 1E-9);
|
||||
Assert.assertEquals("chi-square p-value", 0.000144751460134, InferenceTestUtils.chiSquareTest(counts), 1E-9);
|
||||
Assert.assertTrue("chi-square test reject", InferenceTestUtils.chiSquareTest(counts, 0.0002));
|
||||
Assert.assertTrue("chi-square test accept", !InferenceTestUtils.chiSquareTest(counts, 0.0001));
|
||||
Assert.assertFalse("chi-square test accept", InferenceTestUtils.chiSquareTest(counts, 0.0001));
|
||||
|
||||
long[][] counts2 = {{10, 15}, {30, 40}, {60, 90} };
|
||||
Assert.assertEquals( "chi-square test statistic", 0.168965517241, InferenceTestUtils.chiSquare(counts2), 1E-9);
|
||||
Assert.assertEquals("chi-square p-value",0.918987499852, InferenceTestUtils.chiSquareTest(counts2), 1E-9);
|
||||
Assert.assertTrue("chi-square test accept", !InferenceTestUtils.chiSquareTest(counts2, 0.1));
|
||||
Assert.assertFalse("chi-square test accept", InferenceTestUtils.chiSquareTest(counts2, 0.1));
|
||||
|
||||
// ragged input array
|
||||
long[][] counts3 = { {40, 22, 43}, {91, 21, 28}, {60, 10}};
|
||||
|
@ -291,8 +291,8 @@ public class InferenceTestUtilsTest {
|
|||
InferenceTestUtils.tTest(0d, oneSidedPStats) / 2d, 10E-5);
|
||||
Assert.assertTrue("one sample t-test reject", InferenceTestUtils.tTest(0d, oneSidedP, 0.01));
|
||||
Assert.assertTrue("one sample t-test reject", InferenceTestUtils.tTest(0d, oneSidedPStats, 0.01));
|
||||
Assert.assertTrue("one sample t-test accept", !InferenceTestUtils.tTest(0d, oneSidedP, 0.0001));
|
||||
Assert.assertTrue("one sample t-test accept", !InferenceTestUtils.tTest(0d, oneSidedPStats, 0.0001));
|
||||
Assert.assertFalse("one sample t-test accept", InferenceTestUtils.tTest(0d, oneSidedP, 0.0001));
|
||||
Assert.assertFalse("one sample t-test accept", InferenceTestUtils.tTest(0d, oneSidedPStats, 0.0001));
|
||||
|
||||
try {
|
||||
InferenceTestUtils.tTest(0d, oneSidedP, 95);
|
||||
|
@ -336,10 +336,8 @@ public class InferenceTestUtilsTest {
|
|||
InferenceTestUtils.tTest(sample1, sample2, 0.2));
|
||||
Assert.assertTrue("two sample heteroscedastic t-test reject",
|
||||
InferenceTestUtils.tTest(sampleStats1, sampleStats2, 0.2));
|
||||
Assert.assertTrue("two sample heteroscedastic t-test accept",
|
||||
!InferenceTestUtils.tTest(sample1, sample2, 0.1));
|
||||
Assert.assertTrue("two sample heteroscedastic t-test accept",
|
||||
!InferenceTestUtils.tTest(sampleStats1, sampleStats2, 0.1));
|
||||
Assert.assertFalse("two sample heteroscedastic t-test accept", InferenceTestUtils.tTest(sample1, sample2, 0.1));
|
||||
Assert.assertFalse("two sample heteroscedastic t-test accept", InferenceTestUtils.tTest(sampleStats1, sampleStats2, 0.1));
|
||||
|
||||
try {
|
||||
InferenceTestUtils.tTest(sample1, sample2, .95);
|
||||
|
@ -417,8 +415,7 @@ public class InferenceTestUtilsTest {
|
|||
InferenceTestUtils.homoscedasticTTest(sampleStats1, sampleStats2), 1E-10);
|
||||
Assert.assertTrue("two sample homoscedastic t-test reject",
|
||||
InferenceTestUtils.homoscedasticTTest(sample1, sample2, 0.49));
|
||||
Assert.assertTrue("two sample homoscedastic t-test accept",
|
||||
!InferenceTestUtils.homoscedasticTTest(sample1, sample2, 0.48));
|
||||
Assert.assertFalse("two sample homoscedastic t-test accept", InferenceTestUtils.homoscedasticTTest(sample1, sample2, 0.48));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -122,6 +122,6 @@ public class MannWhitneyUTestTest {
|
|||
d2[i] = i;
|
||||
}
|
||||
double result = testStatistic.mannWhitneyUTest(d1, d2);
|
||||
Assert.assertTrue(result == 1.0);
|
||||
Assert.assertEquals(1.0, result, 0.0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,8 +139,8 @@ public class TTestTest {
|
|||
testStatistic.tTest(0d, oneSidedPStats) / 2d, 10E-5);
|
||||
Assert.assertTrue("one sample t-test reject", testStatistic.tTest(0d, oneSidedP, 0.01));
|
||||
Assert.assertTrue("one sample t-test reject", testStatistic.tTest(0d, oneSidedPStats, 0.01));
|
||||
Assert.assertTrue("one sample t-test accept", !testStatistic.tTest(0d, oneSidedP, 0.0001));
|
||||
Assert.assertTrue("one sample t-test accept", !testStatistic.tTest(0d, oneSidedPStats, 0.0001));
|
||||
Assert.assertFalse("one sample t-test accept", testStatistic.tTest(0d, oneSidedP, 0.0001));
|
||||
Assert.assertFalse("one sample t-test accept", testStatistic.tTest(0d, oneSidedPStats, 0.0001));
|
||||
|
||||
try {
|
||||
testStatistic.tTest(0d, oneSidedP, 95);
|
||||
|
@ -184,10 +184,8 @@ public class TTestTest {
|
|||
testStatistic.tTest(sample1, sample2, 0.2));
|
||||
Assert.assertTrue("two sample heteroscedastic t-test reject",
|
||||
testStatistic.tTest(sampleStats1, sampleStats2, 0.2));
|
||||
Assert.assertTrue("two sample heteroscedastic t-test accept",
|
||||
!testStatistic.tTest(sample1, sample2, 0.1));
|
||||
Assert.assertTrue("two sample heteroscedastic t-test accept",
|
||||
!testStatistic.tTest(sampleStats1, sampleStats2, 0.1));
|
||||
Assert.assertFalse("two sample heteroscedastic t-test accept", testStatistic.tTest(sample1, sample2, 0.1));
|
||||
Assert.assertFalse("two sample heteroscedastic t-test accept", testStatistic.tTest(sampleStats1, sampleStats2, 0.1));
|
||||
|
||||
try {
|
||||
testStatistic.tTest(sample1, sample2, .95);
|
||||
|
@ -265,8 +263,7 @@ public class TTestTest {
|
|||
testStatistic.homoscedasticTTest(sampleStats1, sampleStats2), 1E-10);
|
||||
Assert.assertTrue("two sample homoscedastic t-test reject",
|
||||
testStatistic.homoscedasticTTest(sample1, sample2, 0.49));
|
||||
Assert.assertTrue("two sample homoscedastic t-test accept",
|
||||
!testStatistic.homoscedasticTTest(sample1, sample2, 0.48));
|
||||
Assert.assertFalse("two sample homoscedastic t-test accept", testStatistic.homoscedasticTTest(sample1, sample2, 0.48));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -456,7 +456,7 @@ public final class SimpleRegressionTest {
|
|||
Assert.assertTrue("predict not NaN", Double.isNaN(regression.predict(0)));
|
||||
|
||||
// but SSTO should be OK
|
||||
Assert.assertTrue("SSTO NaN", !Double.isNaN(regression.getTotalSumSquares()));
|
||||
Assert.assertFalse("SSTO NaN", Double.isNaN(regression.getTotalSumSquares()));
|
||||
|
||||
regression = new SimpleRegression();
|
||||
|
||||
|
@ -464,24 +464,24 @@ public final class SimpleRegressionTest {
|
|||
regression.addData(3, 3);
|
||||
|
||||
// All should be OK except MSE, s(b0), s(b1) which need one more df
|
||||
Assert.assertTrue("interceptNaN", !Double.isNaN(regression.getIntercept()));
|
||||
Assert.assertTrue("slope NaN", !Double.isNaN(regression.getSlope()));
|
||||
Assert.assertFalse("interceptNaN", Double.isNaN(regression.getIntercept()));
|
||||
Assert.assertFalse("slope NaN", Double.isNaN(regression.getSlope()));
|
||||
Assert.assertTrue("slope std err not NaN", Double.isNaN(regression.getSlopeStdErr()));
|
||||
Assert.assertTrue("intercept std err not NaN", Double.isNaN(regression.getInterceptStdErr()));
|
||||
Assert.assertTrue("MSE not NaN", Double.isNaN(regression.getMeanSquareError()));
|
||||
Assert.assertTrue("r NaN", !Double.isNaN(regression.getR()));
|
||||
Assert.assertTrue("r-square NaN", !Double.isNaN(regression.getRSquare()));
|
||||
Assert.assertTrue("RSS NaN", !Double.isNaN(regression.getRegressionSumSquares()));
|
||||
Assert.assertTrue("SSE NaN", !Double.isNaN(regression.getSumSquaredErrors()));
|
||||
Assert.assertTrue("SSTO NaN", !Double.isNaN(regression.getTotalSumSquares()));
|
||||
Assert.assertTrue("predict NaN", !Double.isNaN(regression.predict(0)));
|
||||
Assert.assertFalse("r NaN", Double.isNaN(regression.getR()));
|
||||
Assert.assertFalse("r-square NaN", Double.isNaN(regression.getRSquare()));
|
||||
Assert.assertFalse("RSS NaN", Double.isNaN(regression.getRegressionSumSquares()));
|
||||
Assert.assertFalse("SSE NaN", Double.isNaN(regression.getSumSquaredErrors()));
|
||||
Assert.assertFalse("SSTO NaN", Double.isNaN(regression.getTotalSumSquares()));
|
||||
Assert.assertFalse("predict NaN", Double.isNaN(regression.predict(0)));
|
||||
|
||||
regression.addData(1, 4);
|
||||
|
||||
// MSE, MSE, s(b0), s(b1) should all be OK now
|
||||
Assert.assertTrue("MSE NaN", !Double.isNaN(regression.getMeanSquareError()));
|
||||
Assert.assertTrue("slope std err NaN", !Double.isNaN(regression.getSlopeStdErr()));
|
||||
Assert.assertTrue("intercept std err NaN", !Double.isNaN(regression.getInterceptStdErr()));
|
||||
Assert.assertFalse("MSE NaN", Double.isNaN(regression.getMeanSquareError()));
|
||||
Assert.assertFalse("slope std err NaN", Double.isNaN(regression.getSlopeStdErr()));
|
||||
Assert.assertFalse("intercept std err NaN", Double.isNaN(regression.getInterceptStdErr()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue