Generated by Cython 0.29.7
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: _exch_test.c
+001: from libc.math cimport sqrt
__Pyx_TraceLine(1,0,__PYX_ERR(0, 1, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
002: from libc.stdlib cimport rand, RAND_MAX
003:
+004: import numpy as np
__Pyx_TraceLine(4,0,__PYX_ERR(0, 4, __pyx_L1_error)) __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
005:
+006: from copulae.core import pseudo_obs
__Pyx_TraceLine(6,0,__PYX_ERR(0, 6, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_pseudo_obs); __Pyx_GIVEREF(__pyx_n_s_pseudo_obs); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_pseudo_obs); __pyx_t_2 = __Pyx_Import(__pyx_n_s_copulae_core, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_pseudo_obs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pseudo_obs, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
007:
008:
+009: cdef double cn(double[:] u, double[:] v, double x, double y, int n) nogil:
static double __pyx_f_7copulae_3gof_10_exch_test_cn(__Pyx_memviewslice __pyx_v_u, __Pyx_memviewslice __pyx_v_v, double __pyx_v_x, double __pyx_v_y, int __pyx_v_n) { double __pyx_v_res; int __pyx_v_i; double __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("cn", __pyx_f[0], 9, 1, __PYX_ERR(0, 9, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("copulae.gof._exch_test.cn", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1); __pyx_r = 0; __pyx_L0:; __Pyx_TraceReturn(Py_None, 1); return __pyx_r; } /* … */ __Pyx_TraceLine(9,0,__PYX_ERR(0, 9, __pyx_L1_error))
010: """
011: Utility function for the exchangeability test based on Cn
012:
013: Parameters
014: ----------
015: u: ndarray
016: a vector
017:
018: v: ndarray
019: a vector
020:
021: x: float
022: a double
023:
024: y: float
025: a double
026:
027: n: int
028: Number of multiplier or bootstrap iterations to be used to simulate realizations of the test statistic under
029: the null hypothesis.
030: """
031: cdef:
+032: double res = 0.0
__Pyx_TraceLine(32,1,__PYX_ERR(0, 32, __pyx_L1_error)) __pyx_v_res = 0.0;
033: int i
034:
+035: for i in range(n):
__Pyx_TraceLine(35,1,__PYX_ERR(0, 35, __pyx_L1_error)) __pyx_t_1 = __pyx_v_n; __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;
+036: res += (u[i] <= x) * (v[i] <= y)
__Pyx_TraceLine(36,1,__PYX_ERR(0, 36, __pyx_L1_error)) __pyx_t_4 = __pyx_v_i; __pyx_t_5 = __pyx_v_i; __pyx_v_res = (__pyx_v_res + (((*((double *) ( /* dim=0 */ (__pyx_v_u.data + __pyx_t_4 * __pyx_v_u.strides[0]) ))) <= __pyx_v_x) * ((*((double *) ( /* dim=0 */ (__pyx_v_v.data + __pyx_t_5 * __pyx_v_v.strides[0]) ))) <= __pyx_v_y))); }
+037: return res / n
__Pyx_TraceLine(37,1,__PYX_ERR(0, 37, __pyx_L1_error)) __pyx_r = (__pyx_v_res / ((double)__pyx_v_n)); goto __pyx_L0;
038:
039:
+040: cdef double der_cn_1(double[:] u, double[:] v, double x, double y, int n) nogil:
static double __pyx_f_7copulae_3gof_10_exch_test_der_cn_1(__Pyx_memviewslice __pyx_v_u, __Pyx_memviewslice __pyx_v_v, double __pyx_v_x, double __pyx_v_y, int __pyx_v_n) { double __pyx_v_inv_sqrt_n; double __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("der_cn_1", __pyx_f[0], 40, 1, __PYX_ERR(0, 40, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("copulae.gof._exch_test.der_cn_1", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1); __pyx_r = 0; __pyx_L0:; __Pyx_TraceReturn(Py_None, 1); return __pyx_r; } /* … */ __Pyx_TraceLine(40,0,__PYX_ERR(0, 40, __pyx_L1_error))
041: """
042: Utility function for the exchangeability test based on Cn
043:
044: Parameters
045: ----------
046: u: ndarray
047: first vector for the exchangeability test
048:
049: v: ndarray
050: second vector for the exchangeability test
051:
052: n: int
053: Number of multiplier or bootstrap iterations to be used to simulate realizations of the test statistic under
054: the null hypothesis.
055:
056: x: float
057: exchangeability bounds
058:
059: y: float
060: exchangeability bounds
061:
062: Returns
063: -------
064: float
065: """
066: cdef:
+067: double inv_sqrt_n = 1 / sqrt(n)
__Pyx_TraceLine(67,1,__PYX_ERR(0, 67, __pyx_L1_error)) __pyx_v_inv_sqrt_n = (1.0 / sqrt(__pyx_v_n));
+068: if x < inv_sqrt_n:
__Pyx_TraceLine(68,1,__PYX_ERR(0, 68, __pyx_L1_error)) __pyx_t_1 = ((__pyx_v_x < __pyx_v_inv_sqrt_n) != 0); if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+069: x = inv_sqrt_n
__Pyx_TraceLine(69,1,__PYX_ERR(0, 69, __pyx_L1_error)) __pyx_v_x = __pyx_v_inv_sqrt_n;
+070: elif x > 1 - inv_sqrt_n:
__Pyx_TraceLine(70,1,__PYX_ERR(0, 70, __pyx_L1_error)) __pyx_t_1 = ((__pyx_v_x > (1.0 - __pyx_v_inv_sqrt_n)) != 0); if (__pyx_t_1) { /* … */ } __pyx_L3:;
+071: x = 1 - inv_sqrt_n
__Pyx_TraceLine(71,1,__PYX_ERR(0, 71, __pyx_L1_error)) __pyx_v_x = (1.0 - __pyx_v_inv_sqrt_n);
072:
+073: return (cn(u, v, x + inv_sqrt_n, y, n) - cn(u, v, x - inv_sqrt_n, y, n)) / (2 * inv_sqrt_n)
__Pyx_TraceLine(73,1,__PYX_ERR(0, 73, __pyx_L1_error)) __pyx_r = ((__pyx_f_7copulae_3gof_10_exch_test_cn(__pyx_v_u, __pyx_v_v, (__pyx_v_x + __pyx_v_inv_sqrt_n), __pyx_v_y, __pyx_v_n) - __pyx_f_7copulae_3gof_10_exch_test_cn(__pyx_v_u, __pyx_v_v, (__pyx_v_x - __pyx_v_inv_sqrt_n), __pyx_v_y, __pyx_v_n)) / (2.0 * __pyx_v_inv_sqrt_n)); goto __pyx_L0;
074:
075:
+076: cdef double der_cn_2(double[:] u, double[:] v, double x, double y, int n) nogil:
static double __pyx_f_7copulae_3gof_10_exch_test_der_cn_2(__Pyx_memviewslice __pyx_v_u, __Pyx_memviewslice __pyx_v_v, double __pyx_v_x, double __pyx_v_y, int __pyx_v_n) { double __pyx_v_inv_sqrt_n; double __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("der_cn_2", __pyx_f[0], 76, 1, __PYX_ERR(0, 76, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("copulae.gof._exch_test.der_cn_2", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1); __pyx_r = 0; __pyx_L0:; __Pyx_TraceReturn(Py_None, 1); return __pyx_r; } /* … */ __Pyx_TraceLine(76,0,__PYX_ERR(0, 76, __pyx_L1_error))
077: """
078: Utility function for the exchangeability test based on Cn
079:
080: Parameters
081: ----------
082: u: ndarray
083: first vector for the exchangeability test
084:
085: v: ndarray
086: second vector for the exchangeability test
087:
088: n: int
089: Number of multiplier or bootstrap iterations to be used to simulate realizations of the test statistic under
090: the null hypothesis.
091:
092: x: float
093: exchangeability bounds
094:
095: y: float
096: exchangeability bounds
097:
098: Returns
099: -------
100: float
101: """
+102: inv_sqrt_n = 1.0 / sqrt(n)
__Pyx_TraceLine(102,1,__PYX_ERR(0, 102, __pyx_L1_error)) __pyx_v_inv_sqrt_n = (1.0 / sqrt(__pyx_v_n));
103:
+104: if y < inv_sqrt_n:
__Pyx_TraceLine(104,1,__PYX_ERR(0, 104, __pyx_L1_error)) __pyx_t_1 = ((__pyx_v_y < __pyx_v_inv_sqrt_n) != 0); if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+105: y = inv_sqrt_n
__Pyx_TraceLine(105,1,__PYX_ERR(0, 105, __pyx_L1_error)) __pyx_v_y = __pyx_v_inv_sqrt_n;
+106: elif y > 1 - inv_sqrt_n:
__Pyx_TraceLine(106,1,__PYX_ERR(0, 106, __pyx_L1_error)) __pyx_t_1 = ((__pyx_v_y > (1.0 - __pyx_v_inv_sqrt_n)) != 0); if (__pyx_t_1) { /* … */ } __pyx_L3:;
+107: y = 1 - inv_sqrt_n
__Pyx_TraceLine(107,1,__PYX_ERR(0, 107, __pyx_L1_error)) __pyx_v_y = (1.0 - __pyx_v_inv_sqrt_n);
108:
+109: return (cn(u, v, x, y + inv_sqrt_n, n) - cn(u, v, x, y - inv_sqrt_n, n)) / (2 * inv_sqrt_n)
__Pyx_TraceLine(109,1,__PYX_ERR(0, 109, __pyx_L1_error)) __pyx_r = ((__pyx_f_7copulae_3gof_10_exch_test_cn(__pyx_v_u, __pyx_v_v, __pyx_v_x, (__pyx_v_y + __pyx_v_inv_sqrt_n), __pyx_v_n) - __pyx_f_7copulae_3gof_10_exch_test_cn(__pyx_v_u, __pyx_v_v, __pyx_v_x, (__pyx_v_y - __pyx_v_inv_sqrt_n), __pyx_v_n)) / (2.0 * __pyx_v_inv_sqrt_n)); goto __pyx_L0;
110:
111:
+112: def exch_test_cn(double[:, :] u, double[:, :] g, int n, int m, int N, int random_state=8888):
/* Python wrapper */ static PyObject *__pyx_pw_7copulae_3gof_10_exch_test_1exch_test_cn(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_7copulae_3gof_10_exch_test_exch_test_cn[] = "\n Exchangeability test based on the empirical copula\n\n Parameters\n ----------\n u: ndarray\n Data to test for exchangeability\n\n g: ndarray\n Integrand grid\n\n n: int\n Number of multiplier or bootstrap iterations to be used to simulate realizations of the test statistic under\n the null hypothesis.\n\n m: int\n size of the integration grid\n\n N: int\n Number of multiplier or bootstrap iterations to be used to simulate realizations of the test statistic under\n the null hypothesis.\n\n random_state: int\n Random state used to standardize calculated p-value\n "; static PyMethodDef __pyx_mdef_7copulae_3gof_10_exch_test_1exch_test_cn = {"exch_test_cn", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7copulae_3gof_10_exch_test_1exch_test_cn, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7copulae_3gof_10_exch_test_exch_test_cn}; static PyObject *__pyx_pw_7copulae_3gof_10_exch_test_1exch_test_cn(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { __Pyx_memviewslice __pyx_v_u = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_g = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_n; int __pyx_v_m; int __pyx_v_N; int __pyx_v_random_state; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("exch_test_cn (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_u,&__pyx_n_s_g,&__pyx_n_s_n,&__pyx_n_s_m,&__pyx_n_s_N,&__pyx_n_s_random_state,0}; PyObject* values[6] = {0,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 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; 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_u)) != 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_g)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_test_cn", 0, 5, 6, 1); __PYX_ERR(0, 112, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_test_cn", 0, 5, 6, 2); __PYX_ERR(0, 112, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_test_cn", 0, 5, 6, 3); __PYX_ERR(0, 112, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_N)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_test_cn", 0, 5, 6, 4); __PYX_ERR(0, 112, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_random_state); if (value) { values[5] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "exch_test_cn") < 0)) __PYX_ERR(0, 112, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_u = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_u.memview)) __PYX_ERR(0, 112, __pyx_L3_error) __pyx_v_g = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_g.memview)) __PYX_ERR(0, 112, __pyx_L3_error) __pyx_v_n = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L3_error) __pyx_v_m = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_m == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L3_error) __pyx_v_N = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L3_error) if (values[5]) { __pyx_v_random_state = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_random_state == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L3_error) } else { __pyx_v_random_state = ((int)0x22B8); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("exch_test_cn", 0, 5, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 112, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("copulae.gof._exch_test.exch_test_cn", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7copulae_3gof_10_exch_test_exch_test_cn(__pyx_self, __pyx_v_u, __pyx_v_g, __pyx_v_n, __pyx_v_m, __pyx_v_N, __pyx_v_random_state); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7copulae_3gof_10_exch_test_exch_test_cn(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_u, __Pyx_memviewslice __pyx_v_g, int __pyx_v_n, int __pyx_v_m, int __pyx_v_N, int __pyx_v_random_state) { __Pyx_memviewslice __pyx_v_influ = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_s0 = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_random = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_i; int __pyx_v_j; int __pyx_v_k; double __pyx_v_x; double __pyx_v_y; double __pyx_v_d1xy; double __pyx_v_d2xy; double __pyx_v_d1yx; double __pyx_v_d2yx; double __pyx_v_mean; double __pyx_v_process; __Pyx_memviewslice __pyx_v_U = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_V = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj_) __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("exch_test_cn", 0); __Pyx_TraceCall("exch_test_cn", __pyx_f[0], 112, 0, __PYX_ERR(0, 112, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_AddTraceback("copulae.gof._exch_test.exch_test_cn", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_influ, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_s0, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_random, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_U, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_V, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_u, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_g, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__23 = PyTuple_Pack(22, __pyx_n_s_u, __pyx_n_s_g, __pyx_n_s_n, __pyx_n_s_m, __pyx_n_s_N, __pyx_n_s_random_state, __pyx_n_s_influ, __pyx_n_s_s0, __pyx_n_s_random, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_k, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_d1xy, __pyx_n_s_d2xy, __pyx_n_s_d1yx, __pyx_n_s_d2yx, __pyx_n_s_mean, __pyx_n_s_process, __pyx_n_s_U, __pyx_n_s_V); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); /* … */ __Pyx_TraceLine(112,0,__PYX_ERR(0, 112, __pyx_L1_error)) __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7copulae_3gof_10_exch_test_1exch_test_cn, NULL, __pyx_n_s_copulae_gof__exch_test); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_exch_test_cn, __pyx_t_2) < 0) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj_ = (PyObject*)__Pyx_PyCode_New(6, 0, 22, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_copulae_gof__exch_test_pyx, __pyx_n_s_exch_test_cn, 112, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 112, __pyx_L1_error)
113: """
114: Exchangeability test based on the empirical copula
115:
116: Parameters
117: ----------
118: u: ndarray
119: Data to test for exchangeability
120:
121: g: ndarray
122: Integrand grid
123:
124: n: int
125: Number of multiplier or bootstrap iterations to be used to simulate realizations of the test statistic under
126: the null hypothesis.
127:
128: m: int
129: size of the integration grid
130:
131: N: int
132: Number of multiplier or bootstrap iterations to be used to simulate realizations of the test statistic under
133: the null hypothesis.
134:
135: random_state: int
136: Random state used to standardize calculated p-value
137: """
138: cdef:
+139: double[:] influ = np.zeros(m * n), s0 = np.zeros(N), random
__Pyx_TraceLine(139,0,__PYX_ERR(0, 139, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_m * __pyx_v_n)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_influ = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_N); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_s0 = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
140: int i, j, k
141: double x, y, d1xy, d2xy, d1yx, d2yx, mean, process
+142: double[:] U = u[:, 0], V = u[:, 1]
__Pyx_TraceLine(142,0,__PYX_ERR(0, 142, __pyx_L1_error)) __pyx_t_5.data = __pyx_v_u.data; __pyx_t_5.memview = __pyx_v_u.memview; __PYX_INC_MEMVIEW(&__pyx_t_5, 0); __pyx_t_5.shape[0] = __pyx_v_u.shape[0]; __pyx_t_5.strides[0] = __pyx_v_u.strides[0]; __pyx_t_5.suboffsets[0] = -1; { Py_ssize_t __pyx_tmp_idx = 0; Py_ssize_t __pyx_tmp_stride = __pyx_v_u.strides[1]; if ((0)) __PYX_ERR(0, 142, __pyx_L1_error) __pyx_t_5.data += __pyx_tmp_idx * __pyx_tmp_stride; } __pyx_v_U = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL; __pyx_t_5.data = __pyx_v_u.data; __pyx_t_5.memview = __pyx_v_u.memview; __PYX_INC_MEMVIEW(&__pyx_t_5, 0); __pyx_t_5.shape[0] = __pyx_v_u.shape[0]; __pyx_t_5.strides[0] = __pyx_v_u.strides[0]; __pyx_t_5.suboffsets[0] = -1; { Py_ssize_t __pyx_tmp_idx = 1; Py_ssize_t __pyx_tmp_stride = __pyx_v_u.strides[1]; if ((0)) __PYX_ERR(0, 142, __pyx_L1_error) __pyx_t_5.data += __pyx_tmp_idx * __pyx_tmp_stride; } __pyx_v_V = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
143:
+144: for i in range(m):
__Pyx_TraceLine(144,0,__PYX_ERR(0, 144, __pyx_L1_error)) __pyx_t_6 = __pyx_v_m; __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8;
+145: x, y = g[i, 0], g[i, 1]
__Pyx_TraceLine(145,0,__PYX_ERR(0, 145, __pyx_L1_error)) __pyx_t_9 = __pyx_v_i; __pyx_t_10 = 0; __pyx_t_11 = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_g.data + __pyx_t_9 * __pyx_v_g.strides[0]) ) + __pyx_t_10 * __pyx_v_g.strides[1]) ))); __pyx_t_12 = __pyx_v_i; __pyx_t_13 = 1; __pyx_t_14 = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_g.data + __pyx_t_12 * __pyx_v_g.strides[0]) ) + __pyx_t_13 * __pyx_v_g.strides[1]) ))); __pyx_v_x = __pyx_t_11; __pyx_v_y = __pyx_t_14;
+146: d1xy = der_cn_1(U, V, x, y, n)
__Pyx_TraceLine(146,0,__PYX_ERR(0, 146, __pyx_L1_error)) __pyx_v_d1xy = __pyx_f_7copulae_3gof_10_exch_test_der_cn_1(__pyx_v_U, __pyx_v_V, __pyx_v_x, __pyx_v_y, __pyx_v_n);
+147: d2xy = der_cn_2(U, V, x, y, n)
__Pyx_TraceLine(147,0,__PYX_ERR(0, 147, __pyx_L1_error)) __pyx_v_d2xy = __pyx_f_7copulae_3gof_10_exch_test_der_cn_2(__pyx_v_U, __pyx_v_V, __pyx_v_x, __pyx_v_y, __pyx_v_n);
+148: d1yx = der_cn_1(U, V, y, x, n)
__Pyx_TraceLine(148,0,__PYX_ERR(0, 148, __pyx_L1_error)) __pyx_v_d1yx = __pyx_f_7copulae_3gof_10_exch_test_der_cn_1(__pyx_v_U, __pyx_v_V, __pyx_v_y, __pyx_v_x, __pyx_v_n);
+149: d2yx = der_cn_2(U, V, y, x, n)
__Pyx_TraceLine(149,0,__PYX_ERR(0, 149, __pyx_L1_error)) __pyx_v_d2yx = __pyx_f_7copulae_3gof_10_exch_test_der_cn_2(__pyx_v_U, __pyx_v_V, __pyx_v_y, __pyx_v_x, __pyx_v_n);
150:
+151: for j in range(n):
__Pyx_TraceLine(151,0,__PYX_ERR(0, 151, __pyx_L1_error)) __pyx_t_15 = __pyx_v_n; __pyx_t_16 = __pyx_t_15; for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { __pyx_v_j = __pyx_t_17;
+152: influ[i * n + j] = ((U[j] <= x) * (V[j] <= y)
__Pyx_TraceLine(152,0,__PYX_ERR(0, 152, __pyx_L1_error)) __pyx_t_18 = __pyx_v_j; __pyx_t_19 = __pyx_v_j; /* … */ __Pyx_TraceLine(152,0,__PYX_ERR(0, 152, __pyx_L1_error)) __pyx_t_26 = ((__pyx_v_i * __pyx_v_n) + __pyx_v_j); *((double *) ( /* dim=0 */ (__pyx_v_influ.data + __pyx_t_26 * __pyx_v_influ.strides[0]) )) = (((((((((*((double *) ( /* dim=0 */ (__pyx_v_U.data + __pyx_t_18 * __pyx_v_U.strides[0]) ))) <= __pyx_v_x) * ((*((double *) ( /* dim=0 */ (__pyx_v_V.data + __pyx_t_19 * __pyx_v_V.strides[0]) ))) <= __pyx_v_y)) - (__pyx_v_d1xy * ((*((double *) ( /* dim=0 */ (__pyx_v_U.data + __pyx_t_20 * __pyx_v_U.strides[0]) ))) <= __pyx_v_x))) - (__pyx_v_d2xy * ((*((double *) ( /* dim=0 */ (__pyx_v_V.data + __pyx_t_21 * __pyx_v_V.strides[0]) ))) <= __pyx_v_y))) - (((*((double *) ( /* dim=0 */ (__pyx_v_U.data + __pyx_t_22 * __pyx_v_U.strides[0]) ))) <= __pyx_v_y) * ((*((double *) ( /* dim=0 */ (__pyx_v_V.data + __pyx_t_23 * __pyx_v_V.strides[0]) ))) <= __pyx_v_x))) + (__pyx_v_d1yx * ((*((double *) ( /* dim=0 */ (__pyx_v_U.data + __pyx_t_24 * __pyx_v_U.strides[0]) ))) <= __pyx_v_y))) + (__pyx_v_d2yx * ((*((double *) ( /* dim=0 */ (__pyx_v_V.data + __pyx_t_25 * __pyx_v_V.strides[0]) ))) <= __pyx_v_x))) / sqrt(__pyx_v_n)); } }
+153: - d1xy * (U[j] <= x) - d2xy * (V[j] <= y)
__Pyx_TraceLine(153,0,__PYX_ERR(0, 153, __pyx_L1_error)) __pyx_t_20 = __pyx_v_j; __pyx_t_21 = __pyx_v_j;
+154: - (U[j] <= y) * (V[j] <= x)
__Pyx_TraceLine(154,0,__PYX_ERR(0, 154, __pyx_L1_error)) __pyx_t_22 = __pyx_v_j; __pyx_t_23 = __pyx_v_j;
+155: + d1yx * (U[j] <= y) + d2yx * (V[j] <= x)) / sqrt(n)
__Pyx_TraceLine(155,0,__PYX_ERR(0, 155, __pyx_L1_error)) __pyx_t_24 = __pyx_v_j; __pyx_t_25 = __pyx_v_j;
156:
+157: np.random.seed(random_state)
__Pyx_TraceLine(157,0,__PYX_ERR(0, 157, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_seed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_random_state); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
158:
+159: for i in range(N):
__Pyx_TraceLine(159,0,__PYX_ERR(0, 159, __pyx_L1_error)) __pyx_t_6 = __pyx_v_N; __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8;
+160: random = np.random.normal(size=n)
__Pyx_TraceLine(160,0,__PYX_ERR(0, 160, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_normal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_size, __pyx_t_3) < 0) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_random, 1); __pyx_v_random = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
+161: mean = 0.0
__Pyx_TraceLine(161,0,__PYX_ERR(0, 161, __pyx_L1_error)) __pyx_v_mean = 0.0;
+162: for j in range(n):
__Pyx_TraceLine(162,0,__PYX_ERR(0, 162, __pyx_L1_error)) __pyx_t_15 = __pyx_v_n; __pyx_t_16 = __pyx_t_15; for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { __pyx_v_j = __pyx_t_17;
+163: mean += random[j] / n
__Pyx_TraceLine(163,0,__PYX_ERR(0, 163, __pyx_L1_error)) __pyx_t_27 = __pyx_v_j; __pyx_v_mean = (__pyx_v_mean + ((*((double *) ( /* dim=0 */ (__pyx_v_random.data + __pyx_t_27 * __pyx_v_random.strides[0]) ))) / ((double)__pyx_v_n))); }
164:
+165: for j in range(m):
__Pyx_TraceLine(165,0,__PYX_ERR(0, 165, __pyx_L1_error)) __pyx_t_15 = __pyx_v_m; __pyx_t_16 = __pyx_t_15; for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { __pyx_v_j = __pyx_t_17;
+166: process = 0.0
__Pyx_TraceLine(166,0,__PYX_ERR(0, 166, __pyx_L1_error)) __pyx_v_process = 0.0;
+167: for k in range(n):
__Pyx_TraceLine(167,0,__PYX_ERR(0, 167, __pyx_L1_error)) __pyx_t_28 = __pyx_v_n; __pyx_t_29 = __pyx_t_28; for (__pyx_t_30 = 0; __pyx_t_30 < __pyx_t_29; __pyx_t_30+=1) { __pyx_v_k = __pyx_t_30;
+168: process += (random[k] - mean) * influ[k + j * n]
__Pyx_TraceLine(168,0,__PYX_ERR(0, 168, __pyx_L1_error)) __pyx_t_31 = __pyx_v_k; __pyx_t_32 = (__pyx_v_k + (__pyx_v_j * __pyx_v_n)); __pyx_v_process = (__pyx_v_process + (((*((double *) ( /* dim=0 */ (__pyx_v_random.data + __pyx_t_31 * __pyx_v_random.strides[0]) ))) - __pyx_v_mean) * (*((double *) ( /* dim=0 */ (__pyx_v_influ.data + __pyx_t_32 * __pyx_v_influ.strides[0]) ))))); }
+169: s0[i] += process * process
__Pyx_TraceLine(169,0,__PYX_ERR(0, 169, __pyx_L1_error)) __pyx_t_33 = __pyx_v_i; *((double *) ( /* dim=0 */ (__pyx_v_s0.data + __pyx_t_33 * __pyx_v_s0.strides[0]) )) += (__pyx_v_process * __pyx_v_process); }
+170: s0[i] /= m
__Pyx_TraceLine(170,0,__PYX_ERR(0, 170, __pyx_L1_error)) __pyx_t_34 = __pyx_v_i; *((double *) ( /* dim=0 */ (__pyx_v_s0.data + __pyx_t_34 * __pyx_v_s0.strides[0]) )) /= __pyx_v_m; }
171:
+172: return np.asarray(s0)
__Pyx_TraceLine(172,0,__PYX_ERR(0, 172, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_s0, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
173:
174:
+175: def exch_test_stat(double[:, :] u, double[:, :] g, int n, int m):
/* Python wrapper */ static PyObject *__pyx_pw_7copulae_3gof_10_exch_test_3exch_test_stat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_7copulae_3gof_10_exch_test_2exch_test_stat[] = "\n Statistic for the exchangeability test based on the empirical copula\n\n Parameters\n ----------\n u: ndarray\n Data to test for exchangeability\n\n g: ndarray\n Integrand grid\n\n n: int\n number of rows in u\n\n m: int\n size of the integration grid\n\n Returns\n -------\n float\n Value of the test statistic for exchangeability test\n "; static PyMethodDef __pyx_mdef_7copulae_3gof_10_exch_test_3exch_test_stat = {"exch_test_stat", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7copulae_3gof_10_exch_test_3exch_test_stat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7copulae_3gof_10_exch_test_2exch_test_stat}; static PyObject *__pyx_pw_7copulae_3gof_10_exch_test_3exch_test_stat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { __Pyx_memviewslice __pyx_v_u = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_g = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_n; int __pyx_v_m; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("exch_test_stat (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_u,&__pyx_n_s_g,&__pyx_n_s_n,&__pyx_n_s_m,0}; PyObject* values[4] = {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 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_u)) != 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_g)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_test_stat", 1, 4, 4, 1); __PYX_ERR(0, 175, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_test_stat", 1, 4, 4, 2); __PYX_ERR(0, 175, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_test_stat", 1, 4, 4, 3); __PYX_ERR(0, 175, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "exch_test_stat") < 0)) __PYX_ERR(0, 175, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { 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); } __pyx_v_u = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_u.memview)) __PYX_ERR(0, 175, __pyx_L3_error) __pyx_v_g = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_g.memview)) __PYX_ERR(0, 175, __pyx_L3_error) __pyx_v_n = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 175, __pyx_L3_error) __pyx_v_m = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_m == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 175, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("exch_test_stat", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 175, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("copulae.gof._exch_test.exch_test_stat", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7copulae_3gof_10_exch_test_2exch_test_stat(__pyx_self, __pyx_v_u, __pyx_v_g, __pyx_v_n, __pyx_v_m); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7copulae_3gof_10_exch_test_2exch_test_stat(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_u, __Pyx_memviewslice __pyx_v_g, int __pyx_v_n, int __pyx_v_m) { double __pyx_v_s; double __pyx_v_diff; double __pyx_v_x; double __pyx_v_y; int __pyx_v_i; __Pyx_memviewslice __pyx_v_a = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_b = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__2) __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("exch_test_stat", 0); __Pyx_TraceCall("exch_test_stat", __pyx_f[0], 175, 0, __PYX_ERR(0, 175, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("copulae.gof._exch_test.exch_test_stat", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_a, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_b, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_u, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_g, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__24 = PyTuple_Pack(11, __pyx_n_s_u, __pyx_n_s_g, __pyx_n_s_n, __pyx_n_s_m, __pyx_n_s_s, __pyx_n_s_diff, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_i, __pyx_n_s_a, __pyx_n_s_b); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24); /* … */ __Pyx_TraceLine(175,0,__PYX_ERR(0, 175, __pyx_L1_error)) __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7copulae_3gof_10_exch_test_3exch_test_stat, NULL, __pyx_n_s_copulae_gof__exch_test); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_exch_test_stat, __pyx_t_2) < 0) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(4, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_copulae_gof__exch_test_pyx, __pyx_n_s_exch_test_stat, 175, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 175, __pyx_L1_error)
176: """
177: Statistic for the exchangeability test based on the empirical copula
178:
179: Parameters
180: ----------
181: u: ndarray
182: Data to test for exchangeability
183:
184: g: ndarray
185: Integrand grid
186:
187: n: int
188: number of rows in u
189:
190: m: int
191: size of the integration grid
192:
193: Returns
194: -------
195: float
196: Value of the test statistic for exchangeability test
197: """
198: cdef:
+199: double s = 0.0, diff, x, y
__Pyx_TraceLine(199,0,__PYX_ERR(0, 199, __pyx_L1_error)) __pyx_v_s = 0.0;
200: int i
+201: double[:] a = u[:, 0], b = u[:, 1]
__Pyx_TraceLine(201,0,__PYX_ERR(0, 201, __pyx_L1_error)) __pyx_t_1.data = __pyx_v_u.data; __pyx_t_1.memview = __pyx_v_u.memview; __PYX_INC_MEMVIEW(&__pyx_t_1, 0); __pyx_t_1.shape[0] = __pyx_v_u.shape[0]; __pyx_t_1.strides[0] = __pyx_v_u.strides[0]; __pyx_t_1.suboffsets[0] = -1; { Py_ssize_t __pyx_tmp_idx = 0; Py_ssize_t __pyx_tmp_stride = __pyx_v_u.strides[1]; if ((0)) __PYX_ERR(0, 201, __pyx_L1_error) __pyx_t_1.data += __pyx_tmp_idx * __pyx_tmp_stride; } __pyx_v_a = __pyx_t_1; __pyx_t_1.memview = NULL; __pyx_t_1.data = NULL; __pyx_t_1.data = __pyx_v_u.data; __pyx_t_1.memview = __pyx_v_u.memview; __PYX_INC_MEMVIEW(&__pyx_t_1, 0); __pyx_t_1.shape[0] = __pyx_v_u.shape[0]; __pyx_t_1.strides[0] = __pyx_v_u.strides[0]; __pyx_t_1.suboffsets[0] = -1; { Py_ssize_t __pyx_tmp_idx = 1; Py_ssize_t __pyx_tmp_stride = __pyx_v_u.strides[1]; if ((0)) __PYX_ERR(0, 201, __pyx_L1_error) __pyx_t_1.data += __pyx_tmp_idx * __pyx_tmp_stride; } __pyx_v_b = __pyx_t_1; __pyx_t_1.memview = NULL; __pyx_t_1.data = NULL;
202:
+203: for i in range(m):
__Pyx_TraceLine(203,0,__PYX_ERR(0, 203, __pyx_L1_error)) __pyx_t_2 = __pyx_v_m; __pyx_t_3 = __pyx_t_2; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4;
+204: x, y = g[i, 0], g[i, 1]
__Pyx_TraceLine(204,0,__PYX_ERR(0, 204, __pyx_L1_error)) __pyx_t_5 = __pyx_v_i; __pyx_t_6 = 0; __pyx_t_7 = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_g.data + __pyx_t_5 * __pyx_v_g.strides[0]) ) + __pyx_t_6 * __pyx_v_g.strides[1]) ))); __pyx_t_8 = __pyx_v_i; __pyx_t_9 = 1; __pyx_t_10 = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_g.data + __pyx_t_8 * __pyx_v_g.strides[0]) ) + __pyx_t_9 * __pyx_v_g.strides[1]) ))); __pyx_v_x = __pyx_t_7; __pyx_v_y = __pyx_t_10;
+205: diff = cn(a, b, x, y, n) - cn(a, b, y, x, n)
__Pyx_TraceLine(205,0,__PYX_ERR(0, 205, __pyx_L1_error)) __pyx_v_diff = (__pyx_f_7copulae_3gof_10_exch_test_cn(__pyx_v_a, __pyx_v_b, __pyx_v_x, __pyx_v_y, __pyx_v_n) - __pyx_f_7copulae_3gof_10_exch_test_cn(__pyx_v_a, __pyx_v_b, __pyx_v_y, __pyx_v_x, __pyx_v_n));
+206: s += diff * diff
__Pyx_TraceLine(206,0,__PYX_ERR(0, 206, __pyx_L1_error)) __pyx_v_s = (__pyx_v_s + (__pyx_v_diff * __pyx_v_diff)); }
207:
+208: return s * n / m
__Pyx_TraceLine(208,0,__PYX_ERR(0, 208, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_11 = PyFloat_FromDouble(((__pyx_v_s * __pyx_v_n) / ((double)__pyx_v_m))); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_r = __pyx_t_11; __pyx_t_11 = 0; goto __pyx_L0;
209:
210:
+211: def exch_replication(long[:, :] ir, double[:, :] u, double[:, :] g, int n, int m, int ng):
/* Python wrapper */ static PyObject *__pyx_pw_7copulae_3gof_10_exch_test_5exch_replication(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_7copulae_3gof_10_exch_test_4exch_replication[] = "\n One instance of the bootstrap replication\n\n Parameters\n ----------\n ir: ndarray\n\n u: ndarray\n Data to test for exchangeability\n\n g: ndarray\n Integrand grid\n\n n: int\n number of rows in u\n\n m: int\n size of the integration grid\n\n ng: int\n number of rows in g\n\n Returns\n -------\n float\n Value of the test statistic for exchangeability test\n "; static PyMethodDef __pyx_mdef_7copulae_3gof_10_exch_test_5exch_replication = {"exch_replication", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7copulae_3gof_10_exch_test_5exch_replication, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7copulae_3gof_10_exch_test_4exch_replication}; static PyObject *__pyx_pw_7copulae_3gof_10_exch_test_5exch_replication(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { __Pyx_memviewslice __pyx_v_ir = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_u = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_g = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_n; int __pyx_v_m; int __pyx_v_ng; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("exch_replication (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ir,&__pyx_n_s_u,&__pyx_n_s_g,&__pyx_n_s_n,&__pyx_n_s_m,&__pyx_n_s_ng,0}; PyObject* values[6] = {0,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 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; 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_ir)) != 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_u)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_replication", 1, 6, 6, 1); __PYX_ERR(0, 211, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_g)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_replication", 1, 6, 6, 2); __PYX_ERR(0, 211, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_replication", 1, 6, 6, 3); __PYX_ERR(0, 211, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_replication", 1, 6, 6, 4); __PYX_ERR(0, 211, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ng)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("exch_replication", 1, 6, 6, 5); __PYX_ERR(0, 211, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "exch_replication") < 0)) __PYX_ERR(0, 211, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { 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); values[5] = PyTuple_GET_ITEM(__pyx_args, 5); } __pyx_v_ir = __Pyx_PyObject_to_MemoryviewSlice_dsds_long(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_ir.memview)) __PYX_ERR(0, 211, __pyx_L3_error) __pyx_v_u = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_u.memview)) __PYX_ERR(0, 211, __pyx_L3_error) __pyx_v_g = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_g.memview)) __PYX_ERR(0, 211, __pyx_L3_error) __pyx_v_n = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 211, __pyx_L3_error) __pyx_v_m = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_m == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 211, __pyx_L3_error) __pyx_v_ng = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_ng == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 211, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("exch_replication", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 211, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("copulae.gof._exch_test.exch_replication", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7copulae_3gof_10_exch_test_4exch_replication(__pyx_self, __pyx_v_ir, __pyx_v_u, __pyx_v_g, __pyx_v_n, __pyx_v_m, __pyx_v_ng); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7copulae_3gof_10_exch_test_4exch_replication(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_ir, __Pyx_memviewslice __pyx_v_u, __Pyx_memviewslice __pyx_v_g, int __pyx_v_n, int __pyx_v_m, int __pyx_v_ng) { int __pyx_v_i; int __pyx_v_j; int __pyx_v_s1; int __pyx_v_s2; __Pyx_memviewslice __pyx_v_order = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_ub = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_tub = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__3) __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("exch_replication", 0); __Pyx_TraceCall("exch_replication", __pyx_f[0], 211, 0, __PYX_ERR(0, 211, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_22, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1); __Pyx_XDECREF(__pyx_t_33); __Pyx_XDECREF(__pyx_t_34); __Pyx_XDECREF(__pyx_t_35); __Pyx_XDECREF(__pyx_t_36); __Pyx_AddTraceback("copulae.gof._exch_test.exch_replication", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_order, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_ub, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_tub, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_ir, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_u, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_g, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__25 = PyTuple_Pack(13, __pyx_n_s_ir, __pyx_n_s_u, __pyx_n_s_g, __pyx_n_s_n, __pyx_n_s_m, __pyx_n_s_ng, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_s1, __pyx_n_s_s2, __pyx_n_s_order, __pyx_n_s_ub, __pyx_n_s_tub); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25); /* … */ __Pyx_TraceLine(211,0,__PYX_ERR(0, 211, __pyx_L1_error)) __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_7copulae_3gof_10_exch_test_5exch_replication, NULL, __pyx_n_s_copulae_gof__exch_test); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_exch_replication, __pyx_t_2) < 0) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(6, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_copulae_gof__exch_test_pyx, __pyx_n_s_exch_replication, 211, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 211, __pyx_L1_error)
212: """
213: One instance of the bootstrap replication
214:
215: Parameters
216: ----------
217: ir: ndarray
218:
219: u: ndarray
220: Data to test for exchangeability
221:
222: g: ndarray
223: Integrand grid
224:
225: n: int
226: number of rows in u
227:
228: m: int
229: size of the integration grid
230:
231: ng: int
232: number of rows in g
233:
234: Returns
235: -------
236: float
237: Value of the test statistic for exchangeability test
238: """
239: cdef:
240: int i, j, s1, s2
241: long[:] order
+242: double[:, :] ub = np.copy(u), tub
__Pyx_TraceLine(242,0,__PYX_ERR(0, 242, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_u, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ub = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
243:
+244: for i in range(n):
__Pyx_TraceLine(244,0,__PYX_ERR(0, 244, __pyx_L1_error)) __pyx_t_6 = __pyx_v_n; __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8;
+245: s1, s2 = (0, 1) if (<double>rand() / RAND_MAX) > 0.5 else (1, 0)
__Pyx_TraceLine(245,0,__PYX_ERR(0, 245, __pyx_L1_error)) if ((((((double)rand()) / ((double)RAND_MAX)) > 0.5) != 0)) { __pyx_t_10.f0 = 0; __pyx_t_10.f1 = 1; __pyx_t_9 = __pyx_t_10; } else { __pyx_t_10.f0 = 1; __pyx_t_10.f1 = 0; __pyx_t_9 = __pyx_t_10; } __pyx_t_11 = __pyx_t_9.f0; __pyx_t_12 = __pyx_t_9.f1; __pyx_v_s1 = __pyx_t_11; __pyx_v_s2 = __pyx_t_12; /* … */ struct __pyx_ctuple_long__and_long { long f0; long f1; };
+246: ub[i, 0] = u[i, s1]
__Pyx_TraceLine(246,0,__PYX_ERR(0, 246, __pyx_L1_error)) __pyx_t_13 = __pyx_v_i; __pyx_t_14 = __pyx_v_s1; __pyx_t_15 = __pyx_v_i; __pyx_t_16 = 0; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_ub.data + __pyx_t_15 * __pyx_v_ub.strides[0]) ) + __pyx_t_16 * __pyx_v_ub.strides[1]) )) = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_u.data + __pyx_t_13 * __pyx_v_u.strides[0]) ) + __pyx_t_14 * __pyx_v_u.strides[1]) )));
+247: ub[i, 1] = u[i, s2]
__Pyx_TraceLine(247,0,__PYX_ERR(0, 247, __pyx_L1_error)) __pyx_t_17 = __pyx_v_i; __pyx_t_18 = __pyx_v_s2; __pyx_t_19 = __pyx_v_i; __pyx_t_20 = 1; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_ub.data + __pyx_t_19 * __pyx_v_ub.strides[0]) ) + __pyx_t_20 * __pyx_v_ub.strides[1]) )) = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_u.data + __pyx_t_17 * __pyx_v_u.strides[0]) ) + __pyx_t_18 * __pyx_v_u.strides[1]) ))); }
248:
+249: for i in range(2):
__Pyx_TraceLine(249,0,__PYX_ERR(0, 249, __pyx_L1_error)) for (__pyx_t_6 = 0; __pyx_t_6 < 2; __pyx_t_6+=1) { __pyx_v_i = __pyx_t_6;
+250: order = np.argsort(ub[:, i])
__Pyx_TraceLine(250,0,__PYX_ERR(0, 250, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_argsort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_21.data = __pyx_v_ub.data; __pyx_t_21.memview = __pyx_v_ub.memview; __PYX_INC_MEMVIEW(&__pyx_t_21, 0); __pyx_t_21.shape[0] = __pyx_v_ub.shape[0]; __pyx_t_21.strides[0] = __pyx_v_ub.strides[0]; __pyx_t_21.suboffsets[0] = -1; { Py_ssize_t __pyx_tmp_idx = __pyx_v_i; Py_ssize_t __pyx_tmp_stride = __pyx_v_ub.strides[1]; if ((0)) __PYX_ERR(0, 250, __pyx_L1_error) __pyx_t_21.data += __pyx_tmp_idx * __pyx_tmp_stride; } __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_t_21, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1); __pyx_t_21.memview = NULL; __pyx_t_21.data = NULL; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_22 = __Pyx_PyObject_to_MemoryviewSlice_ds_long(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_22.memview)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_order, 1); __pyx_v_order = __pyx_t_22; __pyx_t_22.memview = NULL; __pyx_t_22.data = NULL;
251:
+252: tub = np.copy(ub)
__Pyx_TraceLine(252,0,__PYX_ERR(0, 252, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_ub, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_tub, 1); __pyx_v_tub = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
+253: for j in range(n):
__Pyx_TraceLine(253,0,__PYX_ERR(0, 253, __pyx_L1_error)) __pyx_t_7 = __pyx_v_n; __pyx_t_8 = __pyx_t_7; for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_8; __pyx_t_23+=1) { __pyx_v_j = __pyx_t_23;
+254: ub[j] = tub[<int>order[j]]
__Pyx_TraceLine(254,0,__PYX_ERR(0, 254, __pyx_L1_error)) __pyx_t_24 = __pyx_v_j; __pyx_t_21.data = __pyx_v_tub.data; __pyx_t_21.memview = __pyx_v_tub.memview; __PYX_INC_MEMVIEW(&__pyx_t_21, 0); { Py_ssize_t __pyx_tmp_idx = ((int)(*((long *) ( /* dim=0 */ (__pyx_v_order.data + __pyx_t_24 * __pyx_v_order.strides[0]) )))); Py_ssize_t __pyx_tmp_stride = __pyx_v_tub.strides[0]; if ((0)) __PYX_ERR(0, 254, __pyx_L1_error) __pyx_t_21.data += __pyx_tmp_idx * __pyx_tmp_stride; } __pyx_t_21.shape[0] = __pyx_v_tub.shape[1]; __pyx_t_21.strides[0] = __pyx_v_tub.strides[1]; __pyx_t_21.suboffsets[0] = -1; __pyx_t_25.data = __pyx_v_ub.data; __pyx_t_25.memview = __pyx_v_ub.memview; __PYX_INC_MEMVIEW(&__pyx_t_25, 0); { Py_ssize_t __pyx_tmp_idx = __pyx_v_j; Py_ssize_t __pyx_tmp_stride = __pyx_v_ub.strides[0]; if ((0)) __PYX_ERR(0, 254, __pyx_L1_error) __pyx_t_25.data += __pyx_tmp_idx * __pyx_tmp_stride; } __pyx_t_25.shape[0] = __pyx_v_ub.shape[1]; __pyx_t_25.strides[0] = __pyx_v_ub.strides[1]; __pyx_t_25.suboffsets[0] = -1; if (unlikely(__pyx_memoryview_copy_contents(__pyx_t_21, __pyx_t_25, 1, 1, 0) < 0)) __PYX_ERR(0, 254, __pyx_L1_error) __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1); __pyx_t_25.memview = NULL; __pyx_t_25.data = NULL; __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1); __pyx_t_21.memview = NULL; __pyx_t_21.data = NULL; }
255:
+256: tub = np.copy(ub)
__Pyx_TraceLine(256,0,__PYX_ERR(0, 256, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_ub, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 256, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_tub, 1); __pyx_v_tub = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
+257: for j in range(n):
__Pyx_TraceLine(257,0,__PYX_ERR(0, 257, __pyx_L1_error)) __pyx_t_7 = __pyx_v_n; __pyx_t_8 = __pyx_t_7; for (__pyx_t_23 = 0; __pyx_t_23 < __pyx_t_8; __pyx_t_23+=1) { __pyx_v_j = __pyx_t_23;
+258: ub[j, i] = tub[ir[j, i], i]
__Pyx_TraceLine(258,0,__PYX_ERR(0, 258, __pyx_L1_error)) __pyx_t_26 = __pyx_v_j; __pyx_t_27 = __pyx_v_i; __pyx_t_28 = (*((long *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_ir.data + __pyx_t_26 * __pyx_v_ir.strides[0]) ) + __pyx_t_27 * __pyx_v_ir.strides[1]) ))); __pyx_t_29 = __pyx_v_i; __pyx_t_30 = __pyx_v_j; __pyx_t_31 = __pyx_v_i; *((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_ub.data + __pyx_t_30 * __pyx_v_ub.strides[0]) ) + __pyx_t_31 * __pyx_v_ub.strides[1]) )) = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_tub.data + __pyx_t_28 * __pyx_v_tub.strides[0]) ) + __pyx_t_29 * __pyx_v_tub.strides[1]) ))); } }
259:
+260: ub = pseudo_obs(ub)
__Pyx_TraceLine(260,0,__PYX_ERR(0, 260, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pseudo_obs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_ub, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_ub, 1); __pyx_v_ub = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
261:
+262: if m == 0:
__Pyx_TraceLine(262,0,__PYX_ERR(0, 262, __pyx_L1_error)) __pyx_t_32 = ((__pyx_v_m == 0) != 0); if (__pyx_t_32) { /* … */ }
+263: g = ub
__Pyx_TraceLine(263,0,__PYX_ERR(0, 263, __pyx_L1_error)) __PYX_XDEC_MEMVIEW(&__pyx_v_g, 1); __PYX_INC_MEMVIEW(&__pyx_v_ub, 0); __pyx_v_g = __pyx_v_ub;
264:
+265: return exch_test_stat(ub, g, n, ng)
__Pyx_TraceLine(265,0,__PYX_ERR(0, 265, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_exch_test_stat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_ub, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_g, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_33 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __pyx_t_34 = __Pyx_PyInt_From_int(__pyx_v_ng); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_34); __pyx_t_35 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_35 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_35)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_35); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[5] = {__pyx_t_35, __pyx_t_3, __pyx_t_4, __pyx_t_33, __pyx_t_34}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[5] = {__pyx_t_35, __pyx_t_3, __pyx_t_4, __pyx_t_33, __pyx_t_34}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0; } else #endif { __pyx_t_36 = PyTuple_New(4+__pyx_t_6); if (unlikely(!__pyx_t_36)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_36); if (__pyx_t_35) { __Pyx_GIVEREF(__pyx_t_35); PyTuple_SET_ITEM(__pyx_t_36, 0, __pyx_t_35); __pyx_t_35 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_36, 0+__pyx_t_6, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_36, 1+__pyx_t_6, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_33); PyTuple_SET_ITEM(__pyx_t_36, 2+__pyx_t_6, __pyx_t_33); __Pyx_GIVEREF(__pyx_t_34); PyTuple_SET_ITEM(__pyx_t_36, 3+__pyx_t_6, __pyx_t_34); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_36, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_36); __pyx_t_36 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;