def counts2slices(counts):
    """Convert a list of counts to cummulative slices.
    Example: [5, 1, 3] ==> [slice(0, 5), slice(5, 6), slice(6, 9)]
    """
    cumu = [sum(counts[:i]) for i in range(len(counts)+1)]
    slices = [slice(cumu[i-1], cumu[i]) for i in range(1, len(cumu))]
    return slices