Given an index array idx that only contains 0 and 1 elements, and 1s represent the sample indices of interest, and a sample array A (A.shape[0] = idx.shape[0]). The objective here is to extract a subset of samples based on the index vector.
In matlab, it is trivial to do:
B = A(idx,:) %assuming A is 2D matrix and idx is a logical vector
How to achieve this in Python in a simple manner?

A[idx.astype(bool)]I suppose?