[Scipy-svn] r4099 - in trunk/scipy/io/arff/tests: . data

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Apr 7 15:37:37 EDT 2008


Author: cdavid
Date: 2008-04-07 14:37:33 -0500 (Mon, 07 Apr 2008)
New Revision: 4099

Added:
   trunk/scipy/io/arff/tests/data/test4.arff
   trunk/scipy/io/arff/tests/test_data.py
Log:
Start testing full arff files readers.

Added: trunk/scipy/io/arff/tests/data/test4.arff
===================================================================
--- trunk/scipy/io/arff/tests/data/test4.arff	2008-04-07 19:28:59 UTC (rev 4098)
+++ trunk/scipy/io/arff/tests/data/test4.arff	2008-04-07 19:37:33 UTC (rev 4099)
@@ -0,0 +1,12 @@
+ at RELATION test4
+
+ at ATTRIBUTE attr0	REAL
+ at ATTRIBUTE attr1 	REAL
+ at ATTRIBUTE attr2 	REAL
+ at ATTRIBUTE attr3	REAL
+ at ATTRIBUTE class 	{class0, class1, class2, class3}
+
+ at DATA
+0.1, 0.2, 0.3, 0.4,class1
+-0.1, -0.2, -0.3, -0.4,class2
+1, 2, 3, 4,class3

Added: trunk/scipy/io/arff/tests/test_data.py
===================================================================
--- trunk/scipy/io/arff/tests/test_data.py	2008-04-07 19:28:59 UTC (rev 4098)
+++ trunk/scipy/io/arff/tests/test_data.py	2008-04-07 19:37:33 UTC (rev 4099)
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+"""Tests for parsing full arff files."""
+import os
+
+from scipy.testing import *
+
+from scipy.io.arff.arffread import read_arff
+
+data_path = os.path.join(os.path.dirname(__file__), 'data')
+
+test4 = os.path.join(data_path, 'test4.arff')
+expect4_data = [(0.1, 0.2, 0.3, 0.4, 'class1'), 
+        (-0.1, -0.2, -0.3, -0.4, 'class2'), 
+        (1, 2, 3, 4, 'class3')]
+
+
+class DataTest(TestCase):
+    def test1(self):
+        """Parsing trivial file with nothing."""
+        data, meta = read_arff(test4)
+        for i in range(len(data)):
+            for j in range(4):
+                assert_array_almost_equal(expect4_data[i][j], data[i][j])
+
+if __name__ == "__main__":
+    nose.run(argv=['', __file__])




More information about the Scipy-svn mailing list