Skip to content

Commit

Permalink
Eliminated tabs.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@201916 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
psteitz committed Jun 26, 2005
1 parent 540caa1 commit 837fb72
Show file tree
Hide file tree
Showing 21 changed files with 609 additions and 609 deletions.
16 changes: 8 additions & 8 deletions src/test/org/apache/commons/math/TestUtils.java
Expand Up @@ -38,17 +38,17 @@ private TestUtils() {
}

public static void assertEquals(double expected, double actual, double delta) {
assertEquals(null, expected, actual, delta);
assertEquals(null, expected, actual, delta);
}

public static void assertEquals(String msg, double expected, double actual, double delta) {
// check for NaN
if(Double.isNaN(expected)){
Assert.assertTrue("" + actual + " is not NaN.",
Double.isNaN(actual));
} else {
Assert.assertEquals(msg, expected, actual, delta);
}
// check for NaN
if(Double.isNaN(expected)){
Assert.assertTrue("" + actual + " is not NaN.",
Double.isNaN(actual));
} else {
Assert.assertEquals(msg, expected, actual, delta);
}
}

/**
Expand Down
Expand Up @@ -186,7 +186,7 @@ public void testIllegalArguments() throws MathException {
* verifies that f(x[i]) = y[i] for i = 0..n-1 where n is common length.
*/
protected void verifyInterpolation(UnivariateRealFunction f, double x[], double y[])
throws Exception{
throws Exception{
for (int i = 0; i < x.length; i++) {
assertEquals(f.value(x[i]), y[i], knotTolerance);
}
Expand All @@ -197,7 +197,7 @@ protected void verifyInterpolation(UnivariateRealFunction f, double x[], double
* adjacent polynomials must agree through two derivatives at knot points
*/
protected void verifyConsistency(PolynomialSplineFunction f, double x[])
throws Exception {
throws Exception {
PolynomialFunction polynomials[] = f.getPolynomials();
for (int i = 1; i < x.length - 2; i++) {
// evaluate polynomials and derivatives at x[i + 1]
Expand Down
Expand Up @@ -24,18 +24,18 @@

public abstract class ComplexFormatAbstractTest extends TestCase {

ComplexFormat complexFormat = null;
ComplexFormat complexFormatJ = null;
ComplexFormat complexFormat = null;
ComplexFormat complexFormatJ = null;

protected abstract Locale getLocale();

protected abstract char getDecimalCharacter();

protected void setUp() throws Exception {
complexFormat = ComplexFormat.getInstance(getLocale());
complexFormatJ = ComplexFormat.getInstance(getLocale());
protected void setUp() throws Exception {
complexFormat = ComplexFormat.getInstance(getLocale());
complexFormatJ = ComplexFormat.getInstance(getLocale());
complexFormatJ.setImaginaryCharacter("j");
}
}

public void testSimpleNoDecimals() {
Complex c = new Complex(1, 1);
Expand All @@ -44,94 +44,94 @@ public void testSimpleNoDecimals() {
assertEquals(expected, actual);
}

public void testSimpleWithDecimals() {
Complex c = new Complex(1.23, 1.43);
public void testSimpleWithDecimals() {
Complex c = new Complex(1.23, 1.43);
String expected = "1" + getDecimalCharacter() + "23 + 1" + getDecimalCharacter() + "43i";
String actual = complexFormat.format(c);
assertEquals(expected, actual);
}
}

public void testSimpleWithDecimalsTrunc() {
Complex c = new Complex(1.2323, 1.4343);
public void testSimpleWithDecimalsTrunc() {
Complex c = new Complex(1.2323, 1.4343);
String expected = "1" + getDecimalCharacter() + "23 + 1" + getDecimalCharacter() + "43i";
String actual = complexFormat.format(c);
assertEquals(expected, actual);
}
}

public void testNegativeReal() {
Complex c = new Complex(-1.2323, 1.4343);
public void testNegativeReal() {
Complex c = new Complex(-1.2323, 1.4343);
String expected = "-1" + getDecimalCharacter() + "23 + 1" + getDecimalCharacter() + "43i";
String actual = complexFormat.format(c);
assertEquals(expected, actual);
}
}

public void testNegativeImaginary() {
Complex c = new Complex(1.2323, -1.4343);
public void testNegativeImaginary() {
Complex c = new Complex(1.2323, -1.4343);
String expected = "1" + getDecimalCharacter() + "23 - 1" + getDecimalCharacter() + "43i";
String actual = complexFormat.format(c);
assertEquals(expected, actual);
}
}

public void testNegativeBoth() {
Complex c = new Complex(-1.2323, -1.4343);
public void testNegativeBoth() {
Complex c = new Complex(-1.2323, -1.4343);
String expected = "-1" + getDecimalCharacter() + "23 - 1" + getDecimalCharacter() + "43i";
String actual = complexFormat.format(c);
assertEquals(expected, actual);
}
}

public void testZeroReal() {
Complex c = new Complex(0.0, -1.4343);
public void testZeroReal() {
Complex c = new Complex(0.0, -1.4343);
String expected = "0 - 1" + getDecimalCharacter() + "43i";
String actual = complexFormat.format(c);
assertEquals(expected, actual);
}
}

public void testZeroImaginary() {
Complex c = new Complex(30.233, 0);
public void testZeroImaginary() {
Complex c = new Complex(30.233, 0);
String expected = "30" + getDecimalCharacter() + "23";
String actual = complexFormat.format(c);
assertEquals(expected, actual);
}
}

public void testDifferentImaginaryChar() {
Complex c = new Complex(1, 1);
public void testDifferentImaginaryChar() {
Complex c = new Complex(1, 1);
String expected = "1 + 1j";
String actual = complexFormatJ.format(c);
assertEquals(expected, actual);
}
public void testStaticFormatComplex() {
}
public void testStaticFormatComplex() {
Locale defaultLocal = Locale.getDefault();
Locale.setDefault(getLocale());

Complex c = new Complex(232.222, -342.33);
Complex c = new Complex(232.222, -342.33);
String expected = "232" + getDecimalCharacter() + "22 - 342" + getDecimalCharacter() + "33i";
String actual = ComplexFormat.formatComplex(c);
assertEquals(expected, actual);

Locale.setDefault(defaultLocal);
}
}

public void testNan() {
Complex c = new Complex(Double.NaN, Double.NaN);
public void testNan() {
Complex c = new Complex(Double.NaN, Double.NaN);
String expected = "(NaN) + (NaN)i";
String actual = complexFormat.format(c);
assertEquals(expected, actual);
}
}

public void testPositiveInfinity() {
Complex c = new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
public void testPositiveInfinity() {
Complex c = new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
String expected = "(Infinity) + (Infinity)i";
String actual = complexFormat.format(c);
assertEquals(expected, actual);
}
}

public void testNegativeInfinity() {
Complex c = new Complex(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
public void testNegativeInfinity() {
Complex c = new Complex(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
String expected = "(-Infinity) - (Infinity)i";
String actual = complexFormat.format(c);
assertEquals(expected, actual);
}
}

public void testParseSimpleNoDecimals() {
String source = "1 + 1i";
Expand Down
Expand Up @@ -181,7 +181,7 @@ public void testConsistency() throws Exception {
double upper = Math.max(cumulativeTestPoints[i], cumulativeTestPoints[i -1]);
double lower = Math.min(cumulativeTestPoints[i], cumulativeTestPoints[i -1]);
double diff = distribution.cumulativeProbability(upper) -
distribution.cumulativeProbability(lower);
distribution.cumulativeProbability(lower);
double direct = distribution.cumulativeProbability(lower, upper);
TestUtils.assertEquals("Inconsistent cumulative probabilities for ("
+ lower + "," + upper + ")", diff, direct, tolerance);
Expand Down
Expand Up @@ -25,28 +25,28 @@ public class DistributionFactoryImplTest extends TestCase {
/** */
private DistributionFactory factory;

/**
* Constructor for DistributionFactoryImplTest.
* @param name
*/
public DistributionFactoryImplTest(String name) {
super(name);
}
/**
* @throws java.lang.Exception
*/
protected void setUp() throws Exception {
super.setUp();
/**
* Constructor for DistributionFactoryImplTest.
* @param name
*/
public DistributionFactoryImplTest(String name) {
super(name);
}
/**
* @throws java.lang.Exception
*/
protected void setUp() throws Exception {
super.setUp();
factory = new DistributionFactoryImpl();
}
}

/**
* @throws java.lang.Exception
*/
protected void tearDown() throws Exception {
/**
* @throws java.lang.Exception
*/
protected void tearDown() throws Exception {
factory = null;
super.tearDown();
}
super.tearDown();
}

public void testCreateChiSquareDistributionNegative(){
try {
Expand Down
Expand Up @@ -100,14 +100,14 @@ public void testValues() throws Exception {

private void testProbability(double x, double a, double b, double expected) throws Exception {
DistributionFactory factory = DistributionFactory.newInstance();
GammaDistribution distribution = factory.createGammaDistribution( a, b );
GammaDistribution distribution = factory.createGammaDistribution( a, b );
double actual = distribution.cumulativeProbability(x);
assertEquals("probability for " + x, expected, actual, 10e-4);
}

private void testValue(double expected, double a, double b, double p) throws Exception {
DistributionFactory factory = DistributionFactory.newInstance();
GammaDistribution distribution = factory.createGammaDistribution( a, b );
DistributionFactory factory = DistributionFactory.newInstance();
GammaDistribution distribution = factory.createGammaDistribution( a, b );
double actual = distribution.inverseCumulativeProbability(p);
assertEquals("critical value for " + p, expected, actual, 10e-4);
}
Expand Down
Expand Up @@ -65,10 +65,10 @@ protected void setup() throws Exception {
* Bug report that prompted this unit test.</a>
*/
public void testCumulativeProbabilityAgaintStackOverflow() throws Exception {
TDistributionImpl td = new TDistributionImpl(5.);
double est;
est = td.cumulativeProbability(.1);
est = td.cumulativeProbability(.01);
TDistributionImpl td = new TDistributionImpl(5.);
double est;
est = td.cumulativeProbability(.1);
est = td.cumulativeProbability(.01);
}

public void testSmallDf() throws Exception {
Expand Down
20 changes: 10 additions & 10 deletions src/test/org/apache/commons/math/fraction/FractionFormatTest.java
Expand Up @@ -23,17 +23,17 @@

public class FractionFormatTest extends TestCase {

FractionFormat properFormat = null;
FractionFormat improperFormat = null;
FractionFormat properFormat = null;
FractionFormat improperFormat = null;

protected Locale getLocale() {
return Locale.getDefault();
}

protected void setUp() throws Exception {
properFormat = FractionFormat.getProperInstance(getLocale());
improperFormat = FractionFormat.getImproperInstance(getLocale());
}
protected void setUp() throws Exception {
properFormat = FractionFormat.getProperInstance(getLocale());
improperFormat = FractionFormat.getImproperInstance(getLocale());
}

public void testFormat() {
Fraction c = new Fraction(1, 2);
Expand All @@ -46,7 +46,7 @@ public void testFormat() {
assertEquals(expected, actual);
}

public void testFormatNegative() {
public void testFormatNegative() {
Fraction c = new Fraction(-1, 2);
String expected = "-1 / 2";

Expand All @@ -55,9 +55,9 @@ public void testFormatNegative() {

actual = improperFormat.format(c);
assertEquals(expected, actual);
}
}

public void testFormatZero() {
public void testFormatZero() {
Fraction c = new Fraction(0, 1);
String expected = "0 / 1";

Expand All @@ -66,7 +66,7 @@ public void testFormatZero() {

actual = improperFormat.format(c);
assertEquals(expected, actual);
}
}

public void testFormatImproper() {
Fraction c = new Fraction(5, 3);
Expand Down

0 comments on commit 837fb72

Please sign in to comment.