modified definition for _normalize_axis_index
@@ -44,15 +44,11 @@ def _normalize_axis_index(axis, ndim):
The normalized axis index, such that `0 <= normalized_axis < ndim`
"""
- if ndim <= axis or (axis < -ndim and axis + ndim < 0):
- raise _errors._AxisError('axis '+str(axis)+' is out of bounds for ' +
- 'array of dimension '+str(ndim))
-
- elif (0 <= axis < ndim) or (-ndim <= axis < 0 and 0 <= axis + ndim < ndim):
if axis < 0:
- return (ndim - abs(axis)) % ndim
- else:
- return abs(axis) % ndim
+ axis += ndim
+ if not (0 <= axis < ndim):
+ raise _errors._AxisError('axis out of bounds')
+ return axis
def memoize(bint for_each_device=False):
