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

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Apr 7 18:08:20 EDT 2008


Author: cdavid
Date: 2008-04-07 17:08:16 -0500 (Mon, 07 Apr 2008)
New Revision: 4101

Added:
   trunk/scipy/io/arff/tests/data/missing.arff
Modified:
   trunk/scipy/io/arff/tests/test_data.py
Log:
Arff reader test for missing data.

Added: trunk/scipy/io/arff/tests/data/missing.arff
===================================================================
--- trunk/scipy/io/arff/tests/data/missing.arff	2008-04-07 20:44:11 UTC (rev 4100)
+++ trunk/scipy/io/arff/tests/data/missing.arff	2008-04-07 22:08:16 UTC (rev 4101)
@@ -0,0 +1,8 @@
+% This arff file contains some missing data
+ at relation missing
+ at attribute yop real
+ at attribute yap real
+ at data
+1,5
+2,4
+?,?

Modified: trunk/scipy/io/arff/tests/test_data.py
===================================================================
--- trunk/scipy/io/arff/tests/test_data.py	2008-04-07 20:44:11 UTC (rev 4100)
+++ trunk/scipy/io/arff/tests/test_data.py	2008-04-07 22:08:16 UTC (rev 4101)
@@ -2,6 +2,7 @@
 """Tests for parsing full arff files."""
 import os
 
+import numpy as N
 from scipy.testing import *
 
 from scipy.io.arff.arffread import read_arff
@@ -14,6 +15,11 @@
         (-0.1, -0.2, -0.3, -0.4, 'class2'), 
         (1, 2, 3, 4, 'class3')]
 
+missing = os.path.join(data_path, 'missing.arff')
+expect_missing_raw = N.array([[1, 5], [2, 4], [N.nan, N.nan]])
+expect_missing = N.empty(3, [('yop', N.float), ('yap', N.float)])
+expect_missing['yop'] = expect_missing_raw[:, 0]
+expect_missing['yap'] = expect_missing_raw[:, 1]
 
 class DataTest(TestCase):
     def test1(self):
@@ -30,5 +36,11 @@
             for j in range(4):
                 assert_array_almost_equal(expect4_data[i][j], data[i][j])
 
+class MissingDataTest(TestCase):
+    def test_missing(self):
+        data, meta = read_arff(missing)
+        for i in ['yop', 'yap']:
+            assert_array_almost_equal(data[i], expect_missing[i])
+
 if __name__ == "__main__":
     nose.run(argv=['', __file__])




More information about the Scipy-svn mailing list