Generated by Cython 0.29.23
Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.
Raw output: mvtools.c
+01: import cython
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
02:
03:
04: @cython.boundscheck(False) # Deactivate bounds checking
05: @cython.wraparound(False) # Deactivate negative indexing.
+06: cpdef int copy(double [:] source,int src_offset,
static PyObject *__pyx_pw_7develia_7cytools_7mvtools_1copy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_7develia_7cytools_7mvtools_copy(__Pyx_memviewslice __pyx_v_source, int __pyx_v_src_offset, __Pyx_memviewslice __pyx_v_destination, int __pyx_v_dst_offset, int __pyx_v_count, CYTHON_UNUSED int __pyx_skip_dispatch) {
int __pyx_v_i;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("copy", 0);
/* … */
/* function exit code */
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_7develia_7cytools_7mvtools_1copy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7develia_7cytools_7mvtools_1copy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_source = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_v_src_offset;
__Pyx_memviewslice __pyx_v_destination = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_v_dst_offset;
int __pyx_v_count;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("copy (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,&__pyx_n_s_src_offset,&__pyx_n_s_destination,&__pyx_n_s_dst_offset,&__pyx_n_s_count,0};
PyObject* values[5] = {0,0,0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_source)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_src_offset)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("copy", 1, 5, 5, 1); __PYX_ERR(0, 6, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_destination)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("copy", 1, 5, 5, 2); __PYX_ERR(0, 6, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dst_offset)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("copy", 1, 5, 5, 3); __PYX_ERR(0, 6, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 4:
if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_count)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("copy", 1, 5, 5, 4); __PYX_ERR(0, 6, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "copy") < 0)) __PYX_ERR(0, 6, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
}
__pyx_v_source = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_source.memview)) __PYX_ERR(0, 6, __pyx_L3_error)
__pyx_v_src_offset = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_src_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 6, __pyx_L3_error)
__pyx_v_destination = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_destination.memview)) __PYX_ERR(0, 7, __pyx_L3_error)
__pyx_v_dst_offset = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_dst_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 7, __pyx_L3_error)
__pyx_v_count = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_count == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 8, __pyx_L3_error)
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("copy", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 6, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("cytools.mvtools.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_7develia_7cytools_7mvtools_copy(__pyx_self, __pyx_v_source, __pyx_v_src_offset, __pyx_v_destination, __pyx_v_dst_offset, __pyx_v_count);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_7develia_7cytools_7mvtools_copy(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_source, int __pyx_v_src_offset, __Pyx_memviewslice __pyx_v_destination, int __pyx_v_dst_offset, int __pyx_v_count) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("copy", 0);
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_v_source.memview)) { __Pyx_RaiseUnboundLocalError("source"); __PYX_ERR(0, 6, __pyx_L1_error) }
if (unlikely(!__pyx_v_destination.memview)) { __Pyx_RaiseUnboundLocalError("destination"); __PYX_ERR(0, 6, __pyx_L1_error) }
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_7develia_7cytools_7mvtools_copy(__pyx_v_source, __pyx_v_src_offset, __pyx_v_destination, __pyx_v_dst_offset, __pyx_v_count, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("cytools.mvtools.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_source, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_destination, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
07: double [:] destination,int dst_offset,
08: int count):
09:
+10: cdef int i = 0
__pyx_v_i = 0;
+11: for i in range(count):
__pyx_t_1 = __pyx_v_count;
__pyx_t_2 = __pyx_t_1;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
+12: destination[i+dst_offset] = source[i+src_offset]
__pyx_t_4 = (__pyx_v_i + __pyx_v_src_offset);
__pyx_t_5 = (__pyx_v_i + __pyx_v_dst_offset);
*((double *) ( /* dim=0 */ (__pyx_v_destination.data + __pyx_t_5 * __pyx_v_destination.strides[0]) )) = (*((double *) ( /* dim=0 */ (__pyx_v_source.data + __pyx_t_4 * __pyx_v_source.strides[0]) )));
}
13:
+14: return i
__pyx_r = __pyx_v_i; goto __pyx_L0;
15:
16: @cython.boundscheck(False) # Deactivate bounds checking
17: @cython.wraparound(False) # Deactivate negative indexing.
+18: cpdef int apply(double [:] target, fn):
static PyObject *__pyx_pw_7develia_7cytools_7mvtools_3apply(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_7develia_7cytools_7mvtools_apply(__Pyx_memviewslice __pyx_v_target, PyObject *__pyx_v_fn, CYTHON_UNUSED int __pyx_skip_dispatch) {
int __pyx_v_i;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("apply", 0);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_WriteUnraisable("cytools.mvtools.apply", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
__pyx_r = 0;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_7develia_7cytools_7mvtools_3apply(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7develia_7cytools_7mvtools_3apply(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_target = { 0, 0, { 0 }, { 0 }, { 0 } };
PyObject *__pyx_v_fn = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("apply (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_target,&__pyx_n_s_fn,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fn)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("apply", 1, 2, 2, 1); __PYX_ERR(0, 18, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "apply") < 0)) __PYX_ERR(0, 18, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_target = __Pyx_PyObject_to_MemoryviewSlice_ds_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_target.memview)) __PYX_ERR(0, 18, __pyx_L3_error)
__pyx_v_fn = values[1];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("apply", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 18, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("cytools.mvtools.apply", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_7develia_7cytools_7mvtools_2apply(__pyx_self, __pyx_v_target, __pyx_v_fn);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_7develia_7cytools_7mvtools_2apply(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_target, PyObject *__pyx_v_fn) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("apply", 0);
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_v_target.memview)) { __Pyx_RaiseUnboundLocalError("target"); __PYX_ERR(0, 18, __pyx_L1_error) }
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_7develia_7cytools_7mvtools_apply(__pyx_v_target, __pyx_v_fn, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("cytools.mvtools.apply", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_target, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
19:
+20: cdef int i = 0
__pyx_v_i = 0;
+21: for i in range(target.shape[0]):
__pyx_t_1 = (__pyx_v_target.shape[0]);
__pyx_t_2 = __pyx_t_1;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
+22: target[i] = fn(target[i])
__pyx_t_5 = __pyx_v_i;
__pyx_t_6 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ (__pyx_v_target.data + __pyx_t_5 * __pyx_v_target.strides[0]) )))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_INCREF(__pyx_v_fn);
__pyx_t_7 = __pyx_v_fn; __pyx_t_8 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
__pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
if (likely(__pyx_t_8)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
__Pyx_INCREF(__pyx_t_8);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_7, function);
}
}
__pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 22, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 22, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_5 = __pyx_v_i;
*((double *) ( /* dim=0 */ (__pyx_v_target.data + __pyx_t_5 * __pyx_v_target.strides[0]) )) = __pyx_t_9;
}
23:
+24: return i
__pyx_r = __pyx_v_i; goto __pyx_L0;