I have encountered the following function in a Matlab code set
X = flipdim(X,i);
The equivalent to
flipdim in MATLAB is
numpy. Be advised that this is only available in version 1.12.0.
Therefore, it's simply:
import numpy as np def flipall(X): for i in range(X.ndim): X = np.flip(X, i)
Be advised that this will mutate the
numpy array so there's no need to return anything. As such, you'd simply call it like so:
However, if you know a priori that you have only three dimensions, you can hard code the operation by simply doing:
def flipall(X): X = X[::-1,::-1,::-1]
This flips each dimension one right after the other.