Right now we throw a whole bunch of subtly different error messages for this.
Something like
class AxisError(IndexError): pass
def resolve_axis(axis, ndim):
if not (-ndim <= axis < axis):
raise AxisError('axis {0} out of bounds [-{1}, {1})'.format(axis, nd))
if axis < 0:
axis += ndim
return axis
But this would preferably be done C-side, to ensure those cases also give the same message