diff options
author | Derek Homeier <derek@astro.physik.uni-goettingen.de> | 2011-05-06 12:07:32 +0200 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@googlemail.com> | 2011-05-07 22:12:29 +0200 |
commit | b233716a031cb523f9bc65dda2c22f69f6f0736a (patch) | |
tree | 13b7a7fa4d38e75d4c36c5b51c465cdddba7f98a /numpy/lib/tests | |
parent | 607d2b3bbe984892fbf345788a54eafebdf967ed (diff) | |
download | numpy-b233716a031cb523f9bc65dda2c22f69f6f0736a.tar.gz |
use np.atleast_Nd() to boost dimensions to ndmin
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_io.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 97633d525..e83c82ecd 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -479,6 +479,10 @@ class TestLoadTxt(TestCase): c = StringIO() c.write(asbytes('1,2,3\n4,5,6')) c.seek(0) + assert_raises(ValueError, np.loadtxt, c, ndmin=3) + c.seek(0) + assert_raises(ValueError, np.loadtxt, c, ndmin=1.5) + c.seek(0) x = np.loadtxt(c, dtype=int, delimiter=',', ndmin=1) a = np.array([[1, 2, 3], [4, 5, 6]]) assert_array_equal(x, a) @@ -487,13 +491,23 @@ class TestLoadTxt(TestCase): d.seek(0) x = np.loadtxt(d, dtype=int, delimiter=',', ndmin=2) assert_(x.shape == (1, 3)) - assert_raises(ValueError, np.loadtxt, d, ndmin=3) - assert_raises(ValueError, np.loadtxt, d, ndmin=1.5) + d.seek(0) + x = np.loadtxt(d, dtype=int, delimiter=',', ndmin=1) + assert_(x.shape == (3,)) + d.seek(0) + x = np.loadtxt(d, dtype=int, delimiter=',', ndmin=0) + assert_(x.shape == (3,)) e = StringIO() e.write(asbytes('0\n1\n2')) e.seek(0) x = np.loadtxt(e, dtype=int, delimiter=',', ndmin=2) assert_(x.shape == (3, 1)) + e.seek(0) + x = np.loadtxt(e, dtype=int, delimiter=',', ndmin=1) + assert_(x.shape == (3,)) + e.seek(0) + x = np.loadtxt(e, dtype=int, delimiter=',', ndmin=0) + assert_(x.shape == (3,)) f = StringIO() assert_(np.loadtxt(f, ndmin=2).shape == (0, 1,)) assert_(np.loadtxt(f, ndmin=1).shape == (0,)) |