(arrays, axis=0, allocator=None)
return result
Join a sequence of arrays along a new axis.
    :arg arrays: A sequnce of :class:`GPUArray`.
    :arg axis: Index of the dimension of the new axis in the result array.
        Can be -1, for the new axis to be last dimension.
    :returns: :class:`GPUArray`
Join a sequence of arrays along a new axis.
    :arg arrays: A sequnce of :class:`GPUArray`.
    :arg axis: Index of the dimension of the new axis in the result array.
        Can be -1, for the new axis to be last dimension.
    :returns: :class:`GPUArray`
Join a sequence of arrays along a new axis . : arg arrays : A sequnce of : class : GPUArray . : arg axis : Index of the dimension of the new axis in the result array . Can be - 1 for the new axis to be last dimension . : returns : : class : GPUArray
def stack(arrays, axis=0, allocator=None):
    """
    Join a sequence of arrays along a new axis.
    :arg arrays: A sequnce of :class:`GPUArray`.
    :arg axis: Index of the dimension of the new axis in the result array.
        Can be -1, for the new axis to be last dimension.
    :returns: :class:`GPUArray`
    """
    # implementation is borrowed from pyopencl.array.stack()
    allocator = allocator or arrays[0].allocator

    if not arrays:
        raise ValueError("need at least one array to stack")

    input_shape = arrays[0].shape
    input_ndim = arrays[0].ndim
    axis = input_ndim if axis == -1 else axis

    if not all(ary.shape == input_shape for ary in arrays[1:]):
        raise ValueError("arrays must have the same shape")

    if not (0 <= axis <= input_ndim):
        raise ValueError("invalid axis")

    result_shape = input_shape[:axis] + (len(arrays),) + input_shape[axis:]
    result = empty(shape=result_shape,
            dtype=np.result_type(*(ary.dtype for ary in arrays)),
            allocator=allocator, order="C" if axis == 0 else "F")

    for i, ary in enumerate(arrays):

        idx = (slice(None),)*axis + (i,) + (slice(None),)*(input_ndim-axis)
        result[idx] = ary

    return result
def stack ( arrays , axis = 0 , allocator = None ) : # implementation is borrowed from pyopencl.array.stack() allocator = allocator or arrays [ 0 ] . allocator if not arrays : raise ValueError ( "need at least one array to stack" ) input_shape = arrays [ 0 ] . shape input_ndim = arrays [ 0 ] . ndim axis = input_ndim if axis == - 1 else axis if not all ( ary . shape == input_shape for ary in arrays [ 1 : ] ) : raise ValueError ( "arrays must have the same shape" ) if not ( 0 <= axis <= input_ndim ) : raise ValueError ( "invalid axis" ) result_shape = input_shape [ : axis ] + ( len ( arrays ) , ) + input_shape [ axis : ] result = empty ( shape = result_shape , dtype = np . result_type ( * ( ary . dtype for ary in arrays ) ) , allocator = allocator , order = "C" if axis == 0 else "F" ) for i , ary in enumerate ( arrays ) : idx = ( slice ( None ) , ) * axis + ( i , ) + ( slice ( None ) , ) * ( input_ndim - axis ) result [ idx ] = ary return result