summaryrefslogtreecommitdiff
path: root/numpy/lib/shape_base.py
diff options
context:
space:
mode:
authorMarten van Kerkwijk <mhvk@astro.utoronto.ca>2017-02-18 11:03:37 -0500
committerGitHub <noreply@github.com>2017-02-18 11:03:37 -0500
commit86bf869ef831e0f2165a97c057c5661fc8b5dbf7 (patch)
tree5b4d68925ea49624efe0074d87bae1523813896a /numpy/lib/shape_base.py
parentd55f40b1e48d5a5fbed80e00a140c9db6e19732f (diff)
parent61640a849557c4460101875fd9657b3c8aaccb6d (diff)
downloadnumpy-86bf869ef831e0f2165a97c057c5661fc8b5dbf7.tar.gz
Merge pull request #8614 from eric-wieser/apply_along_axis-empty
BUG: Don't leak internal exceptions when given an empty array
Diffstat (limited to 'numpy/lib/shape_base.py')
-rw-r--r--numpy/lib/shape_base.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index da0b6a5b2..58e13533b 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -109,7 +109,10 @@ def apply_along_axis(func1d, axis, arr, *args, **kwargs):
inds = ndindex(inarr_view.shape[:-1])
# invoke the function on the first item
- ind0 = next(inds)
+ try:
+ ind0 = next(inds)
+ except StopIteration:
+ raise ValueError('Cannot apply_along_axis when any iteration dimensions are 0')
res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
# build a buffer for storing evaluations of func1d.