diff options
author | Nathaniel J. Smith <njs@pobox.com> | 2017-08-24 16:24:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-24 16:24:33 -0700 |
commit | 01718a9feb7f949b091e4f95320c1a60116e77a5 (patch) | |
tree | 502d1bd7af28a8028f33284aff7cf5a4e476aa7c /numpy/lib/arraypad.py | |
parent | 52a7efe1f2d0be6adb75d09babe6f203906ecfcb (diff) | |
parent | 6f9ea0abbd305d53f9017debab3a3a591fe0e249 (diff) | |
download | numpy-01718a9feb7f949b091e4f95320c1a60116e77a5.tar.gz |
Merge pull request #9599 from irushchyshyn/pad-reflect-empty-array
BUG: fix infinite loop when creating np.pad on an empty array
Diffstat (limited to 'numpy/lib/arraypad.py')
-rw-r--r-- | numpy/lib/arraypad.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/numpy/lib/arraypad.py b/numpy/lib/arraypad.py index 2dad99c34..294a68950 100644 --- a/numpy/lib/arraypad.py +++ b/numpy/lib/arraypad.py @@ -1406,6 +1406,9 @@ def pad(array, pad_width, mode, **kwargs): newmat = _append_min(newmat, pad_after, chunk_after, axis) elif mode == 'reflect': + if narray.size == 0: + raise ValueError("There aren't any elements to reflect in `array`") + for axis, (pad_before, pad_after) in enumerate(pad_width): # Recursive padding along any axis where `pad_amt` is too large # for indexing tricks. We can only safely pad the original axis |