I have a one-dimensional np.array which has the following pattern
array = [seq_1, seq_2, seq_3]seq_1andseq_3are all0seq_2contains at least a single1
and I want to split array into seq_1, seq_2 and seq_3.
For example,
array = [0,0,0,1,1,1,1,0,0,0]
seq_1, seq_2, seq_3 = [0,0,0], [1,1,1,1], [0,0,0]
array = [0,1,0,0,0,0,0,0,1,0]
seq_1, seq_2, seq_3 = [0], [1,0,0,0,0,0,0,1], [0]
array = [0,1,1,1,0,1,0,1,1,0]
seq_1, seq_2, seq_3 = [0], [1,1,1,0,1,0,1,1], [0]
Is there a way using only NumPy functions (meaning no for loop) to achieve this?