예제 #1
0
        internal static ndarray CheckFromAny(Object src, dtype descr, int minDepth,
                                             int maxDepth, NPYARRAYFLAGS requires, Object context)
        {
            if ((requires & NPYARRAYFLAGS.NPY_NOTSWAPPED) != 0)
            {
                if (descr == null && src is ndarray &&
                    !((ndarray)src).Dtype.IsNativeByteOrder)
                {
                    descr = new dtype(((ndarray)src).Dtype);
                }
                else if (descr != null && !descr.IsNativeByteOrder)
                {
                    // Descr replace
                }
                if (descr != null)
                {
                    descr.ByteOrder = '=';
                }
            }

            ndarray arr = np.FromAny(src, descr, minDepth, maxDepth, requires, context);

            if (arr != null && (requires & NPYARRAYFLAGS.NPY_ELEMENTSTRIDES) != 0 &&
                arr.ElementStrides == 0)
            {
                arr = arr.NewCopy(NPY_ORDER.NPY_ANYORDER);
            }
            return(arr);
        }