Relative Content

Tag Archive for pythonnumpynumpy-slicing

How to combine non-contiguous numpy slices

I have a numpy array with shape (M, N, N) – it’s effectively a bunch (M) of (N,N) covariance matrices. I want to be able to extract submatrices out of this with shape (M, P, P). But I’m trying to access non-contiguous indices. Here’s an example: