algorithms/eventdetection.py
def _group_filter_values(seg, filter_indices, ms_per_input):
    """
    Takes a list of 1s and 0s and returns a list of tuples of the form:
    ['y/n', timestamp].
    """
    ret = []
    for filter_value, (_segment, timestamp) in zip(filter_indices, seg.generate_frames_as_segments(ms_per_input)):
        if filter_value == 1:
            if len(ret) > 0 and ret[-1][0] == 'n':
                ret.append(['y', timestamp])  # The last one was different, so we create a new one
            elif len(ret) > 0 and ret[-1][0] == 'y':
                ret[-1][1] = timestamp  # The last one was the same as this one, so just update the timestamp
            else:
                ret.append(['y', timestamp])  # This is the first one
        else:
            if len(ret) > 0 and ret[-1][0] == 'n':
                ret[-1][1] = timestamp
            elif len(ret) > 0 and ret[-1][0] == 'y':
                ret.append(['n', timestamp])
            else:
                ret.append(['n', timestamp])
    return ret
def _group_filter_values(seg, filter_indices, ms_per_input):
    """
    Takes a list of 1s and 0s and returns a list of tuples of the form:
    ['y/n', timestamp].
    """
    ret = []
    for filter_value, (_segment, timestamp) in zip(filter_indices, seg.generate_frames_as_segments(ms_per_input)):
        if filter_value == 1:
            if len(ret) > 0 and ret[-1][0] == 'n':
                ret.append(['y', timestamp])  # The last one was different, so we create a new one
            elif len(ret) > 0 and ret[-1][0] == 'y':
                ret[-1][1] = timestamp  # The last one was the same as this one, so just update the timestamp
            else:
                ret.append(['y', timestamp])  # This is the first one
        else:
            if len(ret) > 0 and ret[-1][0] == 'n':
                ret[-1][1] = timestamp
            elif len(ret) > 0 and ret[-1][0] == 'y':
                ret.append(['n', timestamp])
            else:
                ret.append(['n', timestamp])
    return ret
Takes a list of 1s and 0s and returns a list of tuples of the form:
    ['y/n', timestamp].