def _split_arrs ( array_2d , slices ) : if len ( array_2d ) == 0 : return np . empty ( 0 , dtype = np . object ) rtn = np . empty ( len ( slices ) + 1 , dtype = np . object ) start = 0 for i , s in enumerate ( slices ) : rtn [ i ] = array_2d [ start : s ] start = s rtn [ - 1 ] = array_2d [ start : ] return rtn
how to split an array in 2 by index python
Equivalent to numpy . split ( array_2d slices ) but avoids fancy indexing
def _split_arrs(array_2d, slices):
    """
    Equivalent to numpy.split(array_2d, slices),
    but avoids fancy indexing
    """
    if len(array_2d) == 0:
        return np.empty(0, dtype=np.object)

    rtn = np.empty(len(slices) + 1, dtype=np.object)
    start = 0
    for i, s in enumerate(slices):
        rtn[i] = array_2d[start:s]
        start = s
    rtn[-1] = array_2d[start:]
    return rtn