You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by ed...@apache.org on 2010/05/19 07:24:38 UTC

svn commit: r946031 - in /incubator/hama/trunk: ./ src/test/org/apache/hama/examples/ src/test/org/apache/hama/mapreduce/ src/test/org/apache/hama/matrix/

Author: edwardyoon
Date: Wed May 19 05:24:38 2010
New Revision: 946031

URL: http://svn.apache.org/viewvc?rev=946031&view=rev
Log:
Remove meaningless unit tests

Added:
    incubator/hama/trunk/src/test/org/apache/hama/examples/TestBlockMatrixMapReduce.java
    incubator/hama/trunk/src/test/org/apache/hama/examples/TestRandomMatrixMapReduce.java
Removed:
    incubator/hama/trunk/src/test/org/apache/hama/mapreduce/TestBlockMatrixMapReduce.java
    incubator/hama/trunk/src/test/org/apache/hama/mapreduce/TestRandomMatrixMapReduce.java
    incubator/hama/trunk/src/test/org/apache/hama/matrix/TestMatrixVectorMult.java
    incubator/hama/trunk/src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java
Modified:
    incubator/hama/trunk/CHANGES.txt

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=946031&r1=946030&r2=946031&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Wed May 19 05:24:38 2010
@@ -42,6 +42,7 @@ Trunk (unreleased changes)
 
   IMPROVEMENTS
 
+    HAMA-261: Remove meaningless unit tests (edwardyoon)
     HAMA-253: Change the blog link url (edwardyoon)
     HAMA-247: Discuss / Refactor HamaMaster and GroomServer (hyunsik)
     HAMA-239: Remove unused class (edwardyoon)

Added: incubator/hama/trunk/src/test/org/apache/hama/examples/TestBlockMatrixMapReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/examples/TestBlockMatrixMapReduce.java?rev=946031&view=auto
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/examples/TestBlockMatrixMapReduce.java (added)
+++ incubator/hama/trunk/src/test/org/apache/hama/examples/TestBlockMatrixMapReduce.java Wed May 19 05:24:38 2010
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hama.examples;
+
+import java.io.IOException;
+
+import org.apache.hama.HamaCluster;
+import org.apache.hama.matrix.DenseMatrix;
+import org.apache.log4j.Logger;
+import org.apache.hama.examples.MatrixMultiplication;
+
+public class TestBlockMatrixMapReduce extends HamaCluster {
+  static final Logger LOG = Logger.getLogger(TestBlockMatrixMapReduce.class);
+  static final int SIZE = 32;
+
+  /** constructor */
+  public TestBlockMatrixMapReduce() {
+    super();
+  }
+
+  public void testBlockMatrixMapReduce() throws IOException,
+      ClassNotFoundException {
+    DenseMatrix m1 = DenseMatrix.random(conf, SIZE, SIZE);
+    DenseMatrix m2 = DenseMatrix.random(conf, SIZE, SIZE);
+
+    DenseMatrix c = MatrixMultiplication.mult(m1, m2, 16);
+
+    double[][] mem = new double[SIZE][SIZE];
+    for (int i = 0; i < SIZE; i++) {
+      for (int j = 0; j < SIZE; j++) {
+        for (int k = 0; k < SIZE; k++) {
+          mem[i][k] += m1.get(i, j) * m2.get(j, k);
+        }
+      }
+    }
+
+    for (int i = 0; i < SIZE; i++) {
+      for (int j = 0; j < SIZE; j++) {
+        double gap = (mem[i][j] - c.get(i, j));
+        assertTrue(gap < 0.000001 || gap < -0.000001);
+      }
+    }
+  }
+}

Added: incubator/hama/trunk/src/test/org/apache/hama/examples/TestRandomMatrixMapReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/examples/TestRandomMatrixMapReduce.java?rev=946031&view=auto
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/examples/TestRandomMatrixMapReduce.java (added)
+++ incubator/hama/trunk/src/test/org/apache/hama/examples/TestRandomMatrixMapReduce.java Wed May 19 05:24:38 2010
@@ -0,0 +1,59 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hama.examples;
+
+import java.io.IOException;
+
+import org.apache.hama.HamaCluster;
+import org.apache.hama.examples.RandomMatrix;
+import org.apache.hama.matrix.DenseMatrix;
+import org.apache.hama.matrix.SparseMatrix;
+import org.apache.log4j.Logger;
+
+public class TestRandomMatrixMapReduce extends HamaCluster {
+  static final Logger LOG = Logger.getLogger(TestRandomMatrixMapReduce.class);
+  
+  public void testRandomMatrixMapReduce() throws IOException {
+    DenseMatrix rand = RandomMatrix.random_mapred(conf, 20, 20);
+    assertEquals(20, rand.getRows());
+    assertEquals(20, rand.getColumns());
+
+    for(int i = 0; i < 20; i++) {
+      for(int j = 0; j < 20; j++) {
+        assertTrue(rand.get(i, j) > 0);
+      }
+    }
+
+    rand.close();
+    
+    SparseMatrix rand2 = RandomMatrix.random_mapred(conf, 20, 20, 30);
+    assertEquals(20, rand2.getRows());
+    assertEquals(20, rand2.getColumns());
+    boolean zeroAppear = false;
+    for(int i = 0; i < 20; i++) {
+      for(int j = 0; j < 20; j++) {
+        if(rand2.get(i, j) == 0.0)
+          zeroAppear = true;
+      }
+    }
+    assertTrue(zeroAppear);
+    rand2.close();
+  }
+}