```python
assert axis < ndim, ("Axis must be less than ndim."
                     " axis: %r, ndim: %r" % (axis, ndim))
```