A = np.array([5,1,5,8])
B = np.array([2,5])
I want to compare the A array to each element of B. In other words I'm lookin for a function which do the following computations :
A>2
A>5
(array([ True, False, True, True]), array([False, False, False, True]))
[A > b for b in B]?A>B[:,None]B, it sort off "expands" the last dimension ofBto match the dimension ofA. I know it doesn't make a lot of sense, but it is posibly the most important feature of numpy. For more details see here