You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by gs...@apache.org on 2010/07/01 14:52:37 UTC
svn commit: r959641 -
/mahout/trunk/utils/src/test/java/org/apache/mahout/clustering/TestClusterDumper.java
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++;
Re: svn commit: r959641 - /mahout/trunk/utils/src/test/java/org/apache/mahout/clustering/TestClusterDumper.java
Posted by Grant Ingersoll <gs...@apache.org>.
On Jul 1, 2010, at 12:08 PM, Jeff Eastman wrote:
> 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.
Whew. Good to know. If you want to revert and replace, I'm fine with that.
> Jeff
>
>
> On 7/1/10 5:52 AM, gsingers@apache.org 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++;
>>
>>
>>
>>
>
--------------------------
Grant Ingersoll
http://www.lucidimagination.com/
Search the Lucene ecosystem using Solr/Lucene: http://www.lucidimagination.com/search
Re: svn commit: r959641 - /mahout/trunk/utils/src/test/java/org/apache/mahout/clustering/TestClusterDumper.java
Posted by Jeff Eastman <jd...@windwardsolutions.com>.
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, gsingers@apache.org 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++;
>
>
>
>