(ndarray, order)
return ary
Channel count has to be the first dimension of the C{ndarray}.
Channel count has to be the first dimension of the C{ndarray}.
Channel count has to be the first dimension of the C { ndarray } .
def make_multichannel_2d_array(ndarray, order):
    """Channel count has to be the first dimension of the C{ndarray}."""

    descr = ArrayDescriptor()

    if order.upper() == "C":
        h, w, num_channels = ndarray.shape
        stride = 0
    elif order.upper() == "F":
        num_channels, w, h = ndarray.shape
        stride = 2
    else:
        raise LogicError("order must be either F or C")

    descr.width = w
    descr.height = h
    descr.format = dtype_to_array_format(ndarray.dtype)
    descr.num_channels = num_channels

    ary = Array(descr)

    copy = Memcpy2D()
    copy.set_src_host(ndarray)
    copy.set_dst_array(ary)
    copy.width_in_bytes = copy.src_pitch = copy.dst_pitch = ndarray.strides[stride]
    copy.height = h
    copy(aligned=True)

    return ary
def make_multichannel_2d_array ( ndarray , order ) : descr = ArrayDescriptor ( ) if order . upper ( ) == "C" : h , w , num_channels = ndarray . shape stride = 0 elif order . upper ( ) == "F" : num_channels , w , h = ndarray . shape stride = 2 else : raise LogicError ( "order must be either F or C" ) descr . width = w descr . height = h descr . format = dtype_to_array_format ( ndarray . dtype ) descr . num_channels = num_channels ary = Array ( descr ) copy = Memcpy2D ( ) copy . set_src_host ( ndarray ) copy . set_dst_array ( ary ) copy . width_in_bytes = copy . src_pitch = copy . dst_pitch = ndarray . strides [ stride ] copy . height = h copy ( aligned = True ) return ary