Well, this patch works but what I was getting at in my earlier post is that the modelPrototype class is being improperly specified given the change in the Lucene output to NamedVector. Consider this as an alternative patch:

  public void testDirichlet() throws Exception {
    Path output = getTestTempDirPath("output");
    DirichletDriver.runJob(getTestTempDirPath("testdata"), output,
L1ModelDistribution.class.getName(), "org.apache.mahout.math.RandomAccessSparseVector",
                           15, 10, 1.0, 1, true, true, 0);

... which passes without the patch below, vs what was there before which assumed too much about the Lucene output

  public void testDirichlet() throws Exception {
    Path output = getTestTempDirPath("output");
NamedVector prototype = (NamedVector) sampleData.get(0).get(); // doesn't handle NamedVector(NamedVector(v))
    DirichletDriver.runJob(getTestTempDirPath("testdata"), output,
L1ModelDistribution.class.getName(), prototype.getDelegate().getClass().getName(),
                           15, 10, 1.0, 1, true, true, 0);

Dirichlet itself will work with input of NamedVector(NamedVector(v)); the test won't.
Jeff


On 7/1/10 5:52 AM, [email protected] wrote:
Author: gsingers
Date: Thu Jul  1 12:52:37 2010
New Revision: 959641

URL: http://svn.apache.org/viewvc?rev=959641&view=rev
Log:
MAHOUT-374: Get the tests to pass

Modified:
     
mahout/trunk/utils/src/test/java/org/apache/mahout/clustering/TestClusterDumper.java

Modified: 
mahout/trunk/utils/src/test/java/org/apache/mahout/clustering/TestClusterDumper.java
URL: 
http://svn.apache.org/viewvc/mahout/trunk/utils/src/test/java/org/apache/mahout/clustering/TestClusterDumper.java?rev=959641&r1=959640&r2=959641&view=diff
==============================================================================
--- 
mahout/trunk/utils/src/test/java/org/apache/mahout/clustering/TestClusterDumper.java
 (original)
+++ 
mahout/trunk/utils/src/test/java/org/apache/mahout/clustering/TestClusterDumper.java
 Thu Jul  1 12:52:37 2010
@@ -132,7 +132,14 @@ public class TestClusterDumper extends M
      i = 0;
      for (Vector vector : iterable) {
        Assert.assertNotNull(vector);
-      NamedVector namedVector = new NamedVector(vector, "P(" + i + ')');
+      NamedVector namedVector;
+      if (vector instanceof NamedVector){
+        //rename it for testing purposes
+        namedVector = new NamedVector(((NamedVector)vector).getDelegate(), 
"P(" + i + ')');
+
+      } else {
+        namedVector = new NamedVector(vector, "P(" + i + ')');
+      }
        System.out.println(ClusterBase.formatVector(namedVector, 
termDictionary));
        sampleData.add(new VectorWritable(namedVector));
        i++;




Reply via email to