How to use the dynetx.utils.compact_timeslot function in dynetx

To help you get started, we’ve selected a few dynetx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GiulioRossetti / dynetx / dynetx / readwrite / edgelist.py View on Github external
def read_ids(path, delimiter=None, timestamptype=None):
    f = open(path)
    ids = {}
    for line in f:
        s = line.rstrip().split(delimiter)
        ids[timestamptype(s[-1])] = None
        if len(line) == 4:
            if s[-2] not in ['+', '-']:
                ids[timestamptype(s[-2])] = None

    f.flush()
    f.close()

    ids = compact_timeslot(ids.keys())
    return ids