(other_ary, dtype, order)
return dtype, order, strides
Set order, strides, dtype as in numpy's zero_like.
Set order, strides, dtype as in numpy's zero_like.
Set order strides dtype as in numpy s zero_like .
def _array_like_helper(other_ary, dtype, order):
    """Set order, strides, dtype as in numpy's zero_like. """
    strides = None
    if order == "A":
        if other_ary.flags.f_contiguous and not other_ary.flags.c_contiguous:
            order = "F"
        else:
            order = "C"
    elif order == "K":
        if other_ary.flags.c_contiguous or (other_ary.ndim <= 1):
            order = "C"
        elif other_ary.flags.f_contiguous:
            order = "F"
        else:
            # array_like routines only return positive strides
            strides = [np.abs(s) for s in other_ary.strides]
            if dtype is not None and dtype != other_ary.dtype:
                # scale strides by itemsize when dtype is not the same
                itemsize = other_ary.nbytes // other_ary.size
                itemsize_ratio = np.dtype(dtype).itemsize / itemsize
                strides = [int(s * itemsize_ratio) for s in strides]
    elif order not in ["C", "F"]:
        raise ValueError("Unsupported order: %r" % order)
    if dtype is None:
        dtype = other_ary.dtype
    return dtype, order, strides
def _array_like_helper ( other_ary , dtype , order ) : strides = None if order == "A" : if other_ary . flags . f_contiguous and not other_ary . flags . c_contiguous : order = "F" else : order = "C" elif order == "K" : if other_ary . flags . c_contiguous or ( other_ary . ndim <= 1 ) : order = "C" elif other_ary . flags . f_contiguous : order = "F" else : # array_like routines only return positive strides strides = [ np . abs ( s ) for s in other_ary . strides ] if dtype is not None and dtype != other_ary . dtype : # scale strides by itemsize when dtype is not the same itemsize = other_ary . nbytes // other_ary . size itemsize_ratio = np . dtype ( dtype ) . itemsize / itemsize strides = [ int ( s * itemsize_ratio ) for s in strides ] elif order not in [ "C" , "F" ] : raise ValueError ( "Unsupported order: %r" % order ) if dtype is None : dtype = other_ary . dtype return dtype , order , strides