I'm working on a problem where I have a large system of particles and I want to choose the masses of those that meet two conditions: they have to be inside a circle with given radius and have to be of a given type (let's say, type 2).
I'm trying to do this through this line of code:
mass = {'mass' + str(i): mass[i,r_length[i,:]<=10 and p_type[i,:]==2] for i in range(0,number_of_snapshots)}
But what I got was the error
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().
I don't understand why, because both r_length and p_type are arrays with same shape, and my idea is that, when the conditions for both of them are true, then the overall condition is true and then that element is selected. There is some problem with the function "and" for arrays?