I have a NumPy array \'boolarr\' of boolean type. I want to count the number of elements whose values are True. Is there a NumPy or Python routine dedicated for
True
That question solved a quite similar question for me and I thought I should share :
In raw python you can use sum() to count True values in a list :
sum()
list
>>> sum([True,True,True,False,False]) 3
But this won't work :
>>> sum([[False, False, True], [True, False, True]]) TypeError...