diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-02-08 17:22:11 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-02-11 21:09:20 +0000 |
commit | 78084ee261eae43e3b6cb12abee7d7880c62bc0c (patch) | |
tree | 494d7e487c58dbdb4056b47a29a02b1a764667a8 /numpy/lib/shape_base.py | |
parent | ff9c363bb729a37f09c63937e45d5870501bfbad (diff) | |
download | numpy-78084ee261eae43e3b6cb12abee7d7880c62bc0c.tar.gz |
MAINT: Improve error-checking of axis argument
Copied from the implementation in core.shape_base.stack
Diffstat (limited to 'numpy/lib/shape_base.py')
-rw-r--r-- | numpy/lib/shape_base.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index 9c16982c4..da0b6a5b2 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -96,11 +96,10 @@ def apply_along_axis(func1d, axis, arr, *args, **kwargs): # handle negative axes arr = asanyarray(arr) nd = arr.ndim + if not (-nd <= axis < nd): + raise IndexError('axis {0} out of bounds [-{1}, {1})'.format(axis, nd)) if axis < 0: axis += nd - if axis >= nd: - raise ValueError("axis must be less than arr.ndim; axis=%d, rank=%d." - % (axis, nd)) # arr, with the iteration axis at the end in_dims = list(range(nd)) |