public static bool InitializeNumpyLibrary() { if (_isNumpyLibraryInitialized == true) { return(true); } NpyArray_FunctionDefs functionDefs = null; NpyInterface_WrapperFuncs wrapperFuncs = new NpyInterface_WrapperFuncs() { array_new_wrapper = numpy_interface_array_new_wrapper, iter_new_wrapper = numpy_interface_iter_new_wrapper, multi_iter_new_wrapper = numpy_interface_multi_iter_new_wrapper, neighbor_iter_new_wrapper = numpy_interface_neighbor_iter_new_wrapper, descr_new_from_type = numpy_interface_descr_new_from_type, descr_new_from_wrapper = numpy_interface_descr_new_from_wrapper, ufunc_new_wrapper = numpy_interface_ufunc_new_wrapper, }; npy_tp_error_set error_set = ErrorSet_handler; npy_tp_error_occurred error_occurred = ErrorOccurred_handler; npy_tp_error_clear error_clear = ErrorClear_handler; npy_tp_cmp_priority cmp_priority = numpy_tp_cmp_priority; npy_interface_incref incref = numpy_interface_incref; npy_interface_decref decref = numpy_interface_decref; enable_threads et = enable_threads; disable_threads dt = disable_threads; numpyAPI.npy_initlib(functionDefs, wrapperFuncs, error_set, error_occurred, error_clear, cmp_priority, incref, decref, et, dt); _isNumpyLibraryInitialized = true; return(true); }
public static void CommonInit() { NpyArray_FunctionDefs functionDefs = null; NpyInterface_WrapperFuncs wrapperFuncs = new NpyInterface_WrapperFuncs() { array_new_wrapper = numpy_interface_array_new_wrapper, iter_new_wrapper = numpy_interface_iter_new_wrapper, multi_iter_new_wrapper = numpy_interface_multi_iter_new_wrapper, neighbor_iter_new_wrapper = numpy_interface_neighbor_iter_new_wrapper, descr_new_from_type = numpy_interface_descr_new_from_type, descr_new_from_wrapper = numpy_interface_descr_new_from_wrapper, }; npy_tp_error_set error_set = ErrorSet_handler; npy_tp_error_occurred error_occurred = ErrorOccurred_handler; npy_tp_error_clear error_clear = ErrorClear_handler; npy_tp_cmp_priority cmp_priority = numpy_tp_cmp_priority; npy_interface_incref incref = numpy_interface_incref; npy_interface_decref decref = numpy_interface_decref; enable_threads et = enable_threads; disable_threads dt = disable_threads; numpyAPI.npy_initlib(functionDefs, wrapperFuncs, error_set, error_occurred, error_clear, cmp_priority, incref, decref, et, dt); }
internal static void npy_initlib(NpyArray_FunctionDefs functionDefs, NpyInterface_WrapperFuncs wrapperFuncs, npy_tp_error_set error_set, npy_tp_error_occurred error_occurred, npy_tp_error_clear error_clear, npy_tp_cmp_priority cmp_priority, npy_interface_incref incref, npy_interface_decref decref, enable_threads et, disable_threads dt) { Npy_RefCntLock = new object(); _NpyArrayWrapperFuncs = wrapperFuncs; npy_enable_threads = et; npy_disable_threads = dt; // Verify that the structure definition is correct and has the memory layout // that we expect. Debug.Assert(null == functionDefs || npy_defs.NPY_VALID_MAGIC == functionDefs.sentinel); if (null != wrapperFuncs) { // Store the passed in set of wrapper funcs. However, the CPython interface has the ufunc // code in a separate module which may have initialized the ufunc method prior to this so // we don't want to overwrite it. // npy_interface_ufunc_new_wrapper x = _NpyArrayWrapperFuncs.ufunc_new_wrapper; // memmove(&_NpyArrayWrapperFuncs, wrapperFuncs, sizeof(struct NpyInterface_WrapperFuncs)); //if (null == wrapperFuncs.ufunc_new_wrapper) { // _NpyArrayWrapperFuncs.ufunc_new_wrapper = x; } //NpyArrayIter_Type.ntp_interface_alloc = (npy_wrapper_construct)wrapperFuncs.iter_new_wrapper; //NpyArrayMultiIter_Type.ntp_interface_alloc = (npy_wrapper_construct)wrapperFuncs.multi_iter_new_wrapper; //NpyArrayNeighborhoodIter_Type = wrapperFuncs.neighbor_iter_new_wrapper; NpyErr_SetString_callback = error_set; NpyErr_Occurred_callback = error_occurred; NpyErr_Clear_callback = error_clear; Npy_CmpPriority = cmp_priority; //_NpyInterface_Incref = incref; //_NpyInterface_Decref = decref; /* Must be last because it uses some of the above functions. */ if (null != functionDefs) { _init_type_functions(functionDefs); } _init_builtin_descr_wrappers(); }
/* Initializes the library at startup. This functions must be called exactly once by the interface layer.*/ internal static void npy_initlib(NpyArray_FunctionDefs functionDefs, NpyInterface_WrapperFuncs wrapperFuncs, npy_tp_error_set error_set, npy_tp_error_occurred error_occurred, npy_tp_error_clear error_clear, npy_tp_cmp_priority cmp_priority, npy_interface_incref incref, npy_interface_decref decref, enable_threads et, disable_threads dt) { numpyinternal.npy_initlib(functionDefs, wrapperFuncs, error_set, error_occurred, error_clear, cmp_priority, incref, decref, et, dt); numpyinternal._intialize_builtin_descrs(); }