diff options
author | Ross Barnowski <rossbar@berkeley.edu> | 2022-01-11 12:05:00 -0800 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2022-01-14 20:07:07 -0600 |
commit | 3ca9f5a2a252e020a44a355f4fc8114d91ea3423 (patch) | |
tree | 460d6d61109ce2a54c5f3dfd6c8ac6404a566950 /numpy/lib/npyio.py | |
parent | 530c954316680f234b6926d0188843bca56de90d (diff) | |
download | numpy-3ca9f5a2a252e020a44a355f4fc8114d91ea3423.tar.gz |
Add warning on empty file + tests.
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 3b7b3bb30..6e660dce1 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1062,12 +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 arr.shape: + 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. |