Finding all 1-d arrays within a numpy array
Given a numpy array of dimension n with each direction having length m, I would like to iterate through all 1-dimensional arrays of length m.
Indexing numpy array of shape `(A, B, C)` with `[[a, b], [c, d], :]` (`0 <= a, b < A`, `0 <= c, d < B`) produces shape `(2, C)` instead of `(2, 2, C)`
Here’s the example:
Keeping a “pointer” to the of the “parent array” from which a “derived array” was produced?
(Aside: my question is equally applicable to numpy
structured arrays and non-structured arrays.)
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: