Return-Path: X-Original-To: apmail-mahout-commits-archive@www.apache.org Delivered-To: apmail-mahout-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4758DD849 for ; Sat, 1 Sep 2012 22:31:48 +0000 (UTC) Received: (qmail 55184 invoked by uid 500); 1 Sep 2012 22:31:48 -0000 Delivered-To: apmail-mahout-commits-archive@mahout.apache.org Received: (qmail 55140 invoked by uid 500); 1 Sep 2012 22:31:48 -0000 Mailing-List: contact commits-help@mahout.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mahout.apache.org Delivered-To: mailing list commits@mahout.apache.org Received: (qmail 55130 invoked by uid 99); 1 Sep 2012 22:31:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Sep 2012 22:31:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Sep 2012 22:31:45 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 38822238896F; Sat, 1 Sep 2012 22:31:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@mahout.apache.org From: tdunning@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120901223102.38822238896F@eris.apache.org> 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 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"