(counts)
return incr
Given a 1D array of positive integers, generate an array equal to
    np.concatenate([np.arange(c) for c in counts]), but in a faster and more
    memory-efficient way.
Given a 1D array of positive integers, generate an array equal to
    np.concatenate([np.arange(c) for c in counts]), but in a faster and more
    memory-efficient way.
Given a 1D array of positive integers generate an array equal to np . concatenate ( [ np . arange ( c ) for c in counts ] ) but in a faster and more memory - efficient way .
def _multirange(counts):
    """Given a 1D array of positive integers, generate an array equal to
    np.concatenate([np.arange(c) for c in counts]), but in a faster and more
    memory-efficient way."""
    cumsum = np.cumsum(counts)
    reset_index = cumsum[:-1]
    incr = np.ones(cumsum[-1], dtype=int)
    incr[0] = 0

    # For each index in reset_index, we insert the negative value necessary
    # to offset the cumsum in the last line
    incr[reset_index] = 1 - counts[:-1]
    incr.cumsum(out=incr)

    return incr
def _multirange ( counts ) : cumsum = np . cumsum ( counts ) reset_index = cumsum [ : - 1 ] incr = np . ones ( cumsum [ - 1 ] , dtype = int ) incr [ 0 ] = 0 # For each index in reset_index, we insert the negative value necessary # to offset the cumsum in the last line incr [ reset_index ] = 1 - counts [ : - 1 ] incr . cumsum ( out = incr ) return incr