I think this routine should just do
```
if i.ndim > 1:
    raise IndexError('invalid index shape')
return i.nonzero()[0]
```
Numpy actually does not do the ndim check --- if the number of dimensions in some boolean index array matches the number of dimensions of the array itself, numpy simply ignores the other indexes. It's perhaps better to deviate from this behavior and raise an indexerror instead here.