I have a numpy array of tuples and wish to filter them, but nothing seems to work
possible_points = np.random.normal((0,0),0.01,size=(100,2))
possible_points = possible_points[possible_points > (0,0) and possible_points < (1,1)]
This yields an error
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I suspect the problem is somehow related with the following. When I do, for example,
possible_points = [possible_points > (0,0)]
possible_points becomes something like
[array([[False, False],
[ True, False],
[ True, False],
[ True, True],
[ True, True],
[ True, True],
[ True, True],
[False, False],
[ True, False],
...
From my understanding, it should return True if possible_points > (0,0) and False otherwise, but it's evaluating each tuple's coordinate individually. There are even some points that become [True, False]. If I do
possible_points = possible_points[possible_points > (0,0)]
I stop having tuples, and have something like
array([3.36687201e-03, 7.97227921e-04, 3.44875252e-03, 8.79364101e-03,....])
And I suspect this is what yields the ValueErros.
Can anyone help me understand what I'm doing wrong and help me achieve my goal?