diff options
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-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,)) |