def _fillInOnTimes(vector, durations):
<EOL>nonzeros = numpy.array(vector).nonzero()[<NUM_LIT:0>]<EOL>if len(nonzeros) == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>if len(nonzeros) == <NUM_LIT:1>:<EOL><INDENT>durations[nonzeros[<NUM_LIT:0>]] = <NUM_LIT:1><EOL>return<EOL><DEDENT>prev = nonzeros[<NUM_LIT:0>]<EOL>onTime = <NUM_LIT:1><EOL>onStartIdx = prev<EOL>endIdx = nonzeros[-<NUM_LIT:1>]<EOL>for idx in nonzeros[<NUM_LIT:1>:]:<EOL><INDENT>if idx != prev+<NUM_LIT:1>:<EOL><INDENT>durations[onStartIdx:onStartIdx+onTime] = list(range(<NUM_LIT:1>,onTime+<NUM_LIT:1>))<EOL>onTime       = <NUM_LIT:1><EOL>onStartIdx = idx<EOL><DEDENT>else:<EOL><INDENT>onTime += <NUM_LIT:1><EOL><DEDENT>prev = idx<EOL><DEDENT>durations[onStartIdx:onStartIdx+onTime] = list(range(<NUM_LIT:1>,onTime+<NUM_LIT:1>))<EOL>
Helper function used by averageOnTimePerTimestep. 'durations' is a vector
which must be the same len as vector. For each "on" in vector, it fills in
the corresponding element of duration with the duration of that "on" signal
up until that time

Parameters:
-----------------------------------------------
vector:     vector of output values over time
durations:  vector same length as 'vector', initialized to 0's.
            This is filled in with the durations of each 'on" signal.

Example:
vector:     11100000001100000000011111100000
durations:  12300000001200000000012345600000