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

scipy-svn@scip... scipy-svn@scip...
Mon Apr 7 14:09:53 CDT 2008


Author: cdavid
Date: 2008-04-07 14:09:50 -0500 (Mon, 07 Apr 2008)
New Revision: 4093

Added:
   trunk/scipy/io/arff/tests/test_header.py
Modified:
   trunk/scipy/io/arff/tests/
   trunk/scipy/io/arff/tests/data/
   trunk/scipy/io/arff/tests/data/test1.arff
Log:
Add tests directory.


Property changes on: trunk/scipy/io/arff/tests
___________________________________________________________________
Name: svn:ignore
   + *.pyc
*.swp



Property changes on: trunk/scipy/io/arff/tests/data
___________________________________________________________________
Name: svn:ignore
   + *.pyc
*.swp


Modified: trunk/scipy/io/arff/tests/data/test1.arff
===================================================================
--- trunk/scipy/io/arff/tests/data/test1.arff	2008-04-07 19:09:30 UTC (rev 4092)
+++ trunk/scipy/io/arff/tests/data/test1.arff	2008-04-07 19:09:50 UTC (rev 4093)
@@ -1,10 +1,10 @@
 @RELATION test1
 
-@ATTRIBUTE attr1	REAL
+@ATTRIBUTE attr0	REAL
+@ATTRIBUTE attr1 	REAL
 @ATTRIBUTE attr2 	REAL
-@ATTRIBUTE attr3 	REAL
-@ATTRIBUTE attr4	REAL
-@ATTRIBUTE class 	{class1, class2, class3, class4}
+@ATTRIBUTE attr3	REAL
+@ATTRIBUTE class 	{class0, class1, class2, class3}
 
 @DATA
 0.1, 0.2, 0.3, 0.4,class1

Added: trunk/scipy/io/arff/tests/test_header.py
===================================================================
--- trunk/scipy/io/arff/tests/test_header.py	2008-04-07 19:09:30 UTC (rev 4092)
+++ trunk/scipy/io/arff/tests/test_header.py	2008-04-07 19:09:50 UTC (rev 4093)
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+"""Test for parsing arff headers only."""
+import os
+
+from scipy.testing import *
+
+from scipy.io.arff.arffread import read_header, MetaData
+
+data_path = os.path.join(os.path.dirname(__file__), 'data')
+
+test1 = os.path.join(data_path, 'test1.arff')
+
+class HeaderTest(TestCase):
+    def test_trivial1(self):
+        """Parsing trivial header with nothing."""
+        ofile = open(test1)
+        rel, attrs = read_header(ofile)
+
+        # Test relation
+        assert rel == 'test1'
+
+        # Test numerical attributes
+        assert len(attrs) == 5
+        for i in range(4):
+            assert attrs[i][0] == 'attr%d' % i
+            assert attrs[i][1] == 'REAL'
+        classes = attrs[4][1]
+
+        # Test nominal attribute
+        assert attrs[4][0] == 'class'
+        assert attrs[4][1] == '{class0, class1, class2, class3}'
+
+if __name__ == "__main__":
+    nose.run(argv=['', __file__])



More information about the Scipy-svn mailing list