mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdunn...@apache.org
Subject svn commit: r992673 - in /mahout/trunk/math/src/test/java/org/apache/mahout/math: AbstractTestVector.java MahoutTestCase.java MatrixTest.java TestMatrixView.java jet/random/NormalTest.java
Date Sat, 04 Sep 2010 20:40:59 GMT
Author: tdunning
Date: Sat Sep  4 20:40:59 2010
New Revision: 992673

URL: http://svn.apache.org/viewvc?rev=992673&view=rev
Log:
Removed "throws Exception".
Put RandUtils.useTestSeed() into MahoutTestCase

Modified:
    mahout/trunk/math/src/test/java/org/apache/mahout/math/AbstractTestVector.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/MahoutTestCase.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java
    mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/AbstractTestVector.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/AbstractTestVector.java?rev=992673&r1=992672&r2=992673&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/AbstractTestVector.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/AbstractTestVector.java Sat Sep
 4 20:40:59 2010
@@ -38,7 +38,7 @@ public abstract class AbstractTestVector
 
   @Override
   @Before
-  public void setUp() throws Exception {
+  public void setUp() {
     super.setUp();
     test = generateTestVector(2 * values.length + 1);
     for (int i = 0; i < values.length; i++) {

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/MahoutTestCase.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/MahoutTestCase.java?rev=992673&r1=992672&r2=992673&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/MahoutTestCase.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/MahoutTestCase.java Sat Sep  4
20:40:59 2010
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 
+import org.apache.mahout.common.RandomUtils;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -36,12 +37,13 @@ public abstract class MahoutTestCase ext
   private File testTempDir;
 
   @Before
-  public void setUp() throws Exception {
+  public void setUp() {
     testTempDir = null;
+    RandomUtils.useTestSeed();
   }
 
   @After
-  public void tearDown() throws Exception {
+  public void tearDown() {
     if (testTempDir != null) {
       new DeletingVisitor().accept(testTempDir);
     }

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java?rev=992673&r1=992672&r2=992673&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java Sat Sep  4 20:40:59
2010
@@ -44,7 +44,7 @@ public abstract class MatrixTest extends
 
   @Override
   @Before
-  public void setUp() throws Exception {
+  public void setUp() {
     super.setUp();
     test = matrixFactory(values);
   }

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java?rev=992673&r1=992672&r2=992673&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java Sat Sep  4
20:40:59 2010
@@ -36,7 +36,7 @@ public final class TestMatrixView extend
 
   @Override
   @Before
-  public void setUp() throws Exception {
+  public void setUp() {
     super.setUp();
     int[] offset = {1, 1};
     int[] card = {3, 2};
@@ -119,7 +119,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testViewPart() throws Exception {
+  public void testViewPart() {
     int[] offset = {1, 1};
     int[] size = {2, 1};
     Matrix view = test.viewPart(offset, size);
@@ -166,7 +166,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testAssignDoubleArrayArray() throws Exception {
+  public void testAssignDoubleArrayArray() {
     int[] c = test.size();
     test.assign(new double[3][2]);
     for (int row = 0; row < c[ROW]; row++) {
@@ -184,7 +184,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testAssignMatrixBinaryFunction() throws Exception {
+  public void testAssignMatrixBinaryFunction() {
     int[] c = test.size();
     test.assign(test, Functions.PLUS);
     for (int row = 0; row < c[ROW]; row++) {
@@ -201,7 +201,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testAssignMatrix() throws Exception {
+  public void testAssignMatrix() {
     int[] c = test.size();
     Matrix value = test.like();
     value.assign(test);
@@ -243,7 +243,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testGet() throws Exception {
+  public void testGet() {
     int[] c = test.size();
     for (int row = 0; row < c[ROW]; row++) {
       for (int col = 0; col < c[COL]; col++) {
@@ -274,7 +274,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testMinus() throws Exception {
+  public void testMinus() {
     int[] c = test.size();
     Matrix value = test.minus(test);
     for (int row = 0; row < c[ROW]; row++) {
@@ -302,7 +302,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testPlusMatrix() throws Exception {
+  public void testPlusMatrix() {
     int[] c = test.size();
     Matrix value = test.plus(test);
     for (int row = 0; row < c[ROW]; row++) {
@@ -351,7 +351,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testTimesMatrix() throws Exception {
+  public void testTimesMatrix() {
     int[] c = test.size();
     Matrix transpose = test.transpose();
     Matrix value = test.times(transpose);
@@ -389,7 +389,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testAssignRow() throws Exception {
+  public void testAssignRow() {
     double[] data = {2.1, 3.2};
     test.assignRow(1, new DenseVector(data));
     assertEquals("test[1][0]", 2.1, test.getQuick(1, 0), EPSILON);
@@ -403,7 +403,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testAssignColumn() throws Exception {
+  public void testAssignColumn() {
     double[] data = {2.1, 3.2, 4.3};
     test.assignColumn(1, new DenseVector(data));
     assertEquals("test[0][1]", 2.1, test.getQuick(0, 1), EPSILON);
@@ -418,7 +418,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testGetRow() throws Exception {
+  public void testGetRow() {
     Vector row = test.getRow(1);
     assertEquals("row size", 2, row.getNumNondefaultElements());
   }
@@ -434,7 +434,7 @@ public final class TestMatrixView extend
   }
 
   @Test
-  public void testGetColumn() throws Exception {
+  public void testGetColumn() {
     Vector column = test.getColumn(1);
     assertEquals("row size", 3, column.getNumNondefaultElements());
   }

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java?rev=992673&r1=992672&r2=992673&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/jet/random/NormalTest.java Sat
Sep  4 20:40:59 2010
@@ -17,6 +17,8 @@
 
 package org.apache.mahout.math.jet.random;
 
+import org.apache.commons.math.ConvergenceException;
+import org.apache.commons.math.FunctionEvaluationException;
 import org.apache.mahout.common.RandomUtils;
 import org.apache.mahout.math.MahoutTestCase;
 import org.junit.Test;
@@ -43,12 +45,13 @@ public final class NormalTest extends Ma
   }
 
   @Test
-  public void consistency() throws Exception {
+  public void consistency() throws ConvergenceException, FunctionEvaluationException {
     Random gen = new Random(1);
     double offset = 0;
     double scale = 1;
+    Normal dist = new Normal(offset, scale, RandomUtils.getRandom());
     for (int k = 0; k < 20; k++) {
-      Normal dist = new Normal(offset, scale, RandomUtils.getRandom());
+      dist.setState(offset, scale);
       DistributionChecks.checkDistribution(dist, breaks, offset, scale, 10000);
       offset = gen.nextGaussian();
       scale = Math.exp(3 * gen.nextGaussian());



Mime
View raw message