diff options
| author | Ben Green <ben@SEASITs-MacBook-Pro.local> | 2015-06-18 00:24:29 -0400 |
|---|---|---|
| committer | Ben Green <ben@SEASITs-MacBook-Pro.local> | 2015-06-18 00:24:29 -0400 |
| commit | 4ff5e31b715a62a2cc62a1a8f8beab6c4c2234d6 (patch) | |
| tree | 0918b8124bc3663691bf98115e8e4995fd99c250 | |
| parent | 289cc934a3e4c130563538a462e0cd32a08b0256 (diff) | |
| download | criminal_cascades-4ff5e31b715a62a2cc62a1a8f8beab6c4c2234d6.tar.gz | |
altered spawning model and changed temporal probability on
weight_success
| -rw-r--r-- | experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o | bin | 297088 -> 306248 bytes | |||
| -rw-r--r-- | experiments/ml.c | 841 | ||||
| -rw-r--r-- | experiments/ml.pyx | 20 | ||||
| -rwxr-xr-x | experiments/ml.so | bin | 108528 -> 113728 bytes | |||
| -rw-r--r-- | experiments/out.log | 307 | ||||
| -rw-r--r-- | experiments/plot3d.py | 2 | ||||
| -rw-r--r-- | experiments/process.py | 26 |
7 files changed, 837 insertions, 359 deletions
diff --git a/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o b/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o Binary files differindex 6235b48..c1e1a40 100644 --- a/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o +++ b/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o diff --git a/experiments/ml.c b/experiments/ml.c index b7bbed6..3c6c463 100644 --- a/experiments/ml.c +++ b/experiments/ml.c @@ -759,7 +759,7 @@ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; */ typedef npy_cdouble __pyx_t_5numpy_complex_t; -/* "ml.pyx":34 +/* "ml.pyx":37 * return result * * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<< @@ -773,7 +773,7 @@ struct __pyx_obj_2ml___pyx_scope_struct__ml { }; -/* "ml.pyx":58 +/* "ml.pyx":61 * for (dist, dt, w1, w2, w3) in parents] * # find parent that maximizes log(p) - log(\tilde{p}) * probs[i] = max(s - failures[l] for l, s in enumerate(successes)) # <<<<<<<<<<<<<< @@ -871,6 +871,13 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject static PyObject *__Pyx_GetBuiltinName(PyObject *name); +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); + +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename, + int full_traceback); + static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); @@ -983,9 +990,6 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj); PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj)) #endif -static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); -static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); - static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); #if PY_MAJOR_VERSION >= 3 @@ -1054,6 +1058,14 @@ static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); +static int __Pyx_Print(PyObject*, PyObject *, int); +#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 +static PyObject* __pyx_print = 0; +static PyObject* __pyx_print_kwargs = 0; +#endif + +static int __Pyx_PrintOne(PyObject* stream, PyObject *o); + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); @@ -1290,12 +1302,14 @@ static char __pyx_k_w1[] = "w1"; static char __pyx_k_w2[] = "w2"; static char __pyx_k_w3[] = "w3"; static char __pyx_k_age[] = "age"; +static char __pyx_k_end[] = "end"; static char __pyx_k_inf[] = "-inf"; static char __pyx_k_max[] = "max"; static char __pyx_k_sum[] = "sum"; static char __pyx_k_args[] = "args"; static char __pyx_k_beta[] = "beta"; static char __pyx_k_dist[] = "dist"; +static char __pyx_k_file[] = "file"; static char __pyx_k_main[] = "__main__"; static char __pyx_k_send[] = "send"; static char __pyx_k_test[] = "__test__"; @@ -1307,6 +1321,7 @@ static char __pyx_k_delta[] = "delta"; static char __pyx_k_dtype[] = "dtype"; static char __pyx_k_max_i[] = "max_i"; static char __pyx_k_numpy[] = "numpy"; +static char __pyx_k_print[] = "print"; static char __pyx_k_probs[] = "probs"; static char __pyx_k_range[] = "range"; static char __pyx_k_roots[] = "roots"; @@ -1334,6 +1349,7 @@ static char __pyx_k_non_victims[] = "non_victims"; static char __pyx_k_RuntimeError[] = "RuntimeError"; static char __pyx_k_max_beta_add[] = "max_beta_add"; static char __pyx_k_root_victims[] = "root_victims"; +static char __pyx_k_UNDERFLOW_ERROR[] = "UNDERFLOW ERROR"; static char __pyx_k_ml_locals_genexpr[] = "ml.<locals>.genexpr"; static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; static char __pyx_k_Users_ben_Documents_Cascade_Pro[] = "/Users/ben/Documents/Cascade Project/criminal_cascades/experiments/ml.pyx"; @@ -1347,6 +1363,7 @@ static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_s_RuntimeError; +static PyObject *__pyx_kp_s_UNDERFLOW_ERROR; static PyObject *__pyx_kp_s_Users_ben_Documents_Cascade_Pro; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_age; @@ -1360,8 +1377,10 @@ static PyObject *__pyx_n_s_delta; static PyObject *__pyx_n_s_dist; static PyObject *__pyx_n_s_dt; static PyObject *__pyx_n_s_dtype; +static PyObject *__pyx_n_s_end; static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_failures; +static PyObject *__pyx_n_s_file; static PyObject *__pyx_n_s_float64; static PyObject *__pyx_n_s_genexpr; static PyObject *__pyx_n_s_i; @@ -1385,6 +1404,7 @@ static PyObject *__pyx_n_s_non_victims; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; static PyObject *__pyx_n_s_parents; +static PyObject *__pyx_n_s_print; static PyObject *__pyx_n_s_probs; static PyObject *__pyx_n_s_probs_fail; static PyObject *__pyx_n_s_probs_nv; @@ -1466,38 +1486,56 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_success(int __pyx_v_dist, int __py __pyx_t_2ml_DTYPE_t __pyx_v_result; __pyx_t_2ml_DTYPE_t __pyx_r; __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("weight_success", 0); /* "ml.pyx":16 * """weight for successful infection, exponential time model""" * cdef DTYPE_t structural, temporal, result - * structural = dist * log(delta) # <<<<<<<<<<<<<< + * structural = delta ** dist # <<<<<<<<<<<<<< * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - * temporal = log(alpha) - alpha * dt + * temporal = exp(-alpha*dt) * (exp(alpha)-1) */ - __pyx_v_structural = (__pyx_v_dist * log(__pyx_v_delta)); + __pyx_v_structural = pow(__pyx_v_delta, ((__pyx_t_2ml_DTYPE_t)__pyx_v_dist)); /* "ml.pyx":18 - * structural = dist * log(delta) + * structural = delta ** dist * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - * temporal = log(alpha) - alpha * dt # <<<<<<<<<<<<<< + * temporal = exp(-alpha*dt) * (exp(alpha)-1) # <<<<<<<<<<<<<< + * if exp(-alpha*dt)==0.: print 'UNDERFLOW ERROR' * # temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01 - * result = structural + temporal */ - __pyx_v_temporal = (log(__pyx_v_alpha) - (__pyx_v_alpha * __pyx_v_dt)); + __pyx_v_temporal = (exp(((-__pyx_v_alpha) * __pyx_v_dt)) * (exp(__pyx_v_alpha) - 1.0)); - /* "ml.pyx":20 - * temporal = log(alpha) - alpha * dt + /* "ml.pyx":19 + * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) + * temporal = exp(-alpha*dt) * (exp(alpha)-1) + * if exp(-alpha*dt)==0.: print 'UNDERFLOW ERROR' # <<<<<<<<<<<<<< * # temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01 - * result = structural + temporal # <<<<<<<<<<<<<< - * return result - * + * result = log(structural * temporal) */ - __pyx_v_result = (__pyx_v_structural + __pyx_v_temporal); + __pyx_t_1 = ((exp(((-__pyx_v_alpha) * __pyx_v_dt)) == 0.) != 0); + if (__pyx_t_1) { + if (__Pyx_PrintOne(0, __pyx_kp_s_UNDERFLOW_ERROR) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L3; + } + __pyx_L3:; /* "ml.pyx":21 + * if exp(-alpha*dt)==0.: print 'UNDERFLOW ERROR' * # temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01 - * result = structural + temporal + * result = log(structural * temporal) # <<<<<<<<<<<<<< + * # print 'st', structural, temporal + * return result + */ + __pyx_v_result = log((__pyx_v_structural * __pyx_v_temporal)); + + /* "ml.pyx":23 + * result = log(structural * temporal) + * # print 'st', structural, temporal * return result # <<<<<<<<<<<<<< * * cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, @@ -1514,12 +1552,15 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_success(int __pyx_v_dist, int __py */ /* function exit code */ + __pyx_L1_error:; + __Pyx_WriteUnraisable("ml.weight_success", __pyx_clineno, __pyx_lineno, __pyx_filename, 0); + __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "ml.pyx":23 +/* "ml.pyx":25 * return result * * cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<< @@ -1535,36 +1576,36 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_failure(int __pyx_v_dist, int __py __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("weight_failure", 0); - /* "ml.pyx":27 + /* "ml.pyx":29 * """weight for failed infection, exponential time model""" * cdef DTYPE_t structural, temporal, result * structural = delta ** dist # <<<<<<<<<<<<<< * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - * temporal = 1. - exp(-alpha * dt) + * temporal = exp(-alpha * dt) */ __pyx_v_structural = pow(__pyx_v_delta, ((__pyx_t_2ml_DTYPE_t)__pyx_v_dist)); - /* "ml.pyx":29 + /* "ml.pyx":31 * structural = delta ** dist * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - * temporal = 1. - exp(-alpha * dt) # <<<<<<<<<<<<<< + * temporal = exp(-alpha * dt) # <<<<<<<<<<<<<< * # temporal = 1. - 1. / (1. + dt/alpha)**0.01 - * result = log(1. - structural * temporal) + * result = log(1. - structural + structural * temporal) */ - __pyx_v_temporal = (1. - exp(((-__pyx_v_alpha) * __pyx_v_dt))); + __pyx_v_temporal = exp(((-__pyx_v_alpha) * __pyx_v_dt)); - /* "ml.pyx":31 - * temporal = 1. - exp(-alpha * dt) + /* "ml.pyx":33 + * temporal = exp(-alpha * dt) * # temporal = 1. - 1. / (1. + dt/alpha)**0.01 - * result = log(1. - structural * temporal) # <<<<<<<<<<<<<< + * result = log(1. - structural + structural * temporal) # <<<<<<<<<<<<<< + * # print 'stnv', structural, temporal * return result - * */ - __pyx_v_result = log((1. - (__pyx_v_structural * __pyx_v_temporal))); + __pyx_v_result = log(((1. - __pyx_v_structural) + (__pyx_v_structural * __pyx_v_temporal))); - /* "ml.pyx":32 - * # temporal = 1. - 1. / (1. + dt/alpha)**0.01 - * result = log(1. - structural * temporal) + /* "ml.pyx":35 + * result = log(1. - structural + structural * temporal) + * # print 'stnv', structural, temporal * return result # <<<<<<<<<<<<<< * * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, @@ -1572,7 +1613,7 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_failure(int __pyx_v_dist, int __py __pyx_r = __pyx_v_result; goto __pyx_L0; - /* "ml.pyx":23 + /* "ml.pyx":25 * return result * * cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<< @@ -1586,7 +1627,7 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_failure(int __pyx_v_dist, int __py return __pyx_r; } -/* "ml.pyx":34 +/* "ml.pyx":37 * return result * * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<< @@ -1634,31 +1675,31 @@ static PyObject *__pyx_pw_2ml_1ml(PyObject *__pyx_self, PyObject *__pyx_args, Py case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_victims)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_non_victims)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_age)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_delta)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ml") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ml") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { goto __pyx_L5_argtuple_error; @@ -1673,21 +1714,21 @@ static PyObject *__pyx_pw_2ml_1ml(PyObject *__pyx_self, PyObject *__pyx_args, Py __pyx_v_root_victims = ((PyObject*)values[0]); __pyx_v_victims = ((PyObject*)values[1]); __pyx_v_non_victims = ((PyObject*)values[2]); - __pyx_v_age = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_age == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_alpha = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_alpha == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_delta = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_delta == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_age = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_age == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_alpha = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_alpha == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_delta = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_delta == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("ml.ml", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_root_victims), (&PyDict_Type), 1, "root_victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_victims), (&PyDict_Type), 1, "victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_non_victims), (&PyDict_Type), 1, "non_victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_root_victims), (&PyDict_Type), 1, "root_victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_victims), (&PyDict_Type), 1, "victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_non_victims), (&PyDict_Type), 1, "non_victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_2ml_ml(__pyx_self, __pyx_v_root_victims, __pyx_v_victims, __pyx_v_non_victims, __pyx_v_age, __pyx_v_alpha, __pyx_v_delta); /* function exit code */ @@ -1700,7 +1741,7 @@ static PyObject *__pyx_pw_2ml_1ml(PyObject *__pyx_self, PyObject *__pyx_args, Py } static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ -/* "ml.pyx":58 +/* "ml.pyx":61 * for (dist, dt, w1, w2, w3) in parents] * # find parent that maximizes log(p) - log(\tilde{p}) * probs[i] = max(s - failures[l] for l, s in enumerate(successes)) # <<<<<<<<<<<<<< @@ -1726,7 +1767,7 @@ static PyObject *__pyx_pf_2ml_2ml_genexpr(PyObject *__pyx_self) { __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_2ml_2ml_2generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_ml_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_2ml_2ml_2generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_ml_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -1764,16 +1805,16 @@ static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_genera return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = 0; - if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_successes)) { __Pyx_RaiseClosureNameError("successes"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_successes)) { __Pyx_RaiseClosureNameError("successes"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_2 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_successes; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; for (;;) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_s); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_s, __pyx_t_4); @@ -1781,14 +1822,14 @@ static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_genera __pyx_t_4 = 0; __pyx_cur_scope->__pyx_v_l = __pyx_t_1; __pyx_t_1 = (__pyx_t_1 + 1); - if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_failures)) { __Pyx_RaiseClosureNameError("failures"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_failures)) { __Pyx_RaiseClosureNameError("failures"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_failures == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_failures, __pyx_cur_scope->__pyx_v_l, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_failures, __pyx_cur_scope->__pyx_v_l, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_s, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_s, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_5; @@ -1808,7 +1849,7 @@ static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_genera __pyx_cur_scope->__pyx_t_1 = 0; __Pyx_XGOTREF(__pyx_t_2); __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -1828,7 +1869,7 @@ static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_genera return NULL; } -/* "ml.pyx":34 +/* "ml.pyx":37 * return result * * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<< @@ -1918,7 +1959,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_pybuffernd_probs_nv.data = NULL; __pyx_pybuffernd_probs_nv.rcbuffer = &__pyx_pybuffer_probs_nv; - /* "ml.pyx":40 + /* "ml.pyx":43 * DTYPE_t beta, ll, beta2 * list parents, failures, successes * n_roots, n_victims = len(root_victims), len(victims) # <<<<<<<<<<<<<< @@ -1927,18 +1968,18 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ if (unlikely(__pyx_v_root_victims == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_1 = PyDict_Size(__pyx_v_root_victims); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_Size(__pyx_v_root_victims); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (unlikely(__pyx_v_victims == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_2 = PyDict_Size(__pyx_v_victims); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyDict_Size(__pyx_v_victims); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_n_roots = __pyx_t_1; __pyx_v_n_victims = __pyx_t_2; - /* "ml.pyx":41 + /* "ml.pyx":44 * list parents, failures, successes * n_roots, n_victims = len(root_victims), len(victims) * n_nodes = 148152 # <<<<<<<<<<<<<< @@ -1947,43 +1988,43 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ __pyx_v_n_nodes = 148152; - /* "ml.pyx":43 + /* "ml.pyx":46 * n_nodes = 148152 * cdef: * np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE) # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE) * np.ndarray[DTYPE_t] probs_nv = np.zeros(len(non_victims), dtype=DTYPE) */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_victims); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_victims); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = ((PyArrayObject *)__pyx_t_6); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_probs.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { __pyx_v_probs = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_probs.diminfo[0].strides = __pyx_pybuffernd_probs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_probs.diminfo[0].shape = __pyx_pybuffernd_probs.rcbuffer->pybuffer.shape[0]; } } @@ -1991,43 +2032,43 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_v_probs = ((PyArrayObject *)__pyx_t_6); __pyx_t_6 = 0; - /* "ml.pyx":44 + /* "ml.pyx":47 * cdef: * np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE) * np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE) # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t] probs_nv = np.zeros(len(non_victims), dtype=DTYPE) * */ - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_victims); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_victims); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = ((PyArrayObject *)__pyx_t_4); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_probs_fail.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { __pyx_v_probs_fail = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_probs_fail.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_probs_fail.diminfo[0].strides = __pyx_pybuffernd_probs_fail.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_probs_fail.diminfo[0].shape = __pyx_pybuffernd_probs_fail.rcbuffer->pybuffer.shape[0]; } } @@ -2035,48 +2076,48 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_v_probs_fail = ((PyArrayObject *)__pyx_t_4); __pyx_t_4 = 0; - /* "ml.pyx":45 + /* "ml.pyx":48 * np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE) * np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE) * np.ndarray[DTYPE_t] probs_nv = np.zeros(len(non_victims), dtype=DTYPE) # <<<<<<<<<<<<<< * * # loop through victims */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(__pyx_v_non_victims == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_2 = PyDict_Size(__pyx_v_non_victims); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyDict_Size(__pyx_v_non_victims); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_9 = ((PyArrayObject *)__pyx_t_3); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_probs_nv.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { __pyx_v_probs_nv = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_probs_nv.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_probs_nv.diminfo[0].strides = __pyx_pybuffernd_probs_nv.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_probs_nv.diminfo[0].shape = __pyx_pybuffernd_probs_nv.rcbuffer->pybuffer.shape[0]; } } @@ -2084,7 +2125,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_v_probs_nv = ((PyArrayObject *)__pyx_t_3); __pyx_t_3 = 0; - /* "ml.pyx":48 + /* "ml.pyx":51 * * # loop through victims * for i, parents in enumerate(victims.itervalues()): # <<<<<<<<<<<<<< @@ -2095,9 +2136,9 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_t_2 = 0; if (unlikely(__pyx_v_victims == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "itervalues"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_1), (&__pyx_t_11)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_1), (&__pyx_t_11)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = __pyx_t_4; @@ -2105,25 +2146,25 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ while (1) { __pyx_t_12 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_1, &__pyx_t_2, NULL, &__pyx_t_4, NULL, __pyx_t_11); if (unlikely(__pyx_t_12 == 0)) break; - if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_parents, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; __pyx_v_i = __pyx_t_10; __pyx_t_10 = (__pyx_t_10 + 1); - /* "ml.pyx":52 + /* "ml.pyx":55 * # fail to infect it, also computes the probability that its most * # likely parent infects it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< * for (dist, dt, w1, w2, w3) in parents] * probs_fail[i] = sum(failures) */ - __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - /* "ml.pyx":53 + /* "ml.pyx":56 * # likely parent infects it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< @@ -2132,15 +2173,15 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ if (unlikely(__pyx_v_parents == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_5 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_5); __pyx_t_13 = 0; for (;;) { if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_5)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) { PyObject* sequence = __pyx_t_6; @@ -2152,7 +2193,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ if (unlikely(size != 5)) { if (size > 5) __Pyx_RaiseTooManyValuesError(5); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -2178,7 +2219,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ Py_ssize_t i; PyObject** temps[5] = {&__pyx_t_14,&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18}; for (i=0; i < 5; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(item); *(temps[i]) = item; } @@ -2188,7 +2229,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } else { Py_ssize_t index = -1; PyObject** temps[5] = {&__pyx_t_14,&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18}; - __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_20 = Py_TYPE(__pyx_t_19)->tp_iternext; @@ -2197,7 +2238,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_20 = NULL; __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; goto __pyx_L8_unpacking_done; @@ -2205,12 +2246,12 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_20 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L8_unpacking_done:; } - __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_14); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_14); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_21 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_21 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_21 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_v_dist = __pyx_t_12; __pyx_v_dt = __pyx_t_21; @@ -2221,22 +2262,22 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_18); __pyx_t_18 = 0; - /* "ml.pyx":52 + /* "ml.pyx":55 * # fail to infect it, also computes the probability that its most * # likely parent infects it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< * for (dist, dt, w1, w2, w3) in parents] * probs_fail[i] = sum(failures) */ - __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_22, __pyx_t_23, __pyx_t_24)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_22, __pyx_t_23, __pyx_t_24)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "ml.pyx":53 + /* "ml.pyx":56 * # likely parent infects it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< @@ -2250,38 +2291,38 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; - /* "ml.pyx":54 + /* "ml.pyx":57 * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) * for (dist, dt, w1, w2, w3) in parents] * probs_fail[i] = sum(failures) # <<<<<<<<<<<<<< * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) * for (dist, dt, w1, w2, w3) in parents] */ - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_failures); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_cur_scope->__pyx_v_failures); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_failures); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_21 = __pyx_v_i; if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_pybuffernd_probs_fail.diminfo[0].shape; *__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs_fail.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_probs_fail.diminfo[0].strides) = __pyx_t_24; - /* "ml.pyx":55 + /* "ml.pyx":58 * for (dist, dt, w1, w2, w3) in parents] * probs_fail[i] = sum(failures) * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< * for (dist, dt, w1, w2, w3) in parents] * # find parent that maximizes log(p) - log(\tilde{p}) */ - __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - /* "ml.pyx":56 + /* "ml.pyx":59 * probs_fail[i] = sum(failures) * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< @@ -2290,15 +2331,15 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ if (unlikely(__pyx_v_parents == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_4); __pyx_t_13 = 0; for (;;) { if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) { PyObject* sequence = __pyx_t_6; @@ -2310,7 +2351,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ if (unlikely(size != 5)) { if (size > 5) __Pyx_RaiseTooManyValuesError(5); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -2336,7 +2377,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ Py_ssize_t i; PyObject** temps[5] = {&__pyx_t_18,&__pyx_t_17,&__pyx_t_16,&__pyx_t_15,&__pyx_t_14}; for (i=0; i < 5; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(item); *(temps[i]) = item; } @@ -2346,7 +2387,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } else { Py_ssize_t index = -1; PyObject** temps[5] = {&__pyx_t_18,&__pyx_t_17,&__pyx_t_16,&__pyx_t_15,&__pyx_t_14}; - __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_20 = Py_TYPE(__pyx_t_19)->tp_iternext; @@ -2355,7 +2396,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_20 = NULL; __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; goto __pyx_L12_unpacking_done; @@ -2363,12 +2404,12 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_20 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L12_unpacking_done:; } - __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_18); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_18); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; - __pyx_t_25 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_25 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_25 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_25 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_v_dist = __pyx_t_12; __pyx_v_dt = __pyx_t_25; @@ -2379,22 +2420,22 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_14); __pyx_t_14 = 0; - /* "ml.pyx":55 + /* "ml.pyx":58 * for (dist, dt, w1, w2, w3) in parents] * probs_fail[i] = sum(failures) * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< * for (dist, dt, w1, w2, w3) in parents] * # find parent that maximizes log(p) - log(\tilde{p}) */ - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_success(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_24, __pyx_t_23, __pyx_t_22)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_success(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_24, __pyx_t_23, __pyx_t_22)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "ml.pyx":56 + /* "ml.pyx":59 * probs_fail[i] = sum(failures) * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< @@ -2408,24 +2449,24 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; - /* "ml.pyx":58 + /* "ml.pyx":61 * for (dist, dt, w1, w2, w3) in parents] * # find parent that maximizes log(p) - log(\tilde{p}) * probs[i] = max(s - failures[l] for l, s in enumerate(successes)) # <<<<<<<<<<<<<< * * # loop through non-victims */ - __pyx_t_5 = __pyx_pf_2ml_2ml_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __pyx_pf_2ml_2ml_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_max, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_max, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_25 = __pyx_v_i; if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_pybuffernd_probs.diminfo[0].shape; @@ -2433,7 +2474,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "ml.pyx":61 + /* "ml.pyx":64 * * # loop through non-victims * for i, parents in enumerate(non_victims.itervalues()): # <<<<<<<<<<<<<< @@ -2444,9 +2485,9 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_t_1 = 0; if (unlikely(__pyx_v_non_victims == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "itervalues"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_non_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_2), (&__pyx_t_11)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_non_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_2), (&__pyx_t_11)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = __pyx_t_5; @@ -2454,25 +2495,25 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ while (1) { __pyx_t_12 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_2, &__pyx_t_1, NULL, &__pyx_t_5, NULL, __pyx_t_11); if (unlikely(__pyx_t_12 == 0)) break; - if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_parents, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0; __pyx_v_i = __pyx_t_10; __pyx_t_10 = (__pyx_t_10 + 1); - /* "ml.pyx":64 + /* "ml.pyx":67 * # for each non victim node, compute the probability that all its * # parents fail to infect it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< * for (dist, dt, w1, w2, w3) in parents] * probs_nv[i] = sum(failures) */ - __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - /* "ml.pyx":65 + /* "ml.pyx":68 * # parents fail to infect it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< @@ -2481,15 +2522,15 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ if (unlikely(__pyx_v_parents == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_4); __pyx_t_13 = 0; for (;;) { if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) { PyObject* sequence = __pyx_t_6; @@ -2501,7 +2542,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ if (unlikely(size != 5)) { if (size > 5) __Pyx_RaiseTooManyValuesError(5); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -2527,7 +2568,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ Py_ssize_t i; PyObject** temps[5] = {&__pyx_t_14,&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18}; for (i=0; i < 5; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(item); *(temps[i]) = item; } @@ -2537,7 +2578,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } else { Py_ssize_t index = -1; PyObject** temps[5] = {&__pyx_t_14,&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18}; - __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_20 = Py_TYPE(__pyx_t_19)->tp_iternext; @@ -2546,7 +2587,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_20 = NULL; __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; goto __pyx_L18_unpacking_done; @@ -2554,12 +2595,12 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_20 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L18_unpacking_done:; } - __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_14); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_14); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_26 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_26 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_26 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_26 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_v_dist = __pyx_t_12; __pyx_v_dt = __pyx_t_26; @@ -2570,22 +2611,22 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_18); __pyx_t_18 = 0; - /* "ml.pyx":64 + /* "ml.pyx":67 * # for each non victim node, compute the probability that all its * # parents fail to infect it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< * for (dist, dt, w1, w2, w3) in parents] * probs_nv[i] = sum(failures) */ - __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_22, __pyx_t_23, __pyx_t_24)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_22, __pyx_t_23, __pyx_t_24)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "ml.pyx":65 + /* "ml.pyx":68 * # parents fail to infect it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< @@ -2599,22 +2640,22 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; - /* "ml.pyx":66 + /* "ml.pyx":69 * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) * for (dist, dt, w1, w2, w3) in parents] * probs_nv[i] = sum(failures) # <<<<<<<<<<<<<< * * # calculate log likelihood */ - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_failures); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_failures); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_failures); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_26 = __pyx_v_i; if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_pybuffernd_probs_nv.diminfo[0].shape; @@ -2622,14 +2663,14 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "ml.pyx":72 + /* "ml.pyx":75 * # cdef: * # np.ndarray[DTYPE_t] cums = probs.cumsum() * ll = probs_fail.sum() # add probability that all edges to victims fail # <<<<<<<<<<<<<< * ll += probs_nv.sum() # add probability that all edges to non_victims fail * */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_fail), __pyx_n_s_sum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_fail), __pyx_n_s_sum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) { @@ -2642,27 +2683,27 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } } if (__pyx_t_5) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { - __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_ll = __pyx_t_24; - /* "ml.pyx":73 + /* "ml.pyx":76 * # np.ndarray[DTYPE_t] cums = probs.cumsum() * ll = probs_fail.sum() # add probability that all edges to victims fail * ll += probs_nv.sum() # add probability that all edges to non_victims fail # <<<<<<<<<<<<<< * - * max_i = -1 + * print 'probs', probs */ - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_nv), __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_nv), __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { @@ -2675,24 +2716,42 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } } if (__pyx_t_6) { - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { - __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ll = __pyx_t_24; - /* "ml.pyx":75 + /* "ml.pyx":78 * ll += probs_nv.sum() # add probability that all edges to non_victims fail * + * print 'probs', probs # <<<<<<<<<<<<<< + * max_i = -1 + * max_beta_add = float('-inf') + */ + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_n_s_probs); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_probs); + __Pyx_GIVEREF(__pyx_n_s_probs); + __Pyx_INCREF(((PyObject *)__pyx_v_probs)); + PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_probs)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_probs)); + if (__Pyx_Print(0, __pyx_t_5, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "ml.pyx":79 + * + * print 'probs', probs * max_i = -1 # <<<<<<<<<<<<<< * max_beta_add = float('-inf') * # iterate over all victim nodes to find the optimal threshold @@ -2700,20 +2759,20 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __Pyx_INCREF(__pyx_int_neg_1); __pyx_v_max_i = __pyx_int_neg_1; - /* "ml.pyx":76 - * + /* "ml.pyx":80 + * print 'probs', probs * max_i = -1 * max_beta_add = float('-inf') # <<<<<<<<<<<<<< * # iterate over all victim nodes to find the optimal threshold * for i in xrange(0, n_victims+1, 1): */ - __pyx_t_27 = __Pyx_PyObject_AsDouble(__pyx_kp_s_inf); if (unlikely(__pyx_t_27 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = PyFloat_FromDouble(__pyx_t_27); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __Pyx_PyObject_AsDouble(__pyx_kp_s_inf); if (unlikely(__pyx_t_27 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyFloat_FromDouble(__pyx_t_27); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_v_max_beta_add = __pyx_t_5; __pyx_t_5 = 0; - /* "ml.pyx":78 + /* "ml.pyx":82 * max_beta_add = float('-inf') * # iterate over all victim nodes to find the optimal threshold * for i in xrange(0, n_victims+1, 1): # <<<<<<<<<<<<<< @@ -2724,7 +2783,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_28; __pyx_t_10+=1) { __pyx_v_i = __pyx_t_10; - /* "ml.pyx":79 + /* "ml.pyx":83 * # iterate over all victim nodes to find the optimal threshold * for i in xrange(0, n_victims+1, 1): * roots = n_roots + n_victims - i # <<<<<<<<<<<<<< @@ -2733,39 +2792,39 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ __pyx_v_roots = ((__pyx_v_n_roots + __pyx_v_n_victims) - __pyx_v_i); - /* "ml.pyx":80 + /* "ml.pyx":84 * for i in xrange(0, n_victims+1, 1): * roots = n_roots + n_victims - i * beta = float(roots)/float(n_nodes) # <<<<<<<<<<<<<< * thresh = log(beta/(1.-beta)) - * + * # print 'thresh:', thresh */ __pyx_v_beta = (((double)__pyx_v_roots) / ((double)__pyx_v_n_nodes)); - /* "ml.pyx":81 + /* "ml.pyx":85 * roots = n_roots + n_victims - i * beta = float(roots)/float(n_nodes) * thresh = log(beta/(1.-beta)) # <<<<<<<<<<<<<< + * # print 'thresh:', thresh * - * # add probability for realized edges and subtract probability these edges fail */ __pyx_v_thresh = log((__pyx_v_beta / (1. - __pyx_v_beta))); - /* "ml.pyx":84 + /* "ml.pyx":89 * * # add probability for realized edges and subtract probability these edges fail * beta_add = (probs[probs>thresh]).sum() # <<<<<<<<<<<<<< + * # print 'len(probs[probs>thresh]):', len(probs[probs>thresh]) * # add probability for the seeds and non-seeds - * beta_add += roots * log(beta) + (n_nodes-roots) * log(1 - beta) */ - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_t_3); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_t_3); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; @@ -2779,114 +2838,146 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } } if (__pyx_t_4) { - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { - __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_beta_add, __pyx_t_5); __pyx_t_5 = 0; - /* "ml.pyx":86 - * beta_add = (probs[probs>thresh]).sum() + /* "ml.pyx":92 + * # print 'len(probs[probs>thresh]):', len(probs[probs>thresh]) * # add probability for the seeds and non-seeds * beta_add += roots * log(beta) + (n_nodes-roots) * log(1 - beta) # <<<<<<<<<<<<<< * * if beta_add > max_beta_add: */ - __pyx_t_5 = PyFloat_FromDouble(((__pyx_v_roots * log(__pyx_v_beta)) + ((__pyx_v_n_nodes - __pyx_v_roots) * log((1.0 - __pyx_v_beta))))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyFloat_FromDouble(((__pyx_v_roots * log(__pyx_v_beta)) + ((__pyx_v_n_nodes - __pyx_v_roots) * log((1.0 - __pyx_v_beta))))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_beta_add, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_beta_add, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_beta_add, __pyx_t_3); __pyx_t_3 = 0; - /* "ml.pyx":88 + /* "ml.pyx":94 * beta_add += roots * log(beta) + (n_nodes-roots) * log(1 - beta) * * if beta_add > max_beta_add: # <<<<<<<<<<<<<< * max_i = i * max_beta_add = beta_add */ - __pyx_t_3 = PyObject_RichCompare(__pyx_v_beta_add, __pyx_v_max_beta_add, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_29 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_29 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_beta_add, __pyx_v_max_beta_add, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_29 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_29 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_29) { - /* "ml.pyx":89 + /* "ml.pyx":95 * * if beta_add > max_beta_add: * max_i = i # <<<<<<<<<<<<<< * max_beta_add = beta_add - * + * print max_i, max_beta_add */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_max_i, __pyx_t_3); __pyx_t_3 = 0; - /* "ml.pyx":90 + /* "ml.pyx":96 * if beta_add > max_beta_add: * max_i = i * max_beta_add = beta_add # <<<<<<<<<<<<<< - * - * ll += max_beta_add + * print max_i, max_beta_add + * else: */ __Pyx_INCREF(__pyx_v_beta_add); __Pyx_DECREF_SET(__pyx_v_max_beta_add, __pyx_v_beta_add); + + /* "ml.pyx":97 + * max_i = i + * max_beta_add = beta_add + * print max_i, max_beta_add # <<<<<<<<<<<<<< + * else: + * print i + */ + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_max_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_max_i); + __Pyx_GIVEREF(__pyx_v_max_i); + __Pyx_INCREF(__pyx_v_max_beta_add); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_max_beta_add); + __Pyx_GIVEREF(__pyx_v_max_beta_add); + if (__Pyx_Print(0, __pyx_t_3, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L21; } + /*else*/ { + + /* "ml.pyx":99 + * print max_i, max_beta_add + * else: + * print i # <<<<<<<<<<<<<< + * + * ll += max_beta_add + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (__Pyx_PrintOne(0, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } __pyx_L21:; } - /* "ml.pyx":92 - * max_beta_add = beta_add + /* "ml.pyx":101 + * print i * * ll += max_beta_add # <<<<<<<<<<<<<< * roots = n_roots + n_victims - max_i * # print n_nodes, n_roots, n_victims, max_i, roots */ - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_v_max_beta_add); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_v_max_beta_add); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ll = __pyx_t_24; - /* "ml.pyx":93 + /* "ml.pyx":102 * * ll += max_beta_add * roots = n_roots + n_victims - max_i # <<<<<<<<<<<<<< * # print n_nodes, n_roots, n_victims, max_i, roots * return (beta, roots, ll) */ - __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_n_roots + __pyx_v_n_victims)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_n_roots + __pyx_v_n_victims)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyNumber_Subtract(__pyx_t_5, __pyx_v_max_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Subtract(__pyx_t_5, __pyx_v_max_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_roots = __pyx_t_10; - /* "ml.pyx":95 + /* "ml.pyx":104 * roots = n_roots + n_victims - max_i * # print n_nodes, n_roots, n_victims, max_i, roots * return (beta, roots, ll) # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_beta); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_beta); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); @@ -2901,7 +2992,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_t_6 = 0; goto __pyx_L0; - /* "ml.pyx":34 + /* "ml.pyx":37 * return result * * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<< @@ -5208,6 +5299,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, + {&__pyx_kp_s_UNDERFLOW_ERROR, __pyx_k_UNDERFLOW_ERROR, sizeof(__pyx_k_UNDERFLOW_ERROR), 0, 0, 1, 0}, {&__pyx_kp_s_Users_ben_Documents_Cascade_Pro, __pyx_k_Users_ben_Documents_Cascade_Pro, sizeof(__pyx_k_Users_ben_Documents_Cascade_Pro), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_age, __pyx_k_age, sizeof(__pyx_k_age), 0, 0, 1, 1}, @@ -5221,8 +5313,10 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_dist, __pyx_k_dist, sizeof(__pyx_k_dist), 0, 0, 1, 1}, {&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, + {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1}, {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, {&__pyx_n_s_failures, __pyx_k_failures, sizeof(__pyx_k_failures), 0, 0, 1, 1}, + {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1}, {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1}, {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, @@ -5246,6 +5340,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_parents, __pyx_k_parents, sizeof(__pyx_k_parents), 0, 0, 1, 1}, + {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1}, {&__pyx_n_s_probs, __pyx_k_probs, sizeof(__pyx_k_probs), 0, 0, 1, 1}, {&__pyx_n_s_probs_fail, __pyx_k_probs_fail, sizeof(__pyx_k_probs_fail), 0, 0, 1, 1}, {&__pyx_n_s_probs_nv, __pyx_k_probs_nv, sizeof(__pyx_k_probs_nv), 0, 0, 1, 1}, @@ -5269,13 +5364,13 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s_max); if (!__pyx_builtin_max) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s_max); if (!__pyx_builtin_max) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if PY_MAJOR_VERSION >= 3 - __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -5355,17 +5450,17 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); - /* "ml.pyx":34 + /* "ml.pyx":37 * return result * * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<< * DTYPE_t alpha, DTYPE_t delta): * cdef: */ - __pyx_tuple__7 = PyTuple_Pack(33, __pyx_n_s_root_victims, __pyx_n_s_victims, __pyx_n_s_non_victims, __pyx_n_s_age, __pyx_n_s_alpha, __pyx_n_s_delta, __pyx_n_s_n_roots, __pyx_n_s_n_victims, __pyx_n_s_n_nodes, __pyx_n_s_roots, __pyx_n_s_i, __pyx_n_s_dist, __pyx_n_s_dt, __pyx_n_s_t, __pyx_n_s_l, __pyx_n_s_beta, __pyx_n_s_ll, __pyx_n_s_beta2, __pyx_n_s_parents, __pyx_n_s_failures, __pyx_n_s_successes, __pyx_n_s_probs, __pyx_n_s_probs_fail, __pyx_n_s_probs_nv, __pyx_n_s_max_i, __pyx_n_s_max_beta_add, __pyx_n_s_thresh, __pyx_n_s_beta_add, __pyx_n_s_w1, __pyx_n_s_w2, __pyx_n_s_w3, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__7 = PyTuple_Pack(33, __pyx_n_s_root_victims, __pyx_n_s_victims, __pyx_n_s_non_victims, __pyx_n_s_age, __pyx_n_s_alpha, __pyx_n_s_delta, __pyx_n_s_n_roots, __pyx_n_s_n_victims, __pyx_n_s_n_nodes, __pyx_n_s_roots, __pyx_n_s_i, __pyx_n_s_dist, __pyx_n_s_dt, __pyx_n_s_t, __pyx_n_s_l, __pyx_n_s_beta, __pyx_n_s_ll, __pyx_n_s_beta2, __pyx_n_s_parents, __pyx_n_s_failures, __pyx_n_s_successes, __pyx_n_s_probs, __pyx_n_s_probs_fail, __pyx_n_s_probs_nv, __pyx_n_s_max_i, __pyx_n_s_max_beta_add, __pyx_n_s_thresh, __pyx_n_s_beta_add, __pyx_n_s_w1, __pyx_n_s_w2, __pyx_n_s_w3, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); - __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(6, 0, 33, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ben_Documents_Cascade_Pro, __pyx_n_s_ml, 34, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(6, 0, 33, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ben_Documents_Cascade_Pro, __pyx_n_s_ml, 37, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -5462,10 +5557,10 @@ PyMODINIT_FUNC PyInit_ml(void) /*--- Variable export code ---*/ /*--- Function export code ---*/ /*--- Type init code ---*/ - if (PyType_Ready(&__pyx_type_2ml___pyx_scope_struct__ml) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_2ml___pyx_scope_struct__ml) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_type_2ml___pyx_scope_struct__ml.tp_print = 0; __pyx_ptype_2ml___pyx_scope_struct__ml = &__pyx_type_2ml___pyx_scope_struct__ml; - if (PyType_Ready(&__pyx_type_2ml___pyx_scope_struct_1_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_2ml___pyx_scope_struct_1_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_type_2ml___pyx_scope_struct_1_genexpr.tp_print = 0; __pyx_ptype_2ml___pyx_scope_struct_1_genexpr = &__pyx_type_2ml___pyx_scope_struct_1_genexpr; /*--- Type import code ---*/ @@ -5511,16 +5606,16 @@ PyMODINIT_FUNC PyInit_ml(void) if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "ml.pyx":34 + /* "ml.pyx":37 * return result * * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<< * DTYPE_t alpha, DTYPE_t delta): * cdef: */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_2ml_1ml, NULL, __pyx_n_s_ml); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_2ml_1ml, NULL, __pyx_n_s_ml); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_ml, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ml, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "ml.pyx":1 @@ -5594,6 +5689,64 @@ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { return result; } +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_Restore(type, value, tb); +#endif +} +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(type, value, tb); +#endif +} + +static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +} + static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, @@ -6772,37 +6925,6 @@ bad: return (double)-1; } -static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { -#if CYTHON_COMPILING_IN_CPYTHON - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_Restore(type, value, tb); -#endif -} -static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { -#if CYTHON_COMPILING_IN_CPYTHON - PyThreadState *tstate = PyThreadState_GET(); - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(type, value, tb); -#endif -} - #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { @@ -7213,6 +7335,147 @@ bad: return module; } +#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 +static PyObject *__Pyx_GetStdout(void) { + PyObject *f = PySys_GetObject((char *)"stdout"); + if (!f) { + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); + } + return f; +} +static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { + int i; + if (!f) { + if (!(f = __Pyx_GetStdout())) + return -1; + } + Py_INCREF(f); + for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { + PyObject* v; + if (PyFile_SoftSpace(f, 1)) { + if (PyFile_WriteString(" ", f) < 0) + goto error; + } + v = PyTuple_GET_ITEM(arg_tuple, i); + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) + goto error; + if (PyString_Check(v)) { + char *s = PyString_AsString(v); + Py_ssize_t len = PyString_Size(v); + if (len > 0) { + switch (s[len-1]) { + case ' ': break; + case '\f': case '\r': case '\n': case '\t': case '\v': + PyFile_SoftSpace(f, 0); + break; + default: break; + } + } + } + } + if (newline) { + if (PyFile_WriteString("\n", f) < 0) + goto error; + PyFile_SoftSpace(f, 0); + } + Py_DECREF(f); + return 0; +error: + Py_DECREF(f); + return -1; +} +#else +static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { + PyObject* kwargs = 0; + PyObject* result = 0; + PyObject* end_string; + if (unlikely(!__pyx_print)) { + __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print); + if (!__pyx_print) + return -1; + } + if (stream) { + kwargs = PyDict_New(); + if (unlikely(!kwargs)) + return -1; + if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0)) + goto bad; + if (!newline) { + end_string = PyUnicode_FromStringAndSize(" ", 1); + if (unlikely(!end_string)) + goto bad; + if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) { + Py_DECREF(end_string); + goto bad; + } + Py_DECREF(end_string); + } + } else if (!newline) { + if (unlikely(!__pyx_print_kwargs)) { + __pyx_print_kwargs = PyDict_New(); + if (unlikely(!__pyx_print_kwargs)) + return -1; + end_string = PyUnicode_FromStringAndSize(" ", 1); + if (unlikely(!end_string)) + return -1; + if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) { + Py_DECREF(end_string); + return -1; + } + Py_DECREF(end_string); + } + kwargs = __pyx_print_kwargs; + } + result = PyObject_Call(__pyx_print, arg_tuple, kwargs); + if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs)) + Py_DECREF(kwargs); + if (!result) + return -1; + Py_DECREF(result); + return 0; +bad: + if (kwargs != __pyx_print_kwargs) + Py_XDECREF(kwargs); + return -1; +} +#endif + +#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 +static int __Pyx_PrintOne(PyObject* f, PyObject *o) { + if (!f) { + if (!(f = __Pyx_GetStdout())) + return -1; + } + Py_INCREF(f); + if (PyFile_SoftSpace(f, 0)) { + if (PyFile_WriteString(" ", f) < 0) + goto error; + } + if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) + goto error; + if (PyFile_WriteString("\n", f) < 0) + goto error; + Py_DECREF(f); + return 0; +error: + Py_DECREF(f); + return -1; + /* the line below is just to avoid C compiler + * warnings about unused functions */ + return __Pyx_Print(f, NULL, 0); +} +#else +static int __Pyx_PrintOne(PyObject* stream, PyObject *o) { + int res; + PyObject* arg_tuple = PyTuple_Pack(1, o); + if (unlikely(!arg_tuple)) + return -1; + res = __Pyx_Print(stream, arg_tuple, 1); + Py_DECREF(arg_tuple); + return res; +} +#endif + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { const int neg_one = (int) -1, const_zero = 0; const int is_unsigned = neg_one > const_zero; diff --git a/experiments/ml.pyx b/experiments/ml.pyx index 8dfea70..cc79609 100644 --- a/experiments/ml.pyx +++ b/experiments/ml.pyx @@ -13,11 +13,13 @@ cdef DTYPE_t weight_success(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, DTYPE_t w1, DTYPE_t w2, DTYPE_t w3): """weight for successful infection, exponential time model""" cdef DTYPE_t structural, temporal, result - structural = dist * log(delta) + structural = delta ** dist # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - temporal = log(alpha) - alpha * dt + temporal = exp(-alpha*dt) * (exp(alpha)-1) + if exp(-alpha*dt)==0.: print 'UNDERFLOW ERROR' # temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01 - result = structural + temporal + result = log(structural * temporal) + # print 'st', structural, temporal return result cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, @@ -26,9 +28,10 @@ cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, cdef DTYPE_t structural, temporal, result structural = delta ** dist # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - temporal = 1. - exp(-alpha * dt) + temporal = exp(-alpha * dt) # temporal = 1. - 1. / (1. + dt/alpha)**0.01 - result = log(1. - structural * temporal) + result = log(1. - structural + structural * temporal) + # print 'stnv', structural, temporal return result def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, @@ -72,6 +75,7 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, ll = probs_fail.sum() # add probability that all edges to victims fail ll += probs_nv.sum() # add probability that all edges to non_victims fail + print 'probs', probs max_i = -1 max_beta_add = float('-inf') # iterate over all victim nodes to find the optimal threshold @@ -79,16 +83,20 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, roots = n_roots + n_victims - i beta = float(roots)/float(n_nodes) thresh = log(beta/(1.-beta)) + # print 'thresh:', thresh # add probability for realized edges and subtract probability these edges fail beta_add = (probs[probs>thresh]).sum() - print len(probs[probs>thresh]) + # print 'len(probs[probs>thresh]):', len(probs[probs>thresh]) # add probability for the seeds and non-seeds beta_add += roots * log(beta) + (n_nodes-roots) * log(1 - beta) if beta_add > max_beta_add: max_i = i max_beta_add = beta_add + print max_i, max_beta_add + else: + print i ll += max_beta_add roots = n_roots + n_victims - max_i diff --git a/experiments/ml.so b/experiments/ml.so Binary files differindex 687e6fc..59be721 100755 --- a/experiments/ml.so +++ b/experiments/ml.so diff --git a/experiments/out.log b/experiments/out.log index 7651bb5..69fb56d 100644 --- a/experiments/out.log +++ b/experiments/out.log @@ -1,50 +1,257 @@ -inf 0.01 0.00728306064042 1079 nan -inf 0.11 0.00728306064042 1079 nan -inf 0.21 0.00728306064042 1079 nan -inf 0.31 0.00728306064042 1079 nan -inf 0.41 0.00728306064042 1079 nan -0.01 0.01 0.00728306064042 1079 -7632.33888826 -0.01 0.11 0.00728306064042 1079 -41145.4085812 -0.01 0.21 0.00728306064042 1079 -143816.774349 -0.01 0.31 0.00728306064042 1079 -362824.427206 -0.01 0.41 0.00728306064042 1079 -753873.18328 -0.005 0.01 0.00728306064042 1079 -7578.26678869 -0.005 0.11 0.00728306064042 1079 -39671.6480412 -0.005 0.21 0.00728306064042 1079 -138032.49228 -0.005 0.31 0.00728306064042 1079 -347783.849869 -0.005 0.41 0.00728306064042 1079 -721985.508852 -0.00333333333333 0.01 0.00728306064042 1079 -7522.44276229 -0.00333333333333 0.11 0.00728306064042 1079 -38127.923151 -0.00333333333333 0.21 0.00728306064042 1079 -131943.601486 -0.00333333333333 0.31 0.00728306064042 1079 -331924.789171 -0.00333333333333 0.41 0.00728306064042 1079 -688355.043571 -0.0025 0.01 0.00728306064042 1079 -7467.51417822 -0.0025 0.11 0.00728306064042 1079 -36599.8359599 -0.0025 0.21 0.00728306064042 1079 -125903.505379 -0.0025 0.31 0.00728306064042 1079 -316183.068106 -0.0025 0.41 0.00728306064042 1079 -654979.438431 -0.002 0.01 0.00728306064042 1079 -7414.70185168 -0.002 0.11 0.00728306064042 1079 -35125.3347484 -0.002 0.21 0.00728306064042 1079 -120067.848333 -0.002 0.31 0.00728306064042 1079 -300970.34788 -0.002 0.41 0.00728306064042 1079 -622737.297292 -0.00166666666667 0.01 0.00728306064042 1079 -7364.63045747 -0.00166666666667 0.11 0.00728306064042 1079 -33723.8769361 -0.00166666666667 0.21 0.00728306064042 1079 -114516.615274 -0.00166666666667 0.31 0.00728306064042 1079 -286498.257545 -0.00166666666667 0.41 0.00728306064042 1079 -592079.644373 -0.00142857142857 0.01 0.00728306064042 1079 -7317.59743719 -0.00142857142857 0.11 0.00728306064042 1079 -32405.1880251 -0.00142857142857 0.21 0.00728306064042 1079 -109290.356131 -0.00142857142857 0.31 0.00728306064042 1079 -272874.512749 -0.00142857142857 0.41 0.00728306064042 1079 -563235.857483 -0.00125 0.01 0.00728306064042 1079 -7273.68766807 -0.00125 0.11 0.00728306064042 1079 -31172.6518115 -0.00125 0.21 0.00728306064042 1079 -104403.890399 -0.00125 0.31 0.00728306064042 1079 -260138.956484 -0.00125 0.41 0.00728306064042 1079 -536290.339785 -0.00111111111111 0.01 0.00728306064042 1079 -7232.84785268 -0.00111111111111 0.11 0.00728306064042 1079 -30025.4645403 -0.00111111111111 0.21 0.00728306064042 1079 -99854.9698943 -0.00111111111111 0.31 0.00728306064042 1079 -248286.311147 -0.00111111111111 0.41 0.00728306064042 1079 -511230.928521 +0.1 0.01 0.00728306064042 1079 -7672.37449847 +0.1 0.04 0.00728306064042 1079 -13270.9153785 +0.1 0.07 0.00728306064042 1079 -22408.265265 +0.1 0.1 0.00728306064042 1079 -36527.0106433 +0.1 0.13 0.00728306064042 1079 -56550.9043071 +0.1 0.16 0.00728306064042 1079 -83812.9459811 +0.1 0.19 0.00728306064042 1079 -119466.349611 +0.1 0.22 0.00728306064042 1079 -164926.067074 +0.1 0.25 0.00728306064042 1079 -221536.167159 +0.1 0.28 0.00728306064042 1106 -290957.449737 +0.1 0.31 0.00728306064042 1129 -375216.627406 +0.1 0.34 0.00728306064042 1136 -474978.488346 +0.1 0.37 0.00728306064042 1129 -592411.673759 +0.1 0.4 0.00728306064042 1112 -729280.882512 +0.1 0.43 0.00728306064042 1193 -888069.229065 +0.1 0.46 0.00728306064042 1388 -1071433.27857 +0.1 0.49 0.00728306064042 1659 -1282287.37906 +0.0166666666667 0.01 0.00728306064042 1079 -7651.94228129 +0.0166666666667 0.04 0.00728306064042 1079 -13165.6513039 +0.0166666666667 0.07 0.00728306064042 1079 -22170.561961 +0.0166666666667 0.1 0.00728306064042 1079 -35856.1922378 +0.0166666666667 0.13 0.00728306064042 1079 -55428.4655996 +0.0166666666667 0.16 0.00728306064042 1079 -82115.6847917 +0.0166666666667 0.19 0.00728306064042 1079 -117176.725216 +0.0166666666667 0.22 0.00728306064042 1079 -161911.615085 +0.0166666666667 0.25 0.00728306064042 1079 -217674.76343 +0.0166666666667 0.28 0.00728306064042 1079 -285891.221147 +0.0166666666667 0.31 0.00728306064042 1079 -368076.524072 +0.0166666666667 0.34 0.00728306064042 1079 -465860.884747 +0.0166666666667 0.37 0.00728306064042 1079 -581018.792804 +0.0166666666667 0.4 0.00728306064042 1079 -715505.485424 +0.0166666666667 0.43 0.00728306064042 1079 -871502.309087 +0.0166666666667 0.46 0.00728306064042 1127 -1051708.64402 +0.0166666666667 0.49 0.00728306064042 1200 -1258828.48382 +0.00909090909091 0.01 0.00728306064042 1079 -7627.15571653 +0.00909090909091 0.04 0.00728306064042 1079 -13035.2615672 +0.00909090909091 0.07 0.00728306064042 1079 -21871.2622768 +0.00909090909091 0.1 0.00728306064042 1079 -35303.2182269 +0.00909090909091 0.13 0.00728306064042 1079 -54515.1069214 +0.00909090909091 0.16 0.00728306064042 1079 -80712.6175917 +0.00909090909091 0.19 0.00728306064042 1079 -115131.09802 +0.00909090909091 0.22 0.00728306064042 1079 -159045.814242 +0.00909090909091 0.25 0.00728306064042 1079 -213784.773998 +0.00909090909091 0.28 0.00728306064042 1079 -280744.484014 +0.00909090909091 0.31 0.00728306064042 1079 -361409.168406 +0.00909090909091 0.34 0.00728306064042 1079 -457374.18427 +0.00909090909091 0.37 0.00728306064042 1079 -570374.651481 +0.00909090909091 0.4 0.00728306064042 1079 -702320.698081 +0.00909090909091 0.43 0.00728306064042 1079 -855341.257805 +0.00909090909091 0.46 0.00728306064042 1079 -1031839.11576 +0.00909090909091 0.49 0.00728306064042 1079 -1234560.99749 +0.00625 0.01 0.00728306064042 1079 -7600.34520247 +0.00625 0.04 0.00728306064042 1079 -12893.0425783 +0.00625 0.07 0.00728306064042 1079 -21542.7951446 +0.00625 0.1 0.00728306064042 1079 -34693.688586 +0.00625 0.13 0.00728306064042 1079 -53505.1885411 +0.00625 0.16 0.00728306064042 1079 -79157.7387492 +0.00625 0.19 0.00728306064042 1079 -112860.437597 +0.00625 0.22 0.00728306064042 1079 -155860.946697 +0.00625 0.25 0.00728306064042 1079 -209457.871396 +0.00625 0.28 0.00728306064042 1079 -275015.967056 +0.00625 0.31 0.00728306064042 1079 -353984.675109 +0.00625 0.34 0.00728306064042 1079 -447920.692108 +0.00625 0.37 0.00728306064042 1079 -558515.542869 +0.00625 0.4 0.00728306064042 1079 -687629.494801 +0.00625 0.43 0.00728306064042 1079 -837333.659614 +0.00625 0.46 0.00728306064042 1079 -1009962.85014 +0.00625 0.49 0.00728306064042 1079 -1208182.80302 +0.0047619047619 0.01 0.00728306064042 1079 -7572.70106714 +0.0047619047619 0.04 0.00728306064042 1079 -12745.7637304 +0.0047619047619 0.07 0.00728306064042 1079 -21201.547286 +0.0047619047619 0.1 0.00728306064042 1079 -34058.9849838 +0.0047619047619 0.13 0.00728306064042 1079 -52451.8343474 +0.0047619047619 0.16 0.00728306064042 1079 -77534.0721985 +0.0047619047619 0.19 0.00728306064042 1079 -110487.291781 +0.0047619047619 0.22 0.00728306064042 1079 -152530.248419 +0.0047619047619 0.25 0.00728306064042 1079 -204930.782366 +0.0047619047619 0.28 0.00728306064042 1079 -269020.456077 +0.0047619047619 0.31 0.00728306064042 1079 -346212.386035 +0.0047619047619 0.34 0.00728306064042 1079 -438022.93877 +0.0047619047619 0.37 0.00728306064042 1079 -546098.21516 +0.0047619047619 0.4 0.00728306064042 1079 -672246.594396 +0.0047619047619 0.43 0.00728306064042 1079 -818479.091441 +0.0047619047619 0.46 0.00728306064042 1079 -987059.964707 +0.0047619047619 0.49 0.00728306064042 1079 -1180570.99634 +0.00384615384615 0.01 0.00728306064042 1079 -7544.7658607 +0.00384615384615 0.04 0.00728306064042 1079 -12596.5681988 +0.00384615384615 0.07 0.00728306064042 1079 -20855.2188135 +0.00384615384615 0.1 0.00728306064042 1079 -33413.9683545 +0.00384615384615 0.13 0.00728306064042 1079 -51380.3308325 +0.00384615384615 0.16 0.00728306064042 1079 -75881.2735367 +0.00384615384615 0.19 0.00728306064042 1079 -108070.332024 +0.00384615384615 0.22 0.00728306064042 1079 -149136.7894 +0.00384615384615 0.25 0.00728306064042 1079 -200317.137271 +0.00384615384615 0.28 0.00728306064042 1079 -262909.138934 +0.00384615384615 0.31 0.00728306064042 1079 -338288.951015 +0.00384615384615 0.34 0.00728306064042 1079 -427931.939504 +0.00384615384615 0.37 0.00728306064042 1079 -533438.067176 +0.00384615384615 0.4 0.00728306064042 1079 -656563.057933 +0.00384615384615 0.43 0.00728306064042 1079 -799256.999428 +0.00384615384615 0.46 0.00728306064042 1079 -963712.689535 +0.00384615384615 0.49 0.00728306064042 1079 -1152426.96068 +0.00322580645161 0.01 0.00728306064042 1079 -7516.88254834 +0.00322580645161 0.04 0.00728306064042 1079 -12447.4221082 +0.00322580645161 0.07 0.00728306064042 1079 -20508.5991803 +0.00322580645161 0.1 0.00728306064042 1079 -32767.8542636 +0.00322580645161 0.13 0.00728306064042 1079 -50306.3336673 +0.00322580645161 0.16 0.00728306064042 1079 -74223.8754529 +0.00322580645161 0.19 0.00728306064042 1079 -105645.843876 +0.00322580645161 0.22 0.00728306064042 1079 -145731.944412 +0.00322580645161 0.25 0.00728306064042 1079 -195687.225638 +0.00322580645161 0.28 0.00728306064042 1079 -256775.572047 +0.00322580645161 0.31 0.00728306064042 1079 -330336.120438 +0.00322580645161 0.34 0.00728306064042 1079 -417803.202575 +0.00322580645161 0.37 0.00728306064042 1079 -520730.644647 +0.00322580645161 0.4 0.00728306064042 1079 -640821.564217 +0.00322580645161 0.43 0.00728306064042 1079 -779965.234904 +0.00322580645161 0.46 0.00728306064042 1079 -940283.195333 +0.00322580645161 0.49 0.00728306064042 1079 -1124187.65117 +0.00277777777778 0.01 0.00728306064042 1079 -7489.28187435 +0.00277777777778 0.04 0.00728306064042 1079 -12299.6297539 +0.00277777777778 0.07 0.00728306064042 1079 -20164.8396682 +0.00277777777778 0.1 0.00728306064042 1079 -32126.6770508 +0.00277777777778 0.13 0.00728306064042 1079 -49240.0645134 +0.00277777777778 0.16 0.00728306064042 1079 -72577.8670012 +0.00277777777778 0.19 0.00728306064042 1079 -103237.450097 +0.00277777777778 0.22 0.00728306064042 1079 -142349.1366 +0.00277777777778 0.25 0.00728306064042 1079 -191086.756779 +0.00277777777778 0.28 0.00728306064042 1079 -250680.580322 +0.00277777777778 0.31 0.00728306064042 1079 -322433.039559 +0.00277777777778 0.34 0.00728306064042 1079 -407737.814249 +0.00277777777778 0.37 0.00728306064042 1079 -508103.063153 +0.00277777777778 0.4 0.00728306064042 1079 -625179.879841 +0.00277777777778 0.43 0.00728306064042 1079 -760797.454308 +0.00277777777778 0.46 0.00728306064042 1079 -917006.991361 +0.00277777777778 0.49 0.00728306064042 1079 -1096137.25458 +0.00243902439024 0.01 0.00728306064042 1079 -7462.124071 +0.00243902439024 0.04 0.00728306064042 1079 -12154.0886906 +0.00243902439024 0.07 0.00728306064042 1079 -19826.097427 +0.00243902439024 0.1 0.00728306064042 1079 -31494.554657 +0.00243902439024 0.13 0.00728306064042 1079 -48188.4858438 +0.00243902439024 0.16 0.00728306064042 1079 -70954.1264488 +0.00243902439024 0.19 0.00728306064042 1079 -100861.210371 +0.00243902439024 0.22 0.00728306064042 1079 -139011.076291 +0.00243902439024 0.25 0.00728306064042 1079 -186546.776802 +0.00243902439024 0.28 0.00728306064042 1079 -244665.462742 +0.00243902439024 0.31 0.00728306064042 1079 -314633.430015 +0.00243902439024 0.34 0.00728306064042 1079 -397804.367757 +0.00243902439024 0.37 0.00728306064042 1079 -495641.549225 +0.00243902439024 0.4 0.00728306064042 1079 -609744.981708 +0.00243902439024 0.43 0.00728306064042 1079 -741884.911273 +0.00243902439024 0.46 0.00728306064042 1079 -894043.612101 +0.00243902439024 0.49 0.00728306064042 1079 -1068468.15553 +0.00217391304348 0.01 0.00728306064042 1079 -7435.5238322 +0.00217391304348 0.04 0.00728306064042 1079 -12011.4396457 +0.00217391304348 0.07 0.00728306064042 1079 -19493.9103138 +0.00217391304348 0.1 0.00728306064042 1079 -30874.4209777 +0.00217391304348 0.13 0.00728306064042 1079 -47156.5567805 +0.00217391304348 0.16 0.00728306064042 1079 -69360.4010049 +0.00217391304348 0.19 0.00728306064042 1079 -98528.5611942 +0.00217391304348 0.22 0.00728306064042 1079 -135733.935135 +0.00217391304348 0.25 0.00728306064042 1079 -182089.391422 +0.00217391304348 0.28 0.00728306064042 1079 -238759.622009 +0.00217391304348 0.31 0.00728306064042 1079 -306975.532533 +0.00217391304348 0.34 0.00728306064042 1079 -388051.678977 +0.00217391304348 0.37 0.00728306064042 1079 -483407.449885 +0.00217391304348 0.4 0.00728306064042 1079 -594592.951545 +0.00217391304348 0.43 0.00728306064042 1079 -723320.909577 +0.00217391304348 0.46 0.00728306064042 1079 -871506.400202 +0.00217391304348 0.49 0.00728306064042 1079 -1041316.93973 +0.00196078431373 0.01 0.00728306064042 1079 -7409.56438246 +0.00196078431373 0.04 0.00728306064042 1079 -11872.1488153 +0.00196078431373 0.07 0.00728306064042 1079 -19169.3996851 +0.00196078431373 0.1 0.00728306064042 1079 -30268.418729 +0.00196078431373 0.13 0.00728306064042 1079 -46147.903349 +0.00196078431373 0.16 0.00728306064042 1079 -67802.3601023 +0.00196078431373 0.19 0.00728306064042 1079 -96247.8769554 +0.00196078431373 0.22 0.00728306064042 1079 -132529.559938 +0.00196078431373 0.25 0.00728306064042 1079 -177730.799171 +0.00196078431373 0.28 0.00728306064042 1079 -232984.607285 +0.00196078431373 0.31 0.00728306064042 1079 -299487.375334 +0.00196078431373 0.34 0.00728306064042 1079 -378515.525831 +0.00196078431373 0.37 0.00728306064042 1079 -471445.721599 +0.00196078431373 0.4 0.00728306064042 1079 -579779.531563 +0.00196078431373 0.43 0.00728306064042 1079 -705173.788035 +0.00196078431373 0.46 0.00728306064042 1079 -849478.337475 +0.00196078431373 0.49 0.00728306064042 1079 -1014783.55414 +0.00178571428571 0.01 0.00728306064042 1079 -7384.30535784 +0.00178571428571 0.04 0.00728306064042 1079 -11736.5526894 +0.00178571428571 0.07 0.00728306064042 1079 -18853.3790446 +0.00178571428571 0.1 0.00728306064042 1079 -29678.1078332 +0.00178571428571 0.13 0.00728306064042 1079 -45165.1717678 +0.00178571428571 0.16 0.00728306064042 1079 -66284.1482978 +0.00178571428571 0.19 0.00728306064042 1079 -94025.2870814 +0.00178571428571 0.22 0.00728306064042 1079 -129406.62917 +0.00178571428571 0.25 0.00728306064042 1079 -173482.873566 +0.00178571428571 0.28 0.00728306064042 1079 -227356.220399 +0.00178571428571 0.31 0.00728306064042 1079 -292189.516122 +0.00178571428571 0.34 0.00728306064042 1079 -369222.152637 +0.00178571428571 0.37 0.00728306064042 1079 -459789.340471 +0.00178571428571 0.4 0.00728306064042 1079 -565345.603359 +0.00178571428571 0.43 0.00728306064042 1079 -687493.653701 +0.00178571428571 0.46 0.00728306064042 1079 -828020.244865 +0.00178571428571 0.49 0.00728306064042 1079 -988941.2185 +0.0016393442623 0.01 0.00728306064042 1079 -7359.78764399 +0.0016393442623 0.04 0.00728306064042 1079 -11604.8848507 +0.0016393442623 0.07 0.00728306064042 1079 -18546.4179384 +0.0016393442623 0.1 0.00728306064042 1079 -29104.5867194 +0.0016393442623 0.13 0.00728306064042 1079 -44210.232741 +0.0016393442623 0.16 0.00728306064042 1079 -64808.7035625 +0.0016393442623 0.19 0.00728306064042 1079 -91865.1449587 +0.0016393442623 0.22 0.00728306064042 1079 -126371.315041 +0.0016393442623 0.25 0.00728306064042 1079 -169354.067098 +0.0016393442623 0.28 0.00728306064042 1079 -221885.71727 +0.0016393442623 0.31 0.00728306064042 1079 -285096.603734 +0.0016393442623 0.34 0.00728306064042 1079 -360190.26291 +0.0016393442623 0.37 0.00728306064042 1079 -448461.806155 +0.0016393442623 0.4 0.00728306064042 1079 -551320.293221 +0.0016393442623 0.43 0.00728306064042 1079 -670316.190656 +0.0016393442623 0.46 0.00728306064042 1079 -807175.410644 +0.0016393442623 0.49 0.00728306064042 1079 -963842.005149 +0.00151515151515 0.01 0.00728306064042 1079 -7336.03681782 +0.00151515151515 0.04 0.00728306064042 1079 -11477.2947149 +0.00151515151515 0.07 0.00728306064042 1079 -18248.8861499 +0.00151515151515 0.1 0.00728306064042 1079 -28548.5756334 +0.00151515151515 0.13 0.00728306064042 1079 -43284.3211126 +0.00151515151515 0.16 0.00728306064042 1079 -63377.9741728 +0.00151515151515 0.19 0.00728306064042 1079 -89770.3467316 +0.00151515151515 0.22 0.00728306064042 1079 -123427.732826 +0.00151515151515 0.25 0.00728306064042 1079 -165350.023875 +0.00151515151515 0.28 0.00728306064042 1079 -216580.621098 +0.00151515151515 0.31 0.00728306064042 1079 -278218.433949 +0.00151515151515 0.34 0.00728306064042 1079 -351432.365119 +0.00151515151515 0.37 0.00728306064042 1079 -437478.830768 +0.00151515151515 0.4 0.00728306064042 1079 -537723.063964 +0.00151515151515 0.43 0.00728306064042 1079 -653665.22204 +0.00151515151515 0.46 0.00728306064042 1079 -786972.698456 +0.00151515151515 0.49 0.00728306064042 1079 -939520.578814 +0.00140845070423 0.01 0.00728306064042 1079 -7313.06591821 +0.00140845070423 0.04 0.00728306064042 1079 -11353.8625393 +0.00140845070423 0.07 0.00728306064042 1079 -17960.9889715 +0.00140845070423 0.1 0.00728306064042 1079 -28010.4829753 +0.00140845070423 0.13 0.00728306064042 1079 -42388.1469028 +0.00140845070423 0.16 0.00728306064042 1079 -61993.0909759 +0.00140845070423 0.19 0.00728306064042 1079 -87742.5843275 +0.00140845070423 0.22 0.00728306064042 1079 -120578.297304 +0.00140845070423 0.25 0.00728306064042 1079 -161474.065447 +0.00140845070423 0.28 0.00728306064042 1079 -211445.367055 +0.00140845070423 0.31 0.00728306064042 1079 -271560.786361 +0.00140845070423 0.34 0.00728306064042 1079 -342955.839236 +0.00140845070423 0.37 0.00728306064042 1079 -426849.677258 +0.00140845070423 0.4 0.00728306064042 1079 -524565.372488 +0.00140845070423 0.43 0.00728306064042 1079 -637554.740075 +0.00140845070423 0.46 0.00728306064042 1079 -767429.009904 +0.00140845070423 0.49 0.00728306064042 1079 -915997.159747 +0.00131578947368 0.01 0.00728306064042 1079 -7290.87781901 +0.00131578947368 0.04 0.00728306064042 1079 -11234.6123033 diff --git a/experiments/plot3d.py b/experiments/plot3d.py index 64c144d..b99ef61 100644 --- a/experiments/plot3d.py +++ b/experiments/plot3d.py @@ -9,7 +9,7 @@ with open("out.log") as fh: am = max(values, key=lambda x: x[4]) am[0] = 1./am[0] print am - alpha, delta, beta, _ , l = zip(*values) + alpha, delta, beta, r , l = zip(*values) alpha = 1./np.array(alpha) fig = plt.figure(figsize=(12, 8)) diff --git a/experiments/process.py b/experiments/process.py index 68c3507..a432dab 100644 --- a/experiments/process.py +++ b/experiments/process.py @@ -9,18 +9,18 @@ from math import exp if __name__ == "__main__": if len(sys.argv) < 2: sys.exit("usage: {0} <file>".format(sys.argv[0])) - root_victims, victims, non_victims, age = load(open(sys.argv[1])) - alphas = 1. / np.arange(0., 1000., 100.) # parameter of the time component - deltas = np.arange(0.01, 0.5, 0.1) # parameter of the structural component - with open("out.log", "w") as fh: - for alpha, delta in product(alphas, deltas): - beta, roots, ll = ml(root_victims, victims, non_victims, age, alpha, delta) - print "\t".join(map(str, [1/alpha, delta, beta, roots, ll])) - fh.write("\t".join(map(str, [alpha, delta, beta, roots, ll])) + "\n") - fh.flush() + + # alphas = 1. / np.arange(1000., 10000., 50.) # parameter of the time component + # deltas = np.arange(0.01, 0.5, 0.03) # parameter of the structural component + # with open("out.log", "w") as fh: + # for alpha, delta in product(alphas, deltas): + # beta, roots, ll = ml(root_victims, victims, non_victims, age, alpha, delta) + # print "\t".join(map(str, [1/alpha, delta, beta, roots, ll])) + # fh.write("\t".join(map(str, [alpha, delta, beta, roots, ll])) + "\n") + # fh.flush() - # alpha = 100. - # delta = 0.2 - # beta, roots, ll = ml(root_victims, victims, non_victims, age, alpha, delta) - # print "\t".join(map(str, [1./alpha, delta, beta, roots, ll]))
\ No newline at end of file + alpha = 1/10. + delta = 0.28 + beta, roots, ll = ml(root_victims, victims, non_victims, age, alpha, delta) + print "\t".join(map(str, [1./alpha, delta, beta, roots, ll]))
\ No newline at end of file |
