diff options
author | Derek Homeier <derek@astro.physik.uni-goettingen.de> | 2011-05-05 01:01:08 +0200 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@googlemail.com> | 2011-05-07 22:12:28 +0200 |
commit | 607d2b3bbe984892fbf345788a54eafebdf967ed (patch) | |
tree | 53db9b466618682614d20956157202c1ac540454 /numpy/lib/npyio.py | |
parent | 6df2ac2173331ed91e79e69bb5caea07c12f410d (diff) | |
download | numpy-607d2b3bbe984892fbf345788a54eafebdf967ed.tar.gz |
changed ndmin option in loadtxt to return shape (1, X.size) for single-row inputs
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index f8c24b1a0..4d5e96b93 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -626,7 +626,8 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, unpacked using ``x, y, z = loadtxt(...)``. When used with a record data-type, arrays are returned for each field. Default is False. ndmin : int, optional - The returned array must have at least `ndmin` dimensions. + The returned array will have at least `ndmin` dimensions. + Otherwise single-dimensional axes will be squeezed. Legal values: 0 (default), 1 or 2. .. versionadded:: 1.6.0 @@ -802,6 +803,8 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, fh.close() X = np.array(X, dtype) + if X.ndim == 3 and X.shape[:2] == (1, 1): + X.shape = (1, -1) # Verify that the array has at least dimensions `ndmin`. # Check correctness of the values of `ndmin` |