diff options
author | Ross Barnowski <rossbar@berkeley.edu> | 2022-01-11 10:45:28 -0800 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2022-01-14 20:07:07 -0600 |
commit | 530c954316680f234b6926d0188843bca56de90d (patch) | |
tree | 73fea05451529258701f0ba3baadf2bf51220977 /numpy/lib/npyio.py | |
parent | 10b04d65bfb403d38f6d5c0de40e26ba1849d10d (diff) | |
download | numpy-530c954316680f234b6926d0188843bca56de90d.tar.gz |
Add UserWarning when reading no data.
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index b5723dee5..3b7b3bb30 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1062,6 +1062,13 @@ def _read(fname, *, delimiter=',', comment='#', quote='"', arr = _ensure_ndmin_ndarray(arr, ndmin=ndmin) + if arr.shape[0] == 0: + warnings.warn( + f'loadtxt: input contained no data: "{fname}"', + category=UserWarning, + stacklevel=2 + ) + if unpack: # Handle unpack like np.loadtxt. # XXX Check interaction with ndmin! |