fixed numerous warnings in test code (unused fields/results, fields only set to null)
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@566833 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
52b98250c2
commit
ea14dd91da
|
@ -169,7 +169,7 @@ public final class LaguerreSolverTest extends TestCase {
|
|||
try {
|
||||
// bad function
|
||||
UnivariateRealFunction f2 = new SinFunction();
|
||||
UnivariateRealSolver solver2 = new LaguerreSolver(f2);
|
||||
new LaguerreSolver(f2);
|
||||
fail("Expecting IllegalArgumentException - bad function");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
|
|
@ -126,13 +126,12 @@ public final class PolynomialFunctionLagrangeFormTest extends TestCase {
|
|||
* Test of parameters for the polynomial.
|
||||
*/
|
||||
public void testParameters() throws Exception {
|
||||
PolynomialFunctionLagrangeForm p;
|
||||
|
||||
try {
|
||||
// bad input array length
|
||||
double x[] = { 1.0 };
|
||||
double y[] = { 2.0 };
|
||||
p = new PolynomialFunctionLagrangeForm(x, y);
|
||||
new PolynomialFunctionLagrangeForm(x, y);
|
||||
fail("Expecting IllegalArgumentException - bad input array length");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -141,7 +140,7 @@ public final class PolynomialFunctionLagrangeFormTest extends TestCase {
|
|||
// mismatch input arrays
|
||||
double x[] = { 1.0, 2.0, 3.0, 4.0 };
|
||||
double y[] = { 0.0, -4.0, -24.0 };
|
||||
p = new PolynomialFunctionLagrangeForm(x, y);
|
||||
new PolynomialFunctionLagrangeForm(x, y);
|
||||
fail("Expecting IllegalArgumentException - mismatch input arrays");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
|
|
@ -125,13 +125,12 @@ public final class PolynomialFunctionNewtonFormTest extends TestCase {
|
|||
* Test of parameters for the polynomial.
|
||||
*/
|
||||
public void testParameters() throws Exception {
|
||||
PolynomialFunctionNewtonForm p;
|
||||
|
||||
try {
|
||||
// bad input array length
|
||||
double a[] = { 1.0 };
|
||||
double c[] = { 2.0 };
|
||||
p = new PolynomialFunctionNewtonForm(a, c);
|
||||
new PolynomialFunctionNewtonForm(a, c);
|
||||
fail("Expecting IllegalArgumentException - bad input array length");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -140,7 +139,7 @@ public final class PolynomialFunctionNewtonFormTest extends TestCase {
|
|||
// mismatch input arrays
|
||||
double a[] = { 1.0, 2.0, 3.0, 4.0 };
|
||||
double c[] = { 4.0, 3.0, 2.0, 1.0 };
|
||||
p = new PolynomialFunctionNewtonForm(a, c);
|
||||
new PolynomialFunctionNewtonForm(a, c);
|
||||
fail("Expecting IllegalArgumentException - mismatch input arrays");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
|
|
@ -132,13 +132,13 @@ public final class PolynomialFunctionTest extends TestCase {
|
|||
|
||||
|
||||
/**
|
||||
* tests the firstDerivative function by comparision
|
||||
* tests the firstDerivative function by comparison
|
||||
*
|
||||
* <p>This will test the functions
|
||||
* <tt>f(x) = x^3 - 2x^2 + 6x + 3, g(x) = 3x^2 - 4x + 6</tt>
|
||||
* and <tt>h(x) = 6x - 4</tt>
|
||||
*/
|
||||
public void testfirstDerivativeComparision() throws MathException {
|
||||
public void testfirstDerivativeComparison() throws MathException {
|
||||
double[] f_coeff = { 3.0, 6.0, -2.0, 1.0 };
|
||||
double[] g_coeff = { 6.0, -4.0, 3.0 };
|
||||
double[] h_coeff = { -4.0, 6.0 };
|
||||
|
@ -155,9 +155,9 @@ public final class PolynomialFunctionTest extends TestCase {
|
|||
assertEquals( f.derivative().value(-3.25), g.value(-3.25), tolerance );
|
||||
|
||||
// compare g' = h
|
||||
assertEquals( g.derivative().value(Math.PI), h.value(Math.PI), tolerance );
|
||||
assertEquals( g.derivative().value(Math.E), h.value(Math.E), tolerance );
|
||||
|
||||
|
||||
// compare f'' = h
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,24 +63,21 @@ public class PolynomialSplineFunctionTest extends TestCase {
|
|||
assertEquals(3, spline.getN());
|
||||
|
||||
try { // too few knots
|
||||
spline =
|
||||
new PolynomialSplineFunction(new double[] {0}, polynomials);
|
||||
new PolynomialSplineFunction(new double[] {0}, polynomials);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try { // too many knots
|
||||
spline =
|
||||
new PolynomialSplineFunction(new double[] {0,1,2,3,4}, polynomials);
|
||||
new PolynomialSplineFunction(new double[] {0,1,2,3,4}, polynomials);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try { // knots not increasing
|
||||
spline =
|
||||
new PolynomialSplineFunction(new double[] {0,1, 3, 2}, polynomials);
|
||||
new PolynomialSplineFunction(new double[] {0,1, 3, 2}, polynomials);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
|
|
@ -52,7 +52,7 @@ public class UnivariateRealSolverFactoryImplTest extends TestCase {
|
|||
|
||||
public void testNewBisectionSolverNull() {
|
||||
try {
|
||||
UnivariateRealSolver solver = factory.newBisectionSolver(null);
|
||||
factory.newBisectionSolver(null);
|
||||
fail();
|
||||
} catch(IllegalArgumentException ex) {
|
||||
// success
|
||||
|
@ -67,7 +67,7 @@ public class UnivariateRealSolverFactoryImplTest extends TestCase {
|
|||
|
||||
public void testNewNewtonSolverNull() {
|
||||
try {
|
||||
UnivariateRealSolver solver = factory.newNewtonSolver(null);
|
||||
factory.newNewtonSolver(null);
|
||||
fail();
|
||||
} catch(IllegalArgumentException ex) {
|
||||
// success
|
||||
|
@ -82,7 +82,7 @@ public class UnivariateRealSolverFactoryImplTest extends TestCase {
|
|||
|
||||
public void testNewBrentSolverNull() {
|
||||
try {
|
||||
UnivariateRealSolver solver = factory.newBrentSolver(null);
|
||||
factory.newBrentSolver(null);
|
||||
fail();
|
||||
} catch(IllegalArgumentException ex) {
|
||||
// success
|
||||
|
@ -97,7 +97,7 @@ public class UnivariateRealSolverFactoryImplTest extends TestCase {
|
|||
|
||||
public void testNewSecantSolverNull() {
|
||||
try {
|
||||
UnivariateRealSolver solver = factory.newSecantSolver(null);
|
||||
factory.newSecantSolver(null);
|
||||
fail();
|
||||
} catch(IllegalArgumentException ex) {
|
||||
// success
|
||||
|
|
|
@ -40,20 +40,19 @@ public class UnivariateRealSolverUtilsTest extends TestCase {
|
|||
|
||||
public void testSolveBadParameters() throws MathException {
|
||||
try { // bad endpoints
|
||||
double x = UnivariateRealSolverUtils.solve(sin,0.0, 4.0, 4.0);
|
||||
UnivariateRealSolverUtils.solve(sin,0.0, 4.0, 4.0);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
try { // bad accuracy
|
||||
double x = UnivariateRealSolverUtils.solve(sin, 0.0, 4.0, 0.0);
|
||||
UnivariateRealSolverUtils.solve(sin, 0.0, 4.0, 0.0);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testSolveSin() throws MathException {
|
||||
double x = UnivariateRealSolverUtils.solve(sin, 1.0,
|
||||
4.0);
|
||||
double x = UnivariateRealSolverUtils.solve(sin, 1.0, 4.0);
|
||||
assertEquals(Math.PI, x, 1.0e-4);
|
||||
}
|
||||
|
||||
|
@ -76,8 +75,7 @@ public class UnivariateRealSolverUtilsTest extends TestCase {
|
|||
|
||||
public void testSolveNoRoot() throws MathException {
|
||||
try {
|
||||
double x = UnivariateRealSolverUtils.solve(sin, 1.0,
|
||||
1.5);
|
||||
UnivariateRealSolverUtils.solve(sin, 1.0, 1.5);
|
||||
fail("Expecting IllegalArgumentException ");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -93,8 +91,7 @@ public class UnivariateRealSolverUtilsTest extends TestCase {
|
|||
|
||||
public void testBracketCornerSolution() throws MathException {
|
||||
try {
|
||||
double[] result = UnivariateRealSolverUtils.bracket(sin,
|
||||
1.5, 0, 2.0);
|
||||
UnivariateRealSolverUtils.bracket(sin, 1.5, 0, 2.0);
|
||||
fail("Expecting ConvergenceException");
|
||||
} catch (ConvergenceException ex) {
|
||||
// expected
|
||||
|
@ -103,25 +100,25 @@ public class UnivariateRealSolverUtilsTest extends TestCase {
|
|||
|
||||
public void testBadParameters() throws MathException {
|
||||
try { // null function
|
||||
double[] result = UnivariateRealSolverUtils.bracket(null, 1.5, 0, 2.0);
|
||||
UnivariateRealSolverUtils.bracket(null, 1.5, 0, 2.0);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
try { // initial not between endpoints
|
||||
double[] result = UnivariateRealSolverUtils.bracket(sin, 2.5, 0, 2.0);
|
||||
UnivariateRealSolverUtils.bracket(sin, 2.5, 0, 2.0);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
try { // endpoints not valid
|
||||
double[] result = UnivariateRealSolverUtils.bracket(sin, 1.5, 2.0, 1.0);
|
||||
UnivariateRealSolverUtils.bracket(sin, 1.5, 2.0, 1.0);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
try { // bad maximum iterations
|
||||
double[] result = UnivariateRealSolverUtils.bracket(sin, 1.5, 0, 2.0, 0);
|
||||
UnivariateRealSolverUtils.bracket(sin, 1.5, 0, 2.0, 0);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
|
|
@ -39,7 +39,6 @@ public class ComplexUtilsTest extends TestCase {
|
|||
private Complex infNegInf = new Complex(inf, negInf);
|
||||
private Complex infInf = new Complex(inf, inf);
|
||||
private Complex negInfNegInf = new Complex(negInf, negInf);
|
||||
private Complex oneNaN = new Complex(1, nan);
|
||||
private Complex infNaN = new Complex(inf, nan);
|
||||
private Complex negInfNaN = new Complex(negInf, nan);
|
||||
private Complex nanInf = new Complex(nan, inf);
|
||||
|
@ -48,11 +47,8 @@ public class ComplexUtilsTest extends TestCase {
|
|||
private Complex nanZero = new Complex(nan, 0);
|
||||
private Complex infZero = new Complex(inf, 0);
|
||||
private Complex zeroInf = new Complex(0, inf);
|
||||
private Complex zeroNegInf = new Complex(0, negInf);
|
||||
private Complex negInfZero = new Complex(negInf, 0);
|
||||
|
||||
private ComplexFormat fmt = new ComplexFormat();
|
||||
|
||||
public void testAcos() {
|
||||
Complex z = new Complex(3, 4);
|
||||
Complex expected = new Complex(0.936812, -2.30551);
|
||||
|
@ -78,7 +74,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testAcosNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.acos(null);
|
||||
ComplexUtils.acos(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -108,7 +104,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testAsinNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.asin(null);
|
||||
ComplexUtils.asin(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -139,7 +135,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testAtanNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.atan(null);
|
||||
ComplexUtils.atan(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -169,7 +165,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testCosNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.cos(null);
|
||||
ComplexUtils.cos(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -199,7 +195,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testCoshNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.cosh(null);
|
||||
ComplexUtils.cosh(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -234,7 +230,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testExpNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.exp(null);
|
||||
ComplexUtils.exp(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -275,7 +271,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testlogNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.log(null);
|
||||
ComplexUtils.log(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -318,7 +314,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testPolar2ComplexIllegalModulus() {
|
||||
try {
|
||||
Complex z = ComplexUtils.polar2Complex(-1, 0);
|
||||
ComplexUtils.polar2Complex(-1, 0);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -405,13 +401,13 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testpowNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.pow(null, Complex.ONE);
|
||||
ComplexUtils.pow(null, Complex.ONE);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
Complex z = ComplexUtils.pow(Complex.ONE, null);
|
||||
ComplexUtils.pow(Complex.ONE, null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -441,7 +437,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testSinNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.sin(null);
|
||||
ComplexUtils.sin(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -471,7 +467,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testsinhNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.sinh(null);
|
||||
ComplexUtils.sinh(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -539,7 +535,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testSqrtNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.sqrt(null);
|
||||
ComplexUtils.sqrt(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -558,7 +554,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testSqrt1zNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.sqrt1z(null);
|
||||
ComplexUtils.sqrt1z(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -593,7 +589,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testTanNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.tan(null);
|
||||
ComplexUtils.tan(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
@ -627,7 +623,7 @@ public class ComplexUtilsTest extends TestCase {
|
|||
|
||||
public void testTanhNull() {
|
||||
try {
|
||||
Complex z = ComplexUtils.tanh(null);
|
||||
ComplexUtils.tanh(null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException ex) {
|
||||
// expected
|
||||
|
|
|
@ -233,14 +233,14 @@ public class FractionFormatTest extends TestCase {
|
|||
public void testParseProperInvalidMinus() {
|
||||
String source = "2 -2 / 3";
|
||||
try {
|
||||
Fraction c = properFormat.parse(source);
|
||||
properFormat.parse(source);
|
||||
fail("invalid minus in improper fraction.");
|
||||
} catch (ParseException ex) {
|
||||
// expected
|
||||
}
|
||||
source = "2 2 / -3";
|
||||
try {
|
||||
Fraction c = properFormat.parse(source);
|
||||
properFormat.parse(source);
|
||||
fail("invalid minus in improper fraction.");
|
||||
} catch (ParseException ex) {
|
||||
// expected
|
||||
|
|
|
@ -280,7 +280,7 @@ public class FractionTest extends TestCase {
|
|||
Fraction f1 = new Fraction(3, 5);
|
||||
Fraction f2 = Fraction.ZERO;
|
||||
try {
|
||||
Fraction f = f1.divide(f2);
|
||||
f1.divide(f2);
|
||||
fail("expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {}
|
||||
|
||||
|
@ -417,7 +417,6 @@ public class FractionTest extends TestCase {
|
|||
public void testEqualsAndHashCode() {
|
||||
Fraction zero = new Fraction(0,1);
|
||||
Fraction nullFraction = null;
|
||||
int zeroHash = zero.hashCode();
|
||||
assertTrue( zero.equals(zero));
|
||||
assertFalse(zero.equals(nullFraction));
|
||||
assertFalse(zero.equals(new Double(0)));
|
||||
|
@ -433,7 +432,7 @@ public class FractionTest extends TestCase {
|
|||
assertTrue(threeFourths.equals(Fraction.getReducedFraction(6, 8)));
|
||||
assertTrue(Fraction.ZERO.equals(Fraction.getReducedFraction(0, -1)));
|
||||
try {
|
||||
Fraction f = Fraction.getReducedFraction(1, 0);
|
||||
Fraction.getReducedFraction(1, 0);
|
||||
fail("expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {
|
||||
// expected
|
||||
|
|
|
@ -170,38 +170,38 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
assertClose("double, BigDecimal", m1, m3, Double.MIN_VALUE);
|
||||
assertClose("string, BigDecimal", m2, m3, Double.MIN_VALUE);
|
||||
try {
|
||||
BigMatrix m4 = new BigMatrixImpl(new String[][] {{"0", "hello", "1"}});
|
||||
new BigMatrixImpl(new String[][] {{"0", "hello", "1"}});
|
||||
fail("Expecting NumberFormatException");
|
||||
} catch (NumberFormatException ex) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
BigMatrix m4 = new BigMatrixImpl(new String[][] {});
|
||||
new BigMatrixImpl(new String[][] {});
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
BigMatrix m4 = new BigMatrixImpl(new String[][] {{},{}});
|
||||
new BigMatrixImpl(new String[][] {{},{}});
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
BigMatrix m4 = new BigMatrixImpl(new String[][] {{"a", "b"},{"c"}});
|
||||
new BigMatrixImpl(new String[][] {{"a", "b"},{"c"}});
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
BigMatrix m4 = new BigMatrixImpl(0, 1);
|
||||
new BigMatrixImpl(0, 1);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
BigMatrix m4 = new BigMatrixImpl(1, 0);
|
||||
new BigMatrixImpl(1, 0);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -228,7 +228,7 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
BigMatrixImpl m = new BigMatrixImpl(testData);
|
||||
BigMatrixImpl m2 = new BigMatrixImpl(testData2);
|
||||
try {
|
||||
BigMatrixImpl mPlusMInv = (BigMatrixImpl)m.add(m2);
|
||||
m.add(m2);
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -250,7 +250,7 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
assertClose("m-n = m + -n",m.subtract(m2),
|
||||
m2.scalarMultiply(new BigDecimal(-1d)).add(m),entryTolerance);
|
||||
try {
|
||||
BigMatrix a = m.subtract(new BigMatrixImpl(testData2));
|
||||
m.subtract(new BigMatrixImpl(testData2));
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -274,7 +274,7 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
assertClose("identity multiply",m2.multiply(identity),
|
||||
m2,entryTolerance);
|
||||
try {
|
||||
BigMatrix a = m.multiply(new BigMatrixImpl(bigSingular));
|
||||
m.multiply(new BigMatrixImpl(bigSingular));
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -342,26 +342,26 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
asDouble(m.solve(asBigDecimal(testVector))),
|
||||
normTolerance);
|
||||
try {
|
||||
double[] x = asDouble(m.solve(asBigDecimal(testVector2)));
|
||||
asDouble(m.solve(asBigDecimal(testVector2)));
|
||||
fail("expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
BigMatrix bs = new BigMatrixImpl(bigSingular);
|
||||
try {
|
||||
BigMatrix a = bs.solve(bs);
|
||||
bs.solve(bs);
|
||||
fail("Expecting InvalidMatrixException");
|
||||
} catch (InvalidMatrixException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
BigMatrix a = m.solve(bs);
|
||||
m.solve(bs);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
BigMatrix a = (new BigMatrixImpl(testData2)).solve(bs);
|
||||
new BigMatrixImpl(testData2).solve(bs);
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -388,7 +388,7 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
assertEquals("nonsingular R test 2",-1d,m.getDeterminant().doubleValue(),normTolerance);
|
||||
|
||||
try {
|
||||
double a = new BigMatrixImpl(testData2).getDeterminant().doubleValue();
|
||||
new BigMatrixImpl(testData2).getDeterminant().doubleValue();
|
||||
fail("Expecting InvalidMatrixException");
|
||||
} catch (InvalidMatrixException ex) {
|
||||
;
|
||||
|
@ -401,7 +401,7 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
assertEquals("identity trace",3d,m.getTrace().doubleValue(),entryTolerance);
|
||||
m = new BigMatrixImpl(testData2);
|
||||
try {
|
||||
double x = m.getTrace().doubleValue();
|
||||
m.getTrace().doubleValue();
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -422,7 +422,7 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
assertClose("identity operate",testVector,x,entryTolerance);
|
||||
m = new BigMatrixImpl(bigSingular);
|
||||
try {
|
||||
x = asDouble(m.operate(asBigDecimal(testVector)));
|
||||
asDouble(m.operate(asBigDecimal(testVector)));
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -461,7 +461,7 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
BigMatrixImpl m = new BigMatrixImpl(testData);
|
||||
BigMatrixImpl mInv = new BigMatrixImpl(testDataInv);
|
||||
BigMatrixImpl identity = new BigMatrixImpl(id);
|
||||
BigMatrixImpl m2 = new BigMatrixImpl(testData2);
|
||||
new BigMatrixImpl(testData2);
|
||||
assertClose("inverse multiply",m.preMultiply(mInv),
|
||||
identity,entryTolerance);
|
||||
assertClose("inverse multiply",mInv.preMultiply(m),
|
||||
|
@ -471,7 +471,7 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
assertClose("identity multiply",identity.preMultiply(mInv),
|
||||
mInv,entryTolerance);
|
||||
try {
|
||||
BigMatrix a = m.preMultiply(new BigMatrixImpl(bigSingular));
|
||||
m.preMultiply(new BigMatrixImpl(bigSingular));
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -483,13 +483,13 @@ public final class BigMatrixImplTest extends TestCase {
|
|||
assertClose("get row",m.getRowAsDoubleArray(0),testDataRow1,entryTolerance);
|
||||
assertClose("get col",m.getColumnAsDoubleArray(2),testDataCol3,entryTolerance);
|
||||
try {
|
||||
double[] x = m.getRowAsDoubleArray(10);
|
||||
m.getRowAsDoubleArray(10);
|
||||
fail("expecting MatrixIndexException");
|
||||
} catch (MatrixIndexException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
double[] x = m.getColumnAsDoubleArray(-1);
|
||||
m.getColumnAsDoubleArray(-1);
|
||||
fail("expecting MatrixIndexException");
|
||||
} catch (MatrixIndexException ex) {
|
||||
;
|
||||
|
|
|
@ -141,7 +141,7 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
RealMatrixImpl m = new RealMatrixImpl(testData);
|
||||
RealMatrixImpl m2 = new RealMatrixImpl(testData2);
|
||||
try {
|
||||
RealMatrixImpl mPlusMInv = (RealMatrixImpl)m.add(m2);
|
||||
m.add(m2);
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -163,7 +163,7 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
assertClose("m-n = m + -n",m.subtract(m2),
|
||||
m2.scalarMultiply(-1d).add(m),entryTolerance);
|
||||
try {
|
||||
RealMatrix a = m.subtract(new RealMatrixImpl(testData2));
|
||||
m.subtract(new RealMatrixImpl(testData2));
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -187,7 +187,7 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
assertClose("identity multiply",m2.multiply(identity),
|
||||
m2,entryTolerance);
|
||||
try {
|
||||
RealMatrix a = m.multiply(new RealMatrixImpl(bigSingular));
|
||||
m.multiply(new RealMatrixImpl(bigSingular));
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -253,26 +253,26 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
assertClose("inverse-operate",mInv.operate(testVector),
|
||||
m.solve(testVector),normTolerance);
|
||||
try {
|
||||
double[] x = m.solve(testVector2);
|
||||
m.solve(testVector2);
|
||||
fail("expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
RealMatrix bs = new RealMatrixImpl(bigSingular);
|
||||
try {
|
||||
RealMatrix a = bs.solve(bs);
|
||||
bs.solve(bs);
|
||||
fail("Expecting InvalidMatrixException");
|
||||
} catch (InvalidMatrixException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
RealMatrix a = m.solve(bs);
|
||||
m.solve(bs);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
RealMatrix a = (new RealMatrixImpl(testData2)).solve(bs);
|
||||
new RealMatrixImpl(testData2).solve(bs);
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -299,7 +299,7 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
assertEquals("nonsingular R test 2",-1d,m.getDeterminant(),normTolerance);
|
||||
|
||||
try {
|
||||
double a = new RealMatrixImpl(testData2).getDeterminant();
|
||||
new RealMatrixImpl(testData2).getDeterminant();
|
||||
fail("Expecting InvalidMatrixException");
|
||||
} catch (InvalidMatrixException ex) {
|
||||
;
|
||||
|
@ -312,7 +312,7 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
assertEquals("identity trace",3d,m.getTrace(),entryTolerance);
|
||||
m = new RealMatrixImpl(testData2);
|
||||
try {
|
||||
double x = m.getTrace();
|
||||
m.getTrace();
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -333,7 +333,7 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
assertClose("identity operate",testVector,x,entryTolerance);
|
||||
m = new RealMatrixImpl(bigSingular);
|
||||
try {
|
||||
x = m.operate(testVector);
|
||||
m.operate(testVector);
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -372,7 +372,6 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
RealMatrixImpl m = new RealMatrixImpl(testData);
|
||||
RealMatrixImpl mInv = new RealMatrixImpl(testDataInv);
|
||||
RealMatrixImpl identity = new RealMatrixImpl(id);
|
||||
RealMatrixImpl m2 = new RealMatrixImpl(testData2);
|
||||
assertClose("inverse multiply",m.preMultiply(mInv),
|
||||
identity,entryTolerance);
|
||||
assertClose("inverse multiply",mInv.preMultiply(m),
|
||||
|
@ -382,7 +381,7 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
assertClose("identity multiply",identity.preMultiply(mInv),
|
||||
mInv,entryTolerance);
|
||||
try {
|
||||
RealMatrix a = m.preMultiply(new RealMatrixImpl(bigSingular));
|
||||
m.preMultiply(new RealMatrixImpl(bigSingular));
|
||||
fail("Expecting illegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -394,13 +393,13 @@ public final class RealMatrixImplTest extends TestCase {
|
|||
assertClose("get row",m.getRow(0),testDataRow1,entryTolerance);
|
||||
assertClose("get col",m.getColumn(2),testDataCol3,entryTolerance);
|
||||
try {
|
||||
double[] x = m.getRow(10);
|
||||
m.getRow(10);
|
||||
fail("expecting MatrixIndexException");
|
||||
} catch (MatrixIndexException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
double[] x = m.getColumn(-1);
|
||||
m.getColumn(-1);
|
||||
fail("expecting MatrixIndexException");
|
||||
} catch (MatrixIndexException ex) {
|
||||
;
|
||||
|
|
|
@ -44,7 +44,7 @@ public class AbstractRandomGeneratorTest extends RandomDataTest {
|
|||
|
||||
public void testNextInt() {
|
||||
try {
|
||||
int x = testGenerator.nextInt(-1);
|
||||
testGenerator.nextInt(-1);
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
|
|
@ -43,7 +43,6 @@ public class RandomDataTest extends RetryTestCase {
|
|||
protected long smallSampleSize = 1000;
|
||||
protected double[] expected = {250,250,250,250};
|
||||
protected int largeSampleSize = 10000;
|
||||
private int tolerance = 50;
|
||||
private String[] hex =
|
||||
{"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
|
||||
protected RandomDataImpl randomData = null;
|
||||
|
@ -73,7 +72,7 @@ public class RandomDataTest extends RetryTestCase {
|
|||
/** test dispersion and failure modes for nextInt() */
|
||||
public void testNextInt() {
|
||||
try {
|
||||
int x = randomData.nextInt(4,3);
|
||||
randomData.nextInt(4,3);
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -100,7 +99,7 @@ public class RandomDataTest extends RetryTestCase {
|
|||
/** test dispersion and failure modes for nextLong() */
|
||||
public void testNextLong() {
|
||||
try {
|
||||
long x = randomData.nextLong(4,3);
|
||||
randomData.nextLong(4,3);
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -127,7 +126,7 @@ public class RandomDataTest extends RetryTestCase {
|
|||
/** test dispersion and failure modes for nextSecureLong() */
|
||||
public void testNextSecureLong() {
|
||||
try {
|
||||
long x = randomData.nextSecureLong(4,3);
|
||||
randomData.nextSecureLong(4,3);
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -154,7 +153,7 @@ public class RandomDataTest extends RetryTestCase {
|
|||
/** test dispersion and failure modes for nextSecureInt() */
|
||||
public void testNextSecureInt() {
|
||||
try {
|
||||
long x = randomData.nextSecureInt(4,3);
|
||||
randomData.nextSecureInt(4,3);
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -186,13 +185,12 @@ public class RandomDataTest extends RetryTestCase {
|
|||
*/
|
||||
public void testNextPoisson() {
|
||||
try {
|
||||
long x = randomData.nextPoisson(0);
|
||||
randomData.nextPoisson(0);
|
||||
fail("zero mean -- expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
Frequency f = new Frequency();
|
||||
long v = 0;
|
||||
for (int i = 0; i<largeSampleSize; i++) {
|
||||
try {
|
||||
f.addValue(randomData.nextPoisson(4.0d));
|
||||
|
@ -207,13 +205,13 @@ public class RandomDataTest extends RetryTestCase {
|
|||
new Double(cumFreq).doubleValue()/new Double(sumFreq).doubleValue();
|
||||
assertEquals("cum Poisson(4)",cumPct,0.7851,0.2);
|
||||
try {
|
||||
long x = randomData.nextPoisson(-1);
|
||||
randomData.nextPoisson(-1);
|
||||
fail("negative mean supplied -- IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
long x = randomData.nextPoisson(0);
|
||||
randomData.nextPoisson(0);
|
||||
fail("0 mean supplied -- IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -224,13 +222,13 @@ public class RandomDataTest extends RetryTestCase {
|
|||
/** test dispersion and failute modes for nextHex() */
|
||||
public void testNextHex() {
|
||||
try {
|
||||
String x = randomData.nextHexString(-1);
|
||||
randomData.nextHexString(-1);
|
||||
fail("negative length supplied -- IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
String x = randomData.nextHexString(0);
|
||||
randomData.nextHexString(0);
|
||||
fail("zero length supplied -- IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -278,13 +276,13 @@ public class RandomDataTest extends RetryTestCase {
|
|||
/** test dispersion and failute modes for nextHex() */
|
||||
public void testNextSecureHex() {
|
||||
try {
|
||||
String x = randomData.nextSecureHexString(-1);
|
||||
randomData.nextSecureHexString(-1);
|
||||
fail("negative length -- IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
String x = randomData.nextSecureHexString(0);
|
||||
randomData.nextSecureHexString(0);
|
||||
fail("zero length -- IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -332,13 +330,13 @@ public class RandomDataTest extends RetryTestCase {
|
|||
/** test failure modes and dispersion of nextUniform() */
|
||||
public void testNextUniform() {
|
||||
try {
|
||||
double x = randomData.nextUniform(4,3);
|
||||
randomData.nextUniform(4,3);
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
double x = randomData.nextUniform(3,3);
|
||||
randomData.nextUniform(3,3);
|
||||
fail("IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -378,7 +376,7 @@ public class RandomDataTest extends RetryTestCase {
|
|||
/** test failure modes and distribution of nextGaussian() */
|
||||
public void testNextGaussian() {
|
||||
try {
|
||||
double x = randomData.nextGaussian(0,0);
|
||||
randomData.nextGaussian(0,0);
|
||||
fail("zero sigma -- IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -399,7 +397,7 @@ public class RandomDataTest extends RetryTestCase {
|
|||
/** test failure modes and distribution of nextExponential() */
|
||||
public void testNextExponential() {
|
||||
try {
|
||||
double x = randomData.nextExponential(-1);
|
||||
randomData.nextExponential(-1);
|
||||
fail("negative mean -- expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -469,16 +467,16 @@ public class RandomDataTest extends RetryTestCase {
|
|||
// test reseeding without first using the generators
|
||||
RandomDataImpl rd = new RandomDataImpl();
|
||||
rd.reSeed(100);
|
||||
double ret = rd.nextLong(1,2);
|
||||
rd.nextLong(1,2);
|
||||
RandomDataImpl rd2 = new RandomDataImpl();
|
||||
rd2.reSeedSecure(2000);
|
||||
ret = rd2.nextSecureLong(1,2);
|
||||
rd2.nextSecureLong(1,2);
|
||||
rd = new RandomDataImpl();
|
||||
rd.reSeed();
|
||||
ret = rd.nextLong(1,2);
|
||||
rd.nextLong(1,2);
|
||||
rd2 = new RandomDataImpl();
|
||||
rd2.reSeedSecure();
|
||||
ret = rd2.nextSecureLong(1,2);
|
||||
rd2.nextSecureLong(1,2);
|
||||
}
|
||||
|
||||
/** tests for nextSample() sampling from Collection */
|
||||
|
@ -540,7 +538,6 @@ public class RandomDataTest extends RetryTestCase {
|
|||
}
|
||||
|
||||
private int findSample(Object[] u, Object[] samp) {
|
||||
int result = -1;
|
||||
for (int i = 0; i < u.length; i++) {
|
||||
HashSet set = (HashSet) u[i];
|
||||
HashSet sampSet = new HashSet();
|
||||
|
@ -596,7 +593,6 @@ public class RandomDataTest extends RetryTestCase {
|
|||
}
|
||||
|
||||
private int findPerm(int[][] p, int[] samp) {
|
||||
int result = -1;
|
||||
for (int i = 0; i < p.length; i++) {
|
||||
boolean good = true;
|
||||
for (int j = 0; j < samp.length; j++) {
|
||||
|
|
|
@ -40,8 +40,6 @@ public final class FrequencyTest extends TestCase {
|
|||
private int oneI = 1;
|
||||
private int twoI = 2;
|
||||
private int threeI=3;
|
||||
private String oneS = "1";
|
||||
private String twoS = "2";
|
||||
private double tolerance = 10E-15;
|
||||
private Frequency f = null;
|
||||
|
||||
|
|
|
@ -36,12 +36,8 @@ public final class StatUtilsTest extends TestCase {
|
|||
private double sumSq = 18;
|
||||
private double sum = 8;
|
||||
private double var = 0.666666666666666666667;
|
||||
private double std = Math.sqrt(var);
|
||||
private double n = 4;
|
||||
private double min = 1;
|
||||
private double max = 3;
|
||||
private double skewness = 0;
|
||||
private double kurtosis = 0.5;
|
||||
private double tolerance = 10E-15;
|
||||
private double nan = Double.NaN;
|
||||
|
||||
|
@ -423,7 +419,7 @@ public final class StatUtilsTest extends TestCase {
|
|||
public void testGeometricMean() throws Exception {
|
||||
double[] test = null;
|
||||
try {
|
||||
double x = StatUtils.geometricMean(test);
|
||||
StatUtils.geometricMean(test);
|
||||
fail("Expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
|
|
@ -41,10 +41,8 @@ public final class DescriptiveStatisticsImplTest extends TestCase {
|
|||
private double n = 4;
|
||||
private double min = 1;
|
||||
private double max = 3;
|
||||
private double skewness = 0;
|
||||
private double kurtosis = 0.5;
|
||||
private double tolerance = 10E-15;
|
||||
|
||||
|
||||
public DescriptiveStatisticsImplTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
@ -196,13 +194,13 @@ public final class DescriptiveStatisticsImplTest extends TestCase {
|
|||
assertEquals("expecting max",5,u.getPercentile(99),10E-12);
|
||||
assertEquals("expecting middle",3,u.getPercentile(50),10E-12);
|
||||
try {
|
||||
double x = u.getPercentile(0);
|
||||
u.getPercentile(0);
|
||||
fail("expecting IllegalArgumentException for getPercentile(0)");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
double x = u.getPercentile(120);
|
||||
u.getPercentile(120);
|
||||
fail("expecting IllegalArgumentException for getPercentile(120)");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
|
|
@ -42,8 +42,6 @@ public final class DescriptiveStatisticsTest extends TestCase {
|
|||
private double n = 4;
|
||||
private double min = 1;
|
||||
private double max = 3;
|
||||
private double skewness = 0;
|
||||
private double kurtosis = 0.5;
|
||||
private double tolerance = 10E-15;
|
||||
|
||||
public DescriptiveStatisticsTest(String name) {
|
||||
|
@ -251,13 +249,13 @@ public final class DescriptiveStatisticsTest extends TestCase {
|
|||
assertEquals("expecting max",5,u.getPercentile(99),10E-12);
|
||||
assertEquals("expecting middle",3,u.getPercentile(50),10E-12);
|
||||
try {
|
||||
double x = u.getPercentile(0);
|
||||
u.getPercentile(0);
|
||||
fail("expecting IllegalArgumentException for getPercentile(0)");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
double x = u.getPercentile(120);
|
||||
u.getPercentile(120);
|
||||
fail("expecting IllegalArgumentException for getPercentile(120)");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
@ -331,7 +329,7 @@ public final class DescriptiveStatisticsTest extends TestCase {
|
|||
|
||||
public void testNewInstanceClassNull() {
|
||||
try {
|
||||
DescriptiveStatistics u = DescriptiveStatistics.newInstance((Class)null);
|
||||
DescriptiveStatistics.newInstance((Class)null);
|
||||
fail("null is not a valid descriptive statistics class");
|
||||
} catch (NullPointerException ex) {
|
||||
// success
|
||||
|
@ -347,7 +345,9 @@ public final class DescriptiveStatisticsTest extends TestCase {
|
|||
DescriptiveStatisticsImpl.class);
|
||||
assertNotNull(u);
|
||||
assertTrue(u instanceof DescriptiveStatisticsImpl);
|
||||
} catch (Exception ex) {
|
||||
} catch (InstantiationException ex) {
|
||||
fail();
|
||||
} catch (IllegalAccessException ex) {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,6 @@ public final class ListUnivariateImplTest extends TestCase {
|
|||
private double n = 4;
|
||||
private double min = 1;
|
||||
private double max = 3;
|
||||
private double skewness = 0;
|
||||
private double kurtosis = 0.5;
|
||||
private double tolerance = 10E-15;
|
||||
|
||||
public ListUnivariateImplTest(String name) {
|
||||
|
|
|
@ -44,8 +44,6 @@ public final class MixedListUnivariateImplTest extends TestCase {
|
|||
private double n = 4;
|
||||
private double min = 1;
|
||||
private double max = 3;
|
||||
private double skewness = 0;
|
||||
private double kurtosis = 0.5;
|
||||
private double tolerance = 10E-15;
|
||||
|
||||
private TransformerMap transformers = new TransformerMap();
|
||||
|
@ -102,8 +100,6 @@ public final class MixedListUnivariateImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testN0andN1Conditions() throws Exception {
|
||||
List list = new ArrayList();
|
||||
|
||||
DescriptiveStatistics u = new ListUnivariateImpl(new ArrayList(),transformers);
|
||||
|
||||
assertTrue(
|
||||
|
|
|
@ -54,7 +54,6 @@ public final class StatisticalSummaryValuesTest extends TestCase {
|
|||
public void testEqualsAndHashCode() {
|
||||
StatisticalSummaryValues u = new StatisticalSummaryValues(1, 2, 3, 4, 5, 6);
|
||||
StatisticalSummaryValues t = null;
|
||||
int emptyHash = u.hashCode();
|
||||
assertTrue("reflexive", u.equals(u));
|
||||
assertFalse("non-null compared to null", u.equals(t));
|
||||
assertFalse("wrong type", u.equals(new Double(0)));
|
||||
|
|
|
@ -117,7 +117,6 @@ public final class SummaryStatisticsImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testNaNContracts() {
|
||||
double nan = Double.NaN;
|
||||
assertTrue("mean not NaN",Double.isNaN(u.getMean()));
|
||||
assertTrue("min not NaN",Double.isNaN(u.getMin()));
|
||||
assertTrue("std dev not NaN",Double.isNaN(u.getStandardDeviation()));
|
||||
|
|
|
@ -32,11 +32,9 @@ public class TTestTest extends TestCase {
|
|||
protected TTest testStatistic = new TTestImpl();
|
||||
|
||||
private double[] tooShortObs = { 1.0 };
|
||||
private double[] nullObserved = null;
|
||||
private double[] emptyObs = {};
|
||||
private SummaryStatistics emptyStats = SummaryStatistics.newInstance();
|
||||
private SummaryStatistics nullStats = null;
|
||||
SummaryStatistics tooShortStats = null;
|
||||
SummaryStatistics tooShortStats = null;
|
||||
|
||||
public TTestTest(String name) {
|
||||
super(name);
|
||||
|
@ -74,14 +72,14 @@ public class TTestTest extends TestCase {
|
|||
testStatistic.tTest(mu, sampleStats), 10E-10);
|
||||
|
||||
try {
|
||||
testStatistic.t(mu, nullObserved);
|
||||
testStatistic.t(mu, (double[]) null);
|
||||
fail("arguments too short, IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
testStatistic.t(mu, nullStats);
|
||||
testStatistic.t(mu, (SummaryStatistics) null);
|
||||
fail("arguments too short, IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -289,8 +287,7 @@ public class TTestTest extends TestCase {
|
|||
double[] sample1 = {1d, 3d, 5d, 7d};
|
||||
double[] sample2 = {0d, 6d, 11d, 2d};
|
||||
double[] sample3 = {5d, 7d, 8d, 10d};
|
||||
double[] sample4 = {0d, 2d};
|
||||
|
||||
|
||||
// Target values computed using R, version 1.8.1 (linux version)
|
||||
assertEquals(-0.3133, testStatistic.pairedT(sample1, sample2), 1E-4);
|
||||
assertEquals(0.774544295819, testStatistic.pairedTTest(sample1, sample2), 1E-10);
|
||||
|
|
|
@ -193,11 +193,8 @@ public class TestUtilsTest extends TestCase {
|
|||
}
|
||||
|
||||
private double[] tooShortObs = { 1.0 };
|
||||
private double[] nullObserved = null;
|
||||
private double[] emptyObs = {};
|
||||
private SummaryStatistics emptyStats = SummaryStatistics.newInstance();
|
||||
private SummaryStatistics nullStats = null;
|
||||
SummaryStatistics tooShortStats = null;
|
||||
|
||||
public void testOneSampleT() throws Exception {
|
||||
double[] observed =
|
||||
|
@ -220,14 +217,14 @@ public class TestUtilsTest extends TestCase {
|
|||
TestUtils.tTest(mu, sampleStats), 10E-10);
|
||||
|
||||
try {
|
||||
TestUtils.t(mu, nullObserved);
|
||||
TestUtils.t(mu, (double[]) null);
|
||||
fail("arguments too short, IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
TestUtils.t(mu, nullStats);
|
||||
TestUtils.t(mu, (SummaryStatistics) null);
|
||||
fail("arguments too short, IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -261,13 +258,13 @@ public class TestUtilsTest extends TestCase {
|
|||
}
|
||||
|
||||
try {
|
||||
TestUtils.t(mu, tooShortStats);
|
||||
TestUtils.t(mu, (SummaryStatistics) null);
|
||||
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// exptected
|
||||
}
|
||||
try {
|
||||
TestUtils.tTest(mu, tooShortStats);
|
||||
TestUtils.tTest(mu, (SummaryStatistics) null);
|
||||
fail("insufficient data to perform t test, IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// exptected
|
||||
|
@ -363,7 +360,7 @@ public class TestUtilsTest extends TestCase {
|
|||
}
|
||||
|
||||
try {
|
||||
TestUtils.tTest(sampleStats1, tooShortStats, .01);
|
||||
TestUtils.tTest(sampleStats1, (SummaryStatistics) null, .01);
|
||||
fail("insufficient data, IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -377,7 +374,7 @@ public class TestUtilsTest extends TestCase {
|
|||
}
|
||||
|
||||
try {
|
||||
TestUtils.tTest(sampleStats1, tooShortStats);
|
||||
TestUtils.tTest(sampleStats1, (SummaryStatistics) null);
|
||||
fail("insufficient data, IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -391,7 +388,7 @@ public class TestUtilsTest extends TestCase {
|
|||
}
|
||||
|
||||
try {
|
||||
TestUtils.t(sampleStats1, tooShortStats);
|
||||
TestUtils.t(sampleStats1, (SummaryStatistics) null);
|
||||
fail("insufficient data, IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
|
@ -435,8 +432,7 @@ public class TestUtilsTest extends TestCase {
|
|||
double[] sample1 = {1d, 3d, 5d, 7d};
|
||||
double[] sample2 = {0d, 6d, 11d, 2d};
|
||||
double[] sample3 = {5d, 7d, 8d, 10d};
|
||||
double[] sample4 = {0d, 2d};
|
||||
|
||||
|
||||
// Target values computed using R, version 1.8.1 (linux version)
|
||||
assertEquals(-0.3133, TestUtils.pairedT(sample1, sample2), 1E-4);
|
||||
assertEquals(0.774544295819, TestUtils.pairedTTest(sample1, sample2), 1E-10);
|
||||
|
|
|
@ -222,7 +222,7 @@ public final class SimpleRegressionTest extends TestCase {
|
|||
regression.getSlopeConfidenceInterval() < regression.getSlopeConfidenceInterval(0.01));
|
||||
|
||||
try {
|
||||
double x = regression.getSlopeConfidenceInterval(1);
|
||||
regression.getSlopeConfidenceInterval(1);
|
||||
fail("expecting IllegalArgumentException for alpha = 1");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
|
|
|
@ -46,11 +46,11 @@ public final class MathUtilsTest extends TestCase {
|
|||
int bigNeg = Integer.MIN_VALUE;
|
||||
assertEquals(big, MathUtils.addAndCheck(big, 0));
|
||||
try {
|
||||
int res = MathUtils.addAndCheck(big, 1);
|
||||
MathUtils.addAndCheck(big, 1);
|
||||
fail("Expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {}
|
||||
try {
|
||||
int res = MathUtils.addAndCheck(bigNeg, -1);
|
||||
MathUtils.addAndCheck(bigNeg, -1);
|
||||
fail("Expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {}
|
||||
}
|
||||
|
@ -60,11 +60,11 @@ public final class MathUtilsTest extends TestCase {
|
|||
int bigNeg = Integer.MIN_VALUE;
|
||||
assertEquals(big, MathUtils.mulAndCheck(big, 1));
|
||||
try {
|
||||
int res = MathUtils.mulAndCheck(big, 2);
|
||||
MathUtils.mulAndCheck(big, 2);
|
||||
fail("Expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {}
|
||||
try {
|
||||
int res = MathUtils.mulAndCheck(bigNeg, 2);
|
||||
MathUtils.mulAndCheck(bigNeg, 2);
|
||||
fail("Expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {}
|
||||
}
|
||||
|
@ -74,20 +74,19 @@ public final class MathUtilsTest extends TestCase {
|
|||
int bigNeg = Integer.MIN_VALUE;
|
||||
assertEquals(big, MathUtils.subAndCheck(big, 0));
|
||||
try {
|
||||
int res = MathUtils.subAndCheck(big, -1);
|
||||
MathUtils.subAndCheck(big, -1);
|
||||
fail("Expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {}
|
||||
try {
|
||||
int res = MathUtils.subAndCheck(bigNeg, 1);
|
||||
MathUtils.subAndCheck(bigNeg, 1);
|
||||
fail("Expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {}
|
||||
}
|
||||
|
||||
public void testSubAndCheckErrorMessage() {
|
||||
int big = Integer.MAX_VALUE;
|
||||
int bigNeg = Integer.MIN_VALUE;
|
||||
try {
|
||||
int res = MathUtils.subAndCheck(big, -1);
|
||||
MathUtils.subAndCheck(big, -1);
|
||||
fail("Expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {
|
||||
assertEquals("overflow: subtract", ex.getMessage());
|
||||
|
@ -136,27 +135,27 @@ public final class MathUtilsTest extends TestCase {
|
|||
|
||||
public void testBinomialCoefficientFail() {
|
||||
try {
|
||||
long x = MathUtils.binomialCoefficient(4,5);
|
||||
MathUtils.binomialCoefficient(4,5);
|
||||
fail ("expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
|
||||
try {
|
||||
double x = MathUtils.binomialCoefficientDouble(4,5);
|
||||
MathUtils.binomialCoefficientDouble(4,5);
|
||||
fail ("expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
|
||||
try {
|
||||
double x = MathUtils.binomialCoefficientLog(4,5);
|
||||
MathUtils.binomialCoefficientLog(4,5);
|
||||
fail ("expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
long x = MathUtils.binomialCoefficient(67,34);
|
||||
MathUtils.binomialCoefficient(67,34);
|
||||
fail ("expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {
|
||||
;
|
||||
|
@ -181,25 +180,25 @@ public final class MathUtilsTest extends TestCase {
|
|||
|
||||
public void testFactorialFail() {
|
||||
try {
|
||||
long x = MathUtils.factorial(-1);
|
||||
MathUtils.factorial(-1);
|
||||
fail ("expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
double x = MathUtils.factorialDouble(-1);
|
||||
MathUtils.factorialDouble(-1);
|
||||
fail ("expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
double x = MathUtils.factorialLog(-1);
|
||||
MathUtils.factorialLog(-1);
|
||||
fail ("expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
try {
|
||||
double x = MathUtils.factorial(21);
|
||||
MathUtils.factorial(21);
|
||||
fail ("expecting ArithmeticException");
|
||||
} catch (ArithmeticException ex) {
|
||||
;
|
||||
|
@ -241,7 +240,7 @@ public final class MathUtilsTest extends TestCase {
|
|||
int test = 10;
|
||||
while (!foundLimit) {
|
||||
try {
|
||||
double x = MathUtils.binomialCoefficient(test, test / 2);
|
||||
MathUtils.binomialCoefficient(test, test / 2);
|
||||
} catch (ArithmeticException ex) {
|
||||
foundLimit = true;
|
||||
System.out.println
|
||||
|
@ -284,7 +283,7 @@ public final class MathUtilsTest extends TestCase {
|
|||
int test = 10;
|
||||
while (!foundLimit) {
|
||||
try {
|
||||
double x = MathUtils.factorial(test);
|
||||
MathUtils.factorial(test);
|
||||
} catch (ArithmeticException ex) {
|
||||
foundLimit = true;
|
||||
System.out.println
|
||||
|
|
|
@ -22,11 +22,9 @@ package org.apache.commons.math.util;
|
|||
*/
|
||||
public class TestBean {
|
||||
private Double x = new Double(1.0);
|
||||
|
||||
|
||||
private String y = "1.0";
|
||||
|
||||
private Double z = new Double(2.0);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -66,7 +64,6 @@ public class TestBean {
|
|||
*
|
||||
*/
|
||||
public void setZ(Double double1) {
|
||||
z = double1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,11 +40,14 @@ Commons Math Release Notes</title>
|
|||
</properties>
|
||||
<body>
|
||||
<release version="1.2-SNAPSHOT" date="TBD">
|
||||
<action dev="luc" type="fix">
|
||||
Fixed numerous warnings in test code.
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-156" due-to="Tyler Ward">
|
||||
Use the initial guess provided by the user in BrentSolver.solve(), thus
|
||||
improving speed.
|
||||
</action>
|
||||
<action dev="luc" type="update">
|
||||
<action dev="luc" type="add">
|
||||
Added the estimation optimization, geometry and ode package from the
|
||||
Mantissa library.
|
||||
</action>
|
||||
|
|
Loading…
Reference in New Issue