Say I have a list of lists of lists etc... of some depth:
ExampleNestedObject = numpy.ones(shape = (3,3,3,3,3))
In general I can get an element
The trick is to think of an index object as a tuple of slice objects.
Example1:
Object[1,2,:] == Object[(1,2,slice(None,None,None))]
Example2:
WantedSliceObject = (1,2,slice(None,None,None), 4,5)
Object[1,2,:,4,5] == Object[WantedSliceObject]
Note the syntax of '''slice:
#slice(start, stop[, step])
#1 == slice(1, 2, 1)
WantedSliceObject2 = (
slice(1, 2, 1),
slice(2, 2, 1),
slice(None,None,None),
slice(4, 2, 1),
slice(5, 2, 1)
)
#WantedSliceObject2 == WantedSliceObject