internal static void SetField(ndarray dest, NpyArray_Descr descr, int offset, object src) { // For char arrays pad the input string. if (dest.Dtype.Type == NPY_TYPECHAR.NPY_CHARLTR && dest.ndim > 0 && src is String) { int ndimNew = (int)dest.Dim(dest.ndim - 1); int ndimOld = ((String)src).Length; if (ndimNew > ndimOld) { src = ((String)src).PadRight(ndimNew, ' '); } } ndarray srcArray; if (src is ndarray) { srcArray = (ndarray)src; } else if (false) { // TODO: Not handling scalars. See arrayobject.c:111 } else { dtype src_dtype = new dtype(descr); srcArray = np.FromAny(src, src_dtype, 0, dest.ndim, NPYARRAYFLAGS.NPY_CARRAY, null); } NpyCoreApi.Incref(descr); if (numpyAPI.NpyArray_SetField(dest.core, descr, offset, srcArray.core) < 0) { NpyCoreApi.CheckError(); } }
internal object Get(npy_intp index) { VoidPtr pos = NpyCoreApi.IterGoto1D(this, index); if (pos == null) { NpyCoreApi.CheckError(); } return(arr.GetItem(index)); }
internal void SingleAssign(npy_intp index, object value) { VoidPtr pos = NpyCoreApi.IterGoto1D(this, index); if (pos == null) { NpyCoreApi.CheckError(); } arr.SetItem(value, index); }
internal NpyIndexes Bind(ndarray arr) { NpyIndexes result = new NpyIndexes(); int n = NpyCoreApi.BindIndex(arr, this, result); if (n < 0) { NpyCoreApi.CheckError(); } else { result.num_indexes = n; } return(result); }
/// <summary> /// /// </summary> /// <param name="dest"></param> /// <param name="descr"></param> /// <param name="offset"></param> /// <param name="src"></param> internal static void SetField(ndarray dest, NpyArray_Descr descr, int offset, object src) { ndarray srcArray; if (src is ndarray) { srcArray = (ndarray)src; } else if (false) { // TODO: Not handling scalars. See arrayobject.c:111 } else { dtype src_dtype = new dtype(descr); srcArray = np.FromAny(src, src_dtype, 0, dest.ndim, NPYARRAYFLAGS.NPY_CARRAY, null); } NpyCoreApi.Incref(descr); if (numpyAPI.NpyArray_SetField(dest.core, descr, offset, srcArray.core) < 0) { NpyCoreApi.CheckError(); } }