summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
diff options
context:
space:
mode:
authordhuard <dhuard@localhost>2008-04-09 00:57:23 +0000
committerdhuard <dhuard@localhost>2008-04-09 00:57:23 +0000
commit0b0a389d1dfb6d76e053988d87f6434c81dd5ba5 (patch)
tree4a775d3b6dc404a85eae2aa73b2b6659c89b8f20 /numpy/lib/tests/test_io.py
parent737f9a1a916ec6a341657faed5c849176ed8828f (diff)
downloadnumpy-0b0a389d1dfb6d76e053988d87f6434c81dd5ba5.tar.gz
Added test for handling missing data using loadtxt.
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r--numpy/lib/tests/test_io.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index c219f6fcd..d0187fb58 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -72,6 +72,24 @@ class Testloadtxt(NumpyTestCase):
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()