I'm trying to count the number of True values in a numpy.array
until a False is reached.
For example, if you have
condition = np.array([True, True, True, False,
False, True, False, True, True, False, True])
Then the desired result would be
np.array([3, 2, 1, 0, 0, 1, 0, 2, 1, 0, 1])
Edit:
Numpy first occurrence of value greater than existing value is not what I'm asking because that's asking about the first time a condition is satisfied. I'm asking how many times in a row a condition is satisfied each time it is satisfied. Find first sequence item that matches a criterion also doesn't work because, again, I'm not asking about the first time a sequence satisfied a condition.