Closed VikingScientist closed 3 years ago
I was looking around for a better indexing solution to extract unconnected submatrices. Matlab allows this syntax
controlpoints([1,end], [1,end], :)
instead of
controlpoints[0, 0, :] = vol1.controlpoints[0, 0]
controlpoints[0, 1, :] = vol1.controlpoints[0, -1]
controlpoints[1, 0, :] = vol1.controlpoints[-1, 0]
controlpoints[1, 1, :] = vol1.controlpoints[-1, -1]
but the closest I came was numpy.id, but I couldn't make that one pretty. It is especially annoying that it does not support the :
-operator on the last axis and you have to do something like
controlpoints(np.ix([0,-1], [0,-1], np.arange(controlpoints.shape[2]))
which I honestly don't feel contribute to the readability.
Solution provided by github user UnaiSan