[Numpy-svn] r4993 - trunk/numpy/lib/tests

numpy-svn@scip... numpy-svn@scip...
Tue Apr 8 19:57:27 CDT 2008


Author: dhuard
Date: 2008-04-08 19:57:23 -0500 (Tue, 08 Apr 2008)
New Revision: 4993

Modified:
   trunk/numpy/lib/tests/test_io.py
Log:
Added test for handling missing data using loadtxt.

Modified: trunk/numpy/lib/tests/test_io.py
===================================================================
--- trunk/numpy/lib/tests/test_io.py	2008-04-09 00:56:39 UTC (rev 4992)
+++ trunk/numpy/lib/tests/test_io.py	2008-04-09 00:57:23 UTC (rev 4993)
@@ -72,6 +72,24 @@
         x = np.loadtxt(c, dtype=int)
         a = np.array([1,2,3,4], int)
         assert_array_equal(x, a)
+        
+        c = StringIO.StringIO()
+        c.write('1,2,3,4\n')
+        c.seek(0)
+        x = np.loadtxt(c, dtype=int, delimiter=',')
+        a = np.array([1,2,3,4], int)
+        assert_array_equal(x, a)
+        
+        
+    def test_missing(self):
+        c = StringIO.StringIO()
+        c.write('1,2,3,,5\n')
+        c.seek(0)
+        x = np.loadtxt(c, dtype=int, delimiter=',', \
+            converters={3:lambda s: int(s or -999)})
+        a = np.array([1,2,3,-999,5], int)
+        assert_array_equal(x, a)
+        
     
 if __name__ == "__main__":
     NumpyTest().run()



More information about the Numpy-svn mailing list