From a528b98550f9e411342659069c5ac8fb7bca7bf3 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sun, 3 Apr 2011 17:45:51 -0600 Subject: ENH: Let genfromtxt accept generators as text sources. Add test for that case. --- numpy/lib/tests/test_io.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'numpy/lib/tests/test_io.py') diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 1ed333165..53068838a 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -488,7 +488,7 @@ class TestLoadTxt(TestCase): def test_generator_source(self): def count(): for i in range(10): - yield "%d" % i + yield asbytes("%d" % i) res = np.loadtxt(count()) assert_array_equal(res, np.arange(10)) @@ -1323,6 +1323,14 @@ M 33 21.99 os.close(f) os.unlink(name) + def test_gft_generator_source(self): + def count(): + for i in range(10): + yield asbytes("%d" % i) + + res = np.genfromtxt(count()) + assert_array_equal(res, np.arange(10)) + def test_gzip_load(): a = np.random.random((5, 5)) -- cgit v1.2.1