I think this if statement can be simplified a little:

```
if multidims:
    if np.prod(multidims) == 1:
        ...
    else:
        ...
```

to avoid checking ``multidims`` twice, which is not very elegant.