def pickIndex(counts):
    total = sum(counts)
    dice = random.randint(1, total)
    countsSoFar = 0

    for (ind, count) in enumerate(counts):
        countsSoFar += count
        if countsSoFar >= dice:
            ret = ind
            break
    return ret
dataset/ETHPy150Open hgascon/pulsar/pulsar/core/lens.py/pickIndex/original