This might be naive, but I couldn’t find an answer else where:
Let A
be an Nd-array, where Nd is unknown exactly till runtime, e.g., only sure that Nd>=3
.
Is there a good way to slice it along, e.g., the n<=3
th dimension?
For comparison, in numpy, one can do:
>>> A = numpy.ones((3,3,3,3));
>>> A[1,:]
array([[[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]],
[[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]],
[[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]]])
This made things each for me, as the slice is shape-ready for broadcasting operations on A
afterwards.
Thanks.