diff options
author | Iryna Shcherbina <ishcherb@redhat.com> | 2017-08-24 18:01:43 +0200 |
---|---|---|
committer | Iryna Shcherbina <ishcherb@redhat.com> | 2017-08-24 18:19:42 +0200 |
commit | 6f9ea0abbd305d53f9017debab3a3a591fe0e249 (patch) | |
tree | fe5dfa411b6a2c9f20951d8842cbcaca1d36ec2e /numpy/lib/arraypad.py | |
parent | 707f33f6a55076bc12e25e736d910545377420e8 (diff) | |
download | numpy-6f9ea0abbd305d53f9017debab3a3a591fe0e249.tar.gz |
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 |