Suppose I have a numpy array A which can be of any dimensions len(A.shape) can be 1,2,3,..etc. and a corresponding array, crop which len(crop) = len(A.shape) and I want to extract the interior values of A using crop. Here is an example for 2D array.
A = np.random.rand(30).reshape([5,6])
crop = np.array([1,2])
Wanted output:
A[crop[0]:-crop[0], crop[1]:-crop[1])
Assuming value of crop will be reasonable with respect to size of A. How do I do this for any dimension of array A ?