I am trying to port a code from Matlab to Python, which involves slicing a 2D numpy array with another boolean array.
z = np.array([[1,2,3],[4,5,6],[7,8,9]])
f = np.array([True,True,False])
print(z[f,f])
Result is a 1D array [1,5]
In Matlab this would return the upper left 2x2 part of z, which is [[1,2],[4,5]].
How can I achieve a similar effect?