Nov-09-2020, 09:26 PM

Hello,

I have an array

I want to count the elements in the array and I can count the number of elements with this code

Is there any nicer way to do it?

Bests

I have an array

I want to count the elements in the array and I can count the number of elements with this code

a0 = sum(np.all((results-np.array([0,0,0]))==0, axis=1)) x1 = sum(np.all((results-np.array([0,0,1]))==0, axis=1)) x2 = sum(np.all((results-np.array([0,1,0]))==0, axis=1)) x3 = sum(np.all((results-np.array([0,1,1]))==0, axis=1)) x4 = sum(np.all((results-np.array([1,0,0]))==0, axis=1)) x5 = sum(np.all((results-np.array([1,0,1]))==0, axis=1)) x6 = sum(np.all((results-np.array([1,1,0]))==0, axis=1)) x7 = sum(np.all((results-np.array([1,1,1]))==0, axis=1))But I want to do it in a shorter way. I don't want to specify my all triplets. This time I have 8 different elements so I could write it by hand but if I have 100 different triplets, I couldn't use this code

Is there any nicer way to do it?

Bests