mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdunn...@apache.org
Subject svn commit: r1379883 - /mahout/trunk/integration/src/test/java/org/apache/mahout/utils/vectors/arff/ARFFVectorIterableTest.java
Date Sat, 01 Sep 2012 22:31:02 GMT
Author: tdunning
Date: Sat Sep  1 22:31:01 2012
New Revision: 1379883

URL: http://svn.apache.org/viewvc?rev=1379883&view=rev
Log:
MAHOUT-1063 - Add test case for ARFF integers and reals.

Modified:
    mahout/trunk/integration/src/test/java/org/apache/mahout/utils/vectors/arff/ARFFVectorIterableTest.java

Modified: mahout/trunk/integration/src/test/java/org/apache/mahout/utils/vectors/arff/ARFFVectorIterableTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/test/java/org/apache/mahout/utils/vectors/arff/ARFFVectorIterableTest.java?rev=1379883&r1=1379882&r2=1379883&view=diff
==============================================================================
--- mahout/trunk/integration/src/test/java/org/apache/mahout/utils/vectors/arff/ARFFVectorIterableTest.java
(original)
+++ mahout/trunk/integration/src/test/java/org/apache/mahout/utils/vectors/arff/ARFFVectorIterableTest.java
Sat Sep  1 22:31:01 2012
@@ -222,7 +222,30 @@ public final class ARFFVectorIterableTes
     assertNotNull("nominals for bar are null", noms);
     assertEquals(2, noms.size());
   }
-  
+
+  @Test
+  public void testNumerics() throws Exception {
+    String arff = "@RELATION numerics\n"
+      + "@ATTRIBUTE theNumeric NUMERIC\n"
+      + "@ATTRIBUTE theInteger INTEGER\n"
+      + "@ATTRIBUTE theReal REAL\n"
+      + "@DATA\n"
+      + "1.0,2,3.0";
+    ARFFModel model = new MapBackedARFFModel();
+    ARFFVectorIterable iterable = new ARFFVectorIterable(arff, model);
+    model = iterable.getModel();
+    assertNotNull(model);
+    assertEquals(3, model.getLabelSize());
+    assertEquals(ARFFType.NUMERIC, model.getARFFType(0));
+    assertEquals(ARFFType.INTEGER, model.getARFFType(1));
+    assertEquals(ARFFType.REAL, model.getARFFType(2));
+    Iterator<Vector> it = iterable.iterator();
+    Vector vector = it.next();
+    assertEquals(1.0, vector.get(0), EPSILON);
+    assertEquals(2.0, vector.get(1), EPSILON);
+    assertEquals(3.0, vector.get(2), EPSILON);
+  }
+
   private static final String SAMPLE_DENSE_ARFF = "   % Comments\n" + "   % \n" + "   % Comments
go here"
                                                   + "   % \n" + "   @RELATION golf\n" + '\n'
                                                   + "   @ATTRIBUTE outlook {sunny,overcast,
rain}\n"



Mime
View raw message