(arrays, fill=0., axis=0, raggedaxis=1)
return out
Stacks a list of arrays, like np.stack with axis=0.
    Arrays may have different length (along the raggedaxis), and will be padded on the right
    with the given fill value.
Stacks a list of arrays, like np.stack with axis=0.
    Arrays may have different length (along the raggedaxis), and will be padded on the right
    with the given fill value.
Stacks a list of arrays like np . stack with axis = 0 . Arrays may have different length ( along the raggedaxis ) and will be padded on the right with the given fill value .
def raggedstack(arrays, fill=0., axis=0, raggedaxis=1):
    '''
    Stacks a list of arrays, like np.stack with axis=0.
    Arrays may have different length (along the raggedaxis), and will be padded on the right
    with the given fill value.
    '''
    assert axis == 0 and raggedaxis == 1, 'not implemented'
    arrays = [a[None,...] for a in arrays]
    assert all(a.ndim >= 2 for a in arrays)

    outshape = list(arrays[0].shape)
    outshape[0] = sum(a.shape[0] for a in arrays)
    outshape[1] = max(a.shape[1] for a in arrays) # take max along ragged axes
    outshape = tuple(outshape)

    out = np.full(outshape, fill, dtype=arrays[0].dtype)
    pos = 0
    for a in arrays:
        out[pos:pos+a.shape[0], :a.shape[1], ...] = a
        pos += a.shape[0]
    assert pos == out.shape[0]
    return out
def raggedstack ( arrays , fill = 0. , axis = 0 , raggedaxis = 1 ) : assert axis == 0 and raggedaxis == 1 , 'not implemented' arrays = [ a [ None , ... ] for a in arrays ] assert all ( a . ndim >= 2 for a in arrays ) outshape = list ( arrays [ 0 ] . shape ) outshape [ 0 ] = sum ( a . shape [ 0 ] for a in arrays ) outshape [ 1 ] = max ( a . shape [ 1 ] for a in arrays ) # take max along ragged axes outshape = tuple ( outshape ) out = np . full ( outshape , fill , dtype = arrays [ 0 ] . dtype ) pos = 0 for a in arrays : out [ pos : pos + a . shape [ 0 ] , : a . shape [ 1 ] , ... ] = a pos += a . shape [ 0 ] assert pos == out . shape [ 0 ] return out