Skip to content
Snippets Groups Projects
Forked from agnumpde / dune-tectonic
135 commits ahead of the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
slip_endings.py 342 B
import array as ar


def slip_endings(x):
    # returns indicies i for which x[i-1]>0 and x[i]=0
    ends = ar.array('i', (0 for i in range(len(x))))
    prev = False

    length = 0
    for i in range(len(x)):
        if (prev and not x[i]):
            ends[length] = i
            length += 1
        prev = x[i]

    return ends[:length]