You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2021/08/13 08:24:27 UTC
[commons-math] branch master updated: Simplify assertions with
simpler equivalent. (#196)
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git
The following commit(s) were added to refs/heads/master by this push:
new 1e4662d Simplify assertions with simpler equivalent. (#196)
1e4662d is described below
commit 1e4662de5aa9fb021202709b3cf22ddb1f8046bc
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Fri Aug 13 10:24:22 2021 +0200
Simplify assertions with simpler equivalent. (#196)
---
.../core/ExtendedFieldElementAbstractTest.java | 8 ++--
.../apache/commons/math4/legacy/core/PairTest.java | 18 ++++----
.../legacy/core/jdkmath/AccurateMathTest.java | 8 ++--
.../exception/util/ExceptionContextTest.java | 4 +-
.../differentiation/DerivativeStructureTest.java | 2 +-
.../differentiation/SparseGradientTest.java | 2 +-
.../polynomials/PolynomialSplineFunctionTest.java | 3 +-
...teNormalMixtureExpectationMaximizationTest.java | 5 +--
.../field/ExtendedFieldElementAbstractTest.java | 8 ++--
.../legacy/fitting/WeightedObservedPointsTest.java | 4 +-
.../leastsquares/EvaluationRmsCheckerTest.java | 8 ++--
.../legacy/linear/Array2DRowRealMatrixTest.java | 8 ++--
.../legacy/linear/BiDiagonalTransformerTest.java | 12 +++---
.../math4/legacy/linear/BigRealFieldTest.java | 2 +-
.../commons/math4/legacy/linear/BigRealTest.java | 8 ++--
.../math4/legacy/linear/BlockFieldMatrixTest.java | 12 +++---
.../math4/legacy/linear/BlockRealMatrixTest.java | 8 ++--
.../legacy/linear/CholeskyDecompositionTest.java | 4 +-
.../math4/legacy/linear/DiagonalMatrixTest.java | 4 +-
.../legacy/linear/FieldLUDecompositionTest.java | 12 +++---
.../math4/legacy/linear/FieldMatrixImplTest.java | 12 +++---
.../legacy/linear/HessenbergTransformerTest.java | 4 +-
.../math4/legacy/linear/LUDecompositionTest.java | 12 +++---
.../math4/legacy/linear/OpenIntToFieldTest.java | 14 +++---
.../math4/legacy/linear/QRDecompositionTest.java | 6 +--
.../legacy/linear/RealVectorAbstractTest.java | 10 ++---
.../math4/legacy/linear/SchurTransformerTest.java | 4 +-
.../linear/SingularValueDecompositionTest.java | 12 +++---
.../math4/legacy/linear/SparseFieldMatrixTest.java | 8 ++--
.../math4/legacy/linear/SparseRealMatrixTest.java | 8 ++--
.../legacy/linear/TriDiagonalTransformerTest.java | 4 +-
.../math4/legacy/ode/FirstOrderConverterTest.java | 2 +-
...tractEmbeddedRungeKuttaFieldIntegratorTest.java | 2 +-
.../AbstractRungeKuttaFieldIntegratorTest.java | 2 +-
...eddedRungeKuttaFieldIntegratorAbstractTest.java | 2 +-
.../RungeKuttaFieldIntegratorAbstractTest.java | 2 +-
.../math4/legacy/optim/PointValuePairTest.java | 8 ++--
.../nonlinear/scalar/noderiv/SimplexTest.java | 11 +++--
.../MultiStartUnivariateOptimizerTest.java | 2 +-
.../commons/math4/legacy/stat/StatUtilsTest.java | 8 +---
.../MultivariateSummaryStatisticsTest.java | 8 ++--
.../stat/descriptive/ResizableDoubleArrayTest.java | 12 +++---
.../descriptive/StatisticalSummaryValuesTest.java | 6 +--
.../StorelessUnivariateStatisticAbstractTest.java | 28 ++++++------
.../stat/descriptive/SummaryStatisticsTest.java | 32 ++++++--------
.../descriptive/rank/PSquarePercentileTest.java | 50 +++++++++++-----------
.../stat/descriptive/rank/PercentileTest.java | 12 +++---
.../legacy/stat/inference/ChiSquareTestTest.java | 6 +--
.../stat/inference/InferenceTestUtilsTest.java | 19 ++++----
.../stat/inference/MannWhitneyUTestTest.java | 2 +-
.../math4/legacy/stat/inference/TTestTest.java | 13 +++---
.../stat/regression/SimpleRegressionTest.java | 24 +++++------
52 files changed, 234 insertions(+), 251 deletions(-)
diff --git a/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/ExtendedFieldElementAbstractTest.java b/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/ExtendedFieldElementAbstractTest.java
index bf57129..c2bb57e 100644
--- a/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/ExtendedFieldElementAbstractTest.java
+++ b/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/ExtendedFieldElementAbstractTest.java
@@ -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
diff --git a/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/PairTest.java b/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/PairTest.java
index bc8e2be..b1327a3 100644
--- a/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/PairTest.java
+++ b/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/PairTest.java
@@ -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
diff --git a/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/jdkmath/AccurateMathTest.java b/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/jdkmath/AccurateMathTest.java
index 2811455..6cddff2 100644
--- a/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/jdkmath/AccurateMathTest.java
+++ b/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/jdkmath/AccurateMathTest.java
@@ -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
}
diff --git a/commons-math-legacy-exception/src/test/java/org/apache/commons/math4/legacy/exception/util/ExceptionContextTest.java b/commons-math-legacy-exception/src/test/java/org/apache/commons/math4/legacy/exception/util/ExceptionContextTest.java
index 374c7cf..9812342 100644
--- a/commons-math-legacy-exception/src/test/java/org/apache/commons/math4/legacy/exception/util/ExceptionContextTest.java
+++ b/commons-math-legacy-exception/src/test/java/org/apache/commons/math4/legacy/exception/util/ExceptionContextTest.java
@@ -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));
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/DerivativeStructureTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/DerivativeStructureTest.java
index 94329c1..91811d8 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/DerivativeStructureTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/DerivativeStructureTest.java
@@ -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);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/SparseGradientTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/SparseGradientTest.java
index 29734fc..7dee83f 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/SparseGradientTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/SparseGradientTest.java
@@ -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);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialSplineFunctionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialSplineFunctionTest.java
index 87cb131..8af324f 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialSplineFunctionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialSplineFunctionTest.java
@@ -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());
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java
index 56ce855..a2fe496 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/fitting/MultivariateNormalMixtureExpectationMaximizationTest.java
@@ -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++;
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/ExtendedFieldElementAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/ExtendedFieldElementAbstractTest.java
index 5bb4575..3f8deb2 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/ExtendedFieldElementAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/ExtendedFieldElementAbstractTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/WeightedObservedPointsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/WeightedObservedPointsTest.java
index 4424b86..d91702a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/WeightedObservedPointsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/WeightedObservedPointsTest.java
@@ -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();
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationRmsCheckerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationRmsCheckerTest.java
index 894adf6..d8308d7 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationRmsCheckerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationRmsCheckerTest.java
@@ -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)));
}
/**
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrixTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrixTest.java
index d107208..c9cb97b 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrixTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrixTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BiDiagonalTransformerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BiDiagonalTransformerTest.java
index 3068f1a..5065898 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BiDiagonalTransformerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BiDiagonalTransformerTest.java
@@ -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());
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealFieldTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealFieldTest.java
index bdf0e45..7d1ca42 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealFieldTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealFieldTest.java
@@ -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));
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java
index f02741b..97d497a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java
@@ -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);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockFieldMatrixTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockFieldMatrixTest.java
index 719aeba..9974ccc 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockFieldMatrixTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockFieldMatrixTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockRealMatrixTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockRealMatrixTest.java
index a8f9f1d..f6ce893 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockRealMatrixTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockRealMatrixTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/CholeskyDecompositionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/CholeskyDecompositionTest.java
index f720e1d..f49d2cd 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/CholeskyDecompositionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/CholeskyDecompositionTest.java
@@ -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());
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/DiagonalMatrixTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/DiagonalMatrixTest.java
index 4af2506..eb2d0cf 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/DiagonalMatrixTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/DiagonalMatrixTest.java
@@ -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);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUDecompositionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUDecompositionTest.java
index 82efbeb..e7ee1f2 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUDecompositionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUDecompositionTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldMatrixImplTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldMatrixImplTest.java
index e540930..68e8068 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldMatrixImplTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldMatrixImplTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/HessenbergTransformerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/HessenbergTransformerTest.java
index df7178a..2ec49d3 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/HessenbergTransformerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/HessenbergTransformerTest.java
@@ -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());
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/LUDecompositionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/LUDecompositionTest.java
index a9421cd..929fea2 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/LUDecompositionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/LUDecompositionTest.java
@@ -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());
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java
index 20f24ab..0e1897a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java
@@ -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()));
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/QRDecompositionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/QRDecompositionTest.java
index b30685a..8969364 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/QRDecompositionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/QRDecompositionTest.java
@@ -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());
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/RealVectorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/RealVectorAbstractTest.java
index 0b70ca3..617b675 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/RealVectorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/RealVectorAbstractTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SchurTransformerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SchurTransformerTest.java
index 8d2e862..8085f0c 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SchurTransformerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SchurTransformerTest.java
@@ -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());
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SingularValueDecompositionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SingularValueDecompositionTest.java
index 92e618b..b268bb0 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SingularValueDecompositionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SingularValueDecompositionTest.java
@@ -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());
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldMatrixTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldMatrixTest.java
index 30ed0cb..b649e16 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldMatrixTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldMatrixTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseRealMatrixTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseRealMatrixTest.java
index 9b2b842..2eda9ba 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseRealMatrixTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseRealMatrixTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/TriDiagonalTransformerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/TriDiagonalTransformerTest.java
index e8b6f5d..7a8b76c 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/TriDiagonalTransformerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/TriDiagonalTransformerTest.java
@@ -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());
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FirstOrderConverterTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FirstOrderConverterTest.java
index 24a37de..f585073 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FirstOrderConverterTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FirstOrderConverterTest.java
@@ -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());
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java
index 9d35a0e..4647431 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java
@@ -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]));
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java
index 2aeb686..d0a2702 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java
@@ -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]));
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java
index 4040e08..82b21b3 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java
@@ -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]));
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java
index e1f23ed..26d56d8 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java
@@ -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]));
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointValuePairTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointValuePairTest.java
index 23a68db..3bb7622 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointValuePairTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/PointValuePairTest.java
@@ -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);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexTest.java
index 260d251..fc2bd4e 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexTest.java
@@ -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);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/MultiStartUnivariateOptimizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/MultiStartUnivariateOptimizerTest.java
index 476b980..59b09db 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/MultiStartUnivariateOptimizerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/MultiStartUnivariateOptimizerTest.java
@@ -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 {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/StatUtilsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/StatUtilsTest.java
index 7f02b3f..aad318d 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/StatUtilsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/StatUtilsTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java
index 1b89f81..3cb7cd9 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/ResizableDoubleArrayTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/ResizableDoubleArrayTest.java
index 478d629..86a0734 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/ResizableDoubleArrayTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/ResizableDoubleArrayTest.java
@@ -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());
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StatisticalSummaryValuesTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StatisticalSummaryValuesTest.java
index 3293577..8c7d848 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StatisticalSummaryValuesTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StatisticalSummaryValuesTest.java
@@ -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);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
index cde08f0..5ee9afe 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/SummaryStatisticsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/SummaryStatisticsTest.java
index 1a8ca40..62feb77 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/SummaryStatisticsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/SummaryStatisticsTest.java
@@ -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());
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentileTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentileTest.java
index 99e8430..40c4c75 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentileTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentileTest.java
@@ -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()));
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PercentileTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PercentileTest.java
index 936b454..7f8e026 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PercentileTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PercentileTest.java
@@ -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);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTestTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTestTest.java
index ef8f6df..70242cd 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTestTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTestTest.java
@@ -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}};
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/InferenceTestUtilsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/InferenceTestUtilsTest.java
index f03e710..e75745a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/InferenceTestUtilsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/InferenceTestUtilsTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/MannWhitneyUTestTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/MannWhitneyUTestTest.java
index 1720611..5f776ba 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/MannWhitneyUTestTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/MannWhitneyUTestTest.java
@@ -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);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/TTestTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/TTestTest.java
index b056eb0..8dde1c5 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/TTestTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/TTestTest.java
@@ -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
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegressionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegressionTest.java
index 0b8df2b..e2084d5 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegressionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegressionTest.java
@@ -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