Let's say I have an array:
a = [0.42, 0.18, 1.54, 2.9, 1.81, 2.35, 0.18, 1.54, 2.92]
which has the following (element-wise) logical state:
[False, True, False, False, False, False, True, False, False]
Is there a nice way to use a list comprehension to only add the True elements to a new list? Additional question: True elements from a shall be popped out afterwards (as they are now already processed)
zip
both of them e,g[v for v, state in zip(a, logical_state) if state]
. If it's a numpy array you could doa[logical_states]