MCPcopy Create free account
hub / github.com/pydata/numexpr / NumExpr_run

Function NumExpr_run

numexpr3/interpreter.cpp:534–1258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

532}
533
534PyObject *
535NumExpr_run(NumExprObject *self, PyObject *args, PyObject *kwds)
536{
537 PyArrayObject *operands[NPY_MAXARGS];
538 PyArray_Descr *dtypes[NPY_MAXARGS];
539 PyObject *tmp, *returnArray;
540 PyObject *objectRef, *arrayRef;
541 npy_uint32 op_flags[NPY_MAXARGS];
542 NPY_CASTING casting = NPY_SAFE_CASTING;
543 NPY_ORDER order = NPY_KEEPORDER;
544 NE_WORD I, J;
545
546 NE_REGISTER arrayCounter = 0, n_input;
547 int allocOutput = 0;
548 int maxDims = 0; // The largest dimensionality in any of the passed arguments
549 npy_intp arrayOffset = 0;
550 npy_intp* broadcastShape = NULL; // An array tracking the broadcasted dimensions of the output
551 npy_intp* arrayShape = NULL;
552 NE_REGISTER retIndex, arg1Index, arg2Index;
553 PyArray_Descr* outputType; // The NumPy array dtype for the output array
554
555 int r, pc_error = 0;
556 int reduction_axis = -1;
557 npy_intp reduction_size = 1;
558 int is_reduction = 0;
559 bool reduction_outer_loop = false, need_output_buffering = false;
560
561 // NumPy iterators for strided arrays
562 NpyIter *iter = NULL, *reduce_iter = NULL;
563
564 // To specify axes when doing a reduction
565 int op_axes_values[NPY_MAXARGS][NPY_MAXDIMS],
566 op_axes_reduction_values[NPY_MAXARGS];
567 int *op_axes_ptrs[NPY_MAXDIMS];
568 int oa_ndim = 0;
569 int **op_axes = NULL;
570
571
572 BENCH_TIME(1);
573 n_input = (int)PyTuple_Size(args);
574
575 memset(operands, 0, sizeof(operands));
576 memset(dtypes, 0, sizeof(dtypes));
577 // Moving away from kwds
578 // if (kwds) {
579 // // Parse standard keyword arguments
580 // // User can't change casting here, it would change the program
581 // tmp = PyDict_GetItemString(kwds, "casting"); // borrowed ref
582 // if (tmp != NULL && !PyArray_CastingConverter(tmp, &casting)) {
583 // return PyErr_Format(PyExc_ValueError,
584 // "NumExpr_run(): casting keyword argument is invalid.");
585 // }
586 // Array ordering is not implemented Python-side
587 // tmp = PyDict_GetItemString(kwds, "order"); // borrowed ref
588 // if (tmp != NULL && !PyArray_OrderConverter(tmp, &order)) {
589 // return PyErr_Format(PyExc_ValueError,
590 // "NumExpr_run(): order keyword argument is invalid.");
591 // }

Callers

nothing calls this directly

Calls 5

NPYENUM_from_dcharFunction · 0.85
get_return_sigFunction · 0.85
run_interpreter_constFunction · 0.85
numexpr_set_nthreadsFunction · 0.85
run_interpreterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…