I have a Python numpy N-dimensional array with shape M x N x ... x T, but I do not know the number of dimensions (rank) of the array until runtime.
How can I create a view of a sub-array of that array, specified by two vectors with length rank: extent and offset?
import numpy as np
def select_subrange( orig_array, subrange_extent_vector, subrange_offset_vector ):
"""
returns a view of orig_array offset by the entries in subrange_offset_vector
and with extent specified by entries in subrange_extent_vector.
"""
# ???
return subarray
I'm stuck because the slicing examples I have found require [ start:end, ... ] entries for each array dimension.