From 8e09ca6ca68c71bdab65525b529e2adfa281823c Mon Sep 17 00:00:00 2001 From: Ben Green Date: Wed, 1 Jul 2015 00:49:23 -0400 Subject: Got predict-victims running in parallel, drastically reducing the time for each test. Also changed how we get the rankings of infected individuals each day. --- R Scripts/find-parents.R | 15 ++- R Scripts/generate-network.R | 40 +++--- R Scripts/predict-victims-plots.R | 9 +- R Scripts/predict-victims.R | 39 +++--- experiments/build_network.py | 3 +- experiments/ml2.so | Bin 123652 -> 123652 bytes experiments/out.log | 255 +++++--------------------------------- experiments/process.py | 42 +++---- 8 files changed, 113 insertions(+), 290 deletions(-) diff --git a/R Scripts/find-parents.R b/R Scripts/find-parents.R index 3ec8809..023d7ba 100644 --- a/R Scripts/find-parents.R +++ b/R Scripts/find-parents.R @@ -6,8 +6,8 @@ # source('criminal_cascades/R Scripts/structural.R') ##### Initialize parameters based on what ml2 found -alpha = 0.061 -delta = 0.082 +alpha = 0.18 +delta = 0.09 ##### Get weights edges = dag_dat_test[!is.na(dag_dat_test$t2),] @@ -21,20 +21,27 @@ weights = p/p_tilde edges$weight = weights ##### Find most likely parents -parents = data.frame(vic=0,Npars=0,par_rank=0) +parents = data.frame(vic=0,Npars=0,par_rank=0,rand_rank=0) vics = setdiff(vic_ids,seeds) +print(length(vics)) for (u in vics){ + if(which(vics==u) %% 500 == 0) print(which(vics==u)) u_parents = edges[edges$to==u,] u_parents = u_parents[order(u_parents$weight,decreasing=T),] Nparents = dim(u_parents)[1] infector = V(g)$infector[u] infectorID = which(u_parents$from==infector) - parents[which(vics==u),] = c(u, Nparents, infectorID) + randID = sample(1:Nparents,1) + parents[which(vics==u),] = c(u, Nparents, infectorID, randID) } ##### Get some summary statistics on how well +mean(parents$par_rank==1) median(parents$par_rank[parents$Npars>9]) median(parents$par_rank[parents$Npars>99]) +edges[edges$to==2847,] +## baseline alg +# for each vic, find potential parents, pick one at random diff --git a/R Scripts/generate-network.R b/R Scripts/generate-network.R index 3b40969..dab81a4 100644 --- a/R Scripts/generate-network.R +++ b/R Scripts/generate-network.R @@ -3,20 +3,20 @@ setwd("~/Documents/Cascade Project/") source('criminal_cascades/R Scripts/temporal.R') source('criminal_cascades/R Scripts/structural.R') -alpha = 1/100 -beta = 0.02 -delta = 0.15 +alpha = 1/10 +beta = 0.01 +delta = 0.25 # lmbda = 1/10 t_max = 1000 N = 5000 g = forest.fire.game(nodes=N, fw.prob=0.3, ambs=1, directed=F) -plot(g, vertex.size=5, vertex.label=NA) +plot(g, vertex.size=3, vertex.label=NA) V(g)$seed = runif(vcount(g))".format(sys.argv[0])) root_victims, victims, non_victims, age = load(open(sys.argv[1])) - # alphas = np.arange(1e-3, 1e-2, 8e-4) # parameter of the time component - alphas = np.logspace(-4,-1,num=15) - # deltas = np.arange(0.001, 0.3, 0.008) # parameter of the structural component - deltas = np.logspace(-4,-1.7,num=15) - with open("out.log", "w") as fh: - for alpha, delta in product(alphas, deltas): - beta, roots, ll = ml3(root_victims, victims, non_victims, age, alpha, delta) - print "\t".join(map(str, [alpha, delta, beta, roots, ll])) - fh.write("\t".join(map(str, [alpha, delta, beta, roots, ll])) + "\n") - fh.flush() - - # alphas = np.arange(.04, .075, .003) # parameter of the time component - # # alphas = np.logspace(-4,-1,num=20) - # deltas = np.arange(.07, .11, .003) # parameter of the structural component - # # deltas = np.logspace(-2,-.5,num=20) - # lmbda = 0.10#np.logspace(-12,-3,num=10) + # # alphas = np.arange(1e-3, 1e-2, 8e-4) # parameter of the time component + # alphas = np.logspace(-4,-1,num=15) + # # deltas = np.arange(0.001, 0.3, 0.008) # parameter of the structural component + # deltas = np.logspace(-4,-1.7,num=15) # with open("out.log", "w") as fh: # for alpha, delta in product(alphas, deltas): - # lmbda, roots, ll = ml2(root_victims, victims, non_victims, alpha, delta, lmbda) - # print "\t".join(map(str, [alpha, delta, lmbda, roots, ll])) - # fh.write("\t".join(map(str, [alpha, delta, lmbda, roots, ll])) + "\n") + # beta, roots, ll = ml3(root_victims, victims, non_victims, age, alpha, delta) + # print "\t".join(map(str, [alpha, delta, beta, roots, ll])) + # fh.write("\t".join(map(str, [alpha, delta, beta, roots, ll])) + "\n") # fh.flush() - # alpha = 0.061 - # delta = 0.082 + alphas = np.arange(.15, .25, .01) # parameter of the time component + # alphas = np.logspace(-4,-.5,num=15) + deltas = np.arange(.08, .1, .01) # parameter of the structural component + # deltas = np.logspace(-2,-.1,num=15) + lmbda = 0.10#np.logspace(-12,-3,num=10) + with open("out.log", "w") as fh: + for alpha, delta in product(alphas, deltas): + lmbda, roots, ll = ml2(root_victims, victims, non_victims, alpha, delta, lmbda) + print "\t".join(map(str, [alpha, delta, lmbda, roots, ll])) + fh.write("\t".join(map(str, [alpha, delta, lmbda, roots, ll])) + "\n") + fh.flush() + + # alpha = .016 + # delta = 0.077 # beta, roots, ll = ml2(root_victims, victims, non_victims, alpha, delta, 1.) # print "\t".join(map(str, [alpha, delta, beta, roots, ll])) \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 375f29ab4306821c888fd9ef0637f9ab2879e375 Mon Sep 17 00:00:00 2001 From: Ben Green Date: Thu, 2 Jul 2015 00:41:49 -0400 Subject: in which the model works!! --- R Scripts/create-hyper-lcc.R | 126 - R Scripts/generate-hyper-lcc.R | 126 + R Scripts/predict-victims-plots.R | 3 +- experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o | Bin 299264 -> 306196 bytes .../build/temp.macosx-10.6-x86_64-2.7/ml3.o | Bin 285944 -> 275440 bytes experiments/build_network.py | 5 +- experiments/ml.c | 3145 ++++++++------------ experiments/ml.pyx | 56 +- experiments/ml.so | Bin 108744 -> 119284 bytes experiments/ml3.c | 966 +++--- experiments/ml3.pyx | 27 +- experiments/ml3.so | Bin 110884 -> 106596 bytes experiments/out.log | 130 +- experiments/process.py | 38 +- 14 files changed, 2047 insertions(+), 2575 deletions(-) delete mode 100644 R Scripts/create-hyper-lcc.R create mode 100644 R Scripts/generate-hyper-lcc.R diff --git a/R Scripts/create-hyper-lcc.R b/R Scripts/create-hyper-lcc.R deleted file mode 100644 index 786b694..0000000 --- a/R Scripts/create-hyper-lcc.R +++ /dev/null @@ -1,126 +0,0 @@ -library(igraph) -setwd("~/Documents/Cascade Project/") -load('Raw Data/lcc.RData') - -lcc_verts = get.data.frame(lcc,'vertices') -lcc_edges = get.data.frame(lcc,'edges') - - -##### Create new vertices dataframe -cols = c('id','ir_no','sex','race','dob','age.arrest','arrest.day', - 'gang.member','gang.name','faction.name') -hyp_lcc_verts = data.frame(matrix(ncol=length(cols)+1,nrow=0)) -colnames(hyp_lcc_verts) = c(cols,'spawn.date') - -ptm = proc.time() -ri = 1 -for (i in 1:dim(lcc_verts)[1]){ - if (i%%10000==0) print(i) - if (lcc_verts$vic[i]){ - if (lcc_verts$vic.nonfatal[i]>0){ - # create nodes for each nonfatal shooting - for (nf in 1:lcc_verts$vic.nonfatal[i]){ - hyp_lcc_verts[ri,cols] = lcc_verts[i,cols] - hyp_lcc_verts$id[ri] = ri - hyp_lcc_verts$vic[ri] = T - hyp_lcc_verts$vic.type[ri] = 'nonfatal' - if(nf==1){ - hyp_lcc_verts$vic.day[ri] = lcc_verts$nonfatal_day_1[i] - hyp_lcc_verts$spawn.date[ri] = 0 - } else if(nf==2){ - hyp_lcc_verts$vic.day[ri] = lcc_verts$nonfatal_day_2[i] - hyp_lcc_verts$spawn.date[ri] = lcc_verts$nonfatal_day_1[i] - } else if(nf==3){ - hyp_lcc_verts$vic.day[ri] = lcc_verts$nonfatal_day_3[i] - hyp_lcc_verts$spawn.date[ri] = lcc_verts$nonfatal_day_2[i] - } else if(nf==4){ - hyp_lcc_verts$vic.day[ri] = lcc_verts$nonfatal_day_4[i] - hyp_lcc_verts$spawn.date[ri] = lcc_verts$nonfatal_day_3[i] - } else if(nf==5){ - hyp_lcc_verts$vic.day[ri] = lcc_verts$nonfatal_day_5[i] - hyp_lcc_verts$spawn.date[ri] = lcc_verts$nonfatal_day_4[i] - } - ri = ri+1 - } - # if no fatal infection, create uninfected duplicate - if (!lcc_verts$vic.fatal[i]){ - hyp_lcc_verts[ri,cols] = lcc_verts[i,cols] - hyp_lcc_verts$id[ri] = ri - hyp_lcc_verts$vic[ri] = F - hyp_lcc_verts$vic.type[ri] = NA - hyp_lcc_verts$vic.day[ri] = NA - hyp_lcc_verts$spawn.date[ri] = max(lcc_verts$nonfatal_day_1[i],lcc_verts$nonfatal_day_2[i], - lcc_verts$nonfatal_day_3[i],lcc_verts$nonfatal_day_4[i], - lcc_verts$nonfatal_day_5[i],na.rm=T) - ri = ri+1 - } - } - # create a node for each fatal shooting - # if also nonfatal shootings, spawn at last nonfatal shooting - if (lcc_verts$vic.fatal[i]){ - hyp_lcc_verts[ri,cols] = lcc_verts[i,cols] - hyp_lcc_verts$id[ri] = ri - hyp_lcc_verts$vic[ri] = T - hyp_lcc_verts$vic.type[ri] = 'fatal' - hyp_lcc_verts$vic.day[ri] = lcc_verts$fatal_day[i] - if (lcc_verts$vic.nonfatal[i]>0){ - hyp_lcc_verts$spawn.date[ri] = max(lcc_verts$nonfatal_day_1[i],lcc_verts$nonfatal_day_2[i], - lcc_verts$nonfatal_day_3[i],lcc_verts$nonfatal_day_4[i], - lcc_verts$nonfatal_day_5[i],na.rm=T) - } else { - hyp_lcc_verts$spawn.date[ri] = 0 - } - ri = ri+1 - } - } - # create an uninfected node for each uninfected person - else{ - hyp_lcc_verts[ri,cols] = lcc_verts[i,cols] - hyp_lcc_verts$id[ri] = ri - hyp_lcc_verts$vic[ri] = F - hyp_lcc_verts$vic.type[ri] = NA - hyp_lcc_verts$vic.day[ri] = NA - hyp_lcc_verts$spawn.date[ri] = 0 - ri = ri+1 - } -} -print(proc.time()-ptm) # 1.5 hrs -row.names(hyp_lcc_verts) = NULL -n.nodes = sum(sum(V(lcc)$vic.fatal),sum(V(lcc)$vic.nonfatal), - sum(V(lcc)$vic.nonfatal>0 & !V(lcc)$vic.fatal),sum(V(lcc)$vic==FALSE)) -stopifnot(dim(hyp_lcc_verts)[1] == n.nodes) - -##### Create new edgelist -print('Edges') -hyp_lcc_edges = data.frame(from=0, to=0, weight=0) -ei = 1 -ptm = proc.time() -for(i in 1:dim(hyp_lcc_verts)[1]){ - if (i%%10000==0) print(i) - ego_id = hyp_lcc_verts$id[i] - ego_ir = hyp_lcc_verts$ir_no[i] - alter_irs = union(lcc_edges$from[which(lcc_edges$to==ego_ir)], - lcc_edges$to[which(lcc_edges$from==ego_ir)]) -# alter_irs = union(ego_ir, alter_irs) # add edges to other infected selves - alter_ids = hyp_lcc_verts$id[which(hyp_lcc_verts$ir_no %in% alter_irs)] - alter_ids = alter_ids[ego_id0){ + # create nodes for each nonfatal shooting + for (nf in 1:lcc_verts$vic.nonfatal[i]){ + hyp_lcc_verts[ri,cols] = lcc_verts[i,cols] + hyp_lcc_verts$id[ri] = ri + hyp_lcc_verts$vic[ri] = T + hyp_lcc_verts$vic.type[ri] = 'nonfatal' + if(nf==1){ + hyp_lcc_verts$vic.day[ri] = lcc_verts$nonfatal_day_1[i] + hyp_lcc_verts$spawn.date[ri] = 0 + } else if(nf==2){ + hyp_lcc_verts$vic.day[ri] = lcc_verts$nonfatal_day_2[i] + hyp_lcc_verts$spawn.date[ri] = lcc_verts$nonfatal_day_1[i] + } else if(nf==3){ + hyp_lcc_verts$vic.day[ri] = lcc_verts$nonfatal_day_3[i] + hyp_lcc_verts$spawn.date[ri] = lcc_verts$nonfatal_day_2[i] + } else if(nf==4){ + hyp_lcc_verts$vic.day[ri] = lcc_verts$nonfatal_day_4[i] + hyp_lcc_verts$spawn.date[ri] = lcc_verts$nonfatal_day_3[i] + } else if(nf==5){ + hyp_lcc_verts$vic.day[ri] = lcc_verts$nonfatal_day_5[i] + hyp_lcc_verts$spawn.date[ri] = lcc_verts$nonfatal_day_4[i] + } + ri = ri+1 + } + # if no fatal infection, create uninfected duplicate + if (!lcc_verts$vic.fatal[i]){ + hyp_lcc_verts[ri,cols] = lcc_verts[i,cols] + hyp_lcc_verts$id[ri] = ri + hyp_lcc_verts$vic[ri] = F + hyp_lcc_verts$vic.type[ri] = NA + hyp_lcc_verts$vic.day[ri] = NA + hyp_lcc_verts$spawn.date[ri] = max(lcc_verts$nonfatal_day_1[i],lcc_verts$nonfatal_day_2[i], + lcc_verts$nonfatal_day_3[i],lcc_verts$nonfatal_day_4[i], + lcc_verts$nonfatal_day_5[i],na.rm=T) + ri = ri+1 + } + } + # create a node for each fatal shooting + # if also nonfatal shootings, spawn at last nonfatal shooting + if (lcc_verts$vic.fatal[i]){ + hyp_lcc_verts[ri,cols] = lcc_verts[i,cols] + hyp_lcc_verts$id[ri] = ri + hyp_lcc_verts$vic[ri] = T + hyp_lcc_verts$vic.type[ri] = 'fatal' + hyp_lcc_verts$vic.day[ri] = lcc_verts$fatal_day[i] + if (lcc_verts$vic.nonfatal[i]>0){ + hyp_lcc_verts$spawn.date[ri] = max(lcc_verts$nonfatal_day_1[i],lcc_verts$nonfatal_day_2[i], + lcc_verts$nonfatal_day_3[i],lcc_verts$nonfatal_day_4[i], + lcc_verts$nonfatal_day_5[i],na.rm=T) + } else { + hyp_lcc_verts$spawn.date[ri] = 0 + } + ri = ri+1 + } + } + # create an uninfected node for each uninfected person + else{ + hyp_lcc_verts[ri,cols] = lcc_verts[i,cols] + hyp_lcc_verts$id[ri] = ri + hyp_lcc_verts$vic[ri] = F + hyp_lcc_verts$vic.type[ri] = NA + hyp_lcc_verts$vic.day[ri] = NA + hyp_lcc_verts$spawn.date[ri] = 0 + ri = ri+1 + } +} +print(proc.time()-ptm) # 1.5 hrs +row.names(hyp_lcc_verts) = NULL +n.nodes = sum(sum(V(lcc)$vic.fatal),sum(V(lcc)$vic.nonfatal), + sum(V(lcc)$vic.nonfatal>0 & !V(lcc)$vic.fatal),sum(V(lcc)$vic==FALSE)) +stopifnot(dim(hyp_lcc_verts)[1] == n.nodes) + +##### Create new edgelist +print('Edges') +hyp_lcc_edges = data.frame(from=0, to=0, weight=0) +ei = 1 +ptm = proc.time() +for(i in 1:dim(hyp_lcc_verts)[1]){ + if (i%%10000==0) print(i) + ego_id = hyp_lcc_verts$id[i] + ego_ir = hyp_lcc_verts$ir_no[i] + alter_irs = union(lcc_edges$from[which(lcc_edges$to==ego_ir)], + lcc_edges$to[which(lcc_edges$from==ego_ir)]) +# alter_irs = union(ego_ir, alter_irs) # add edges to other infected selves + alter_ids = hyp_lcc_verts$id[which(hyp_lcc_verts$ir_no %in% alter_irs)] + alter_ids = alter_ids[ego_id - typedef struct { int code_line; PyCodeObject* code_object; @@ -1160,41 +1122,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); -static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); - -static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); - -static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); - -#define __Pyx_Generator_USED -#include -#include -typedef PyObject *(*__pyx_generator_body_t)(PyObject *, PyObject *); -typedef struct { - PyObject_HEAD - __pyx_generator_body_t body; - PyObject *closure; - PyObject *exc_type; - PyObject *exc_value; - PyObject *exc_traceback; - PyObject *gi_weakreflist; - PyObject *classobj; - PyObject *yieldfrom; - PyObject *gi_name; - PyObject *gi_qualname; - int resume_label; - char is_running; -} __pyx_GeneratorObject; -static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body, - PyObject *closure, PyObject *name, PyObject *qualname); -static int __pyx_Generator_init(void); -static int __Pyx_Generator_clear(PyObject* self); -#if 1 || PY_VERSION_HEX < 0x030300B0 -static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue); -#else -#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue) -#endif - static int __Pyx_check_binary_version(void); #if !defined(__Pyx_PyIdentifier_FromString) @@ -1242,8 +1169,6 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, cha /* Module declarations from 'libc.math' */ /* Module declarations from 'ml' */ -static PyTypeObject *__pyx_ptype_2ml___pyx_scope_struct__ml = 0; -static PyTypeObject *__pyx_ptype_2ml___pyx_scope_struct_1_genexpr = 0; static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_success(int, int, __pyx_t_2ml_DTYPE_t, __pyx_t_2ml_DTYPE_t, __pyx_t_2ml_DTYPE_t, __pyx_t_2ml_DTYPE_t, __pyx_t_2ml_DTYPE_t); /*proto*/ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_failure(int, int, __pyx_t_2ml_DTYPE_t, __pyx_t_2ml_DTYPE_t, __pyx_t_2ml_DTYPE_t, __pyx_t_2ml_DTYPE_t, __pyx_t_2ml_DTYPE_t); /*proto*/ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_2ml_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; @@ -1253,16 +1178,12 @@ int __pyx_module_is_main_ml = 0; /* Implementation of 'ml' */ static PyObject *__pyx_builtin_enumerate; static PyObject *__pyx_builtin_sum; -static PyObject *__pyx_builtin_max; static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_RuntimeError; -static PyObject *__pyx_pf_2ml_2ml_genexpr(PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_root_victims, PyObject *__pyx_v_victims, PyObject *__pyx_v_non_victims, CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_age, __pyx_t_2ml_DTYPE_t __pyx_v_alpha, __pyx_t_2ml_DTYPE_t __pyx_v_delta); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ -static PyObject *__pyx_tp_new_2ml___pyx_scope_struct__ml(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_2ml___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static char __pyx_k_B[] = "B"; static char __pyx_k_H[] = "H"; static char __pyx_k_I[] = "I"; @@ -1277,6 +1198,7 @@ static char __pyx_k_h[] = "h"; static char __pyx_k_i[] = "i"; static char __pyx_k_l[] = "l"; static char __pyx_k_q[] = "q"; +static char __pyx_k_s[] = "s"; static char __pyx_k_t[] = "t"; static char __pyx_k_Zd[] = "Zd"; static char __pyx_k_Zf[] = "Zf"; @@ -1289,31 +1211,30 @@ 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_dts[] = "dts"; 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_main[] = "__main__"; -static char __pyx_k_send[] = "send"; +static char __pyx_k_prnt[] = "prnt"; +static char __pyx_k_prob[] = "prob"; static char __pyx_k_test[] = "__test__"; static char __pyx_k_DTYPE[] = "DTYPE"; static char __pyx_k_alpha[] = "alpha"; -static char __pyx_k_close[] = "close"; static char __pyx_k_delta[] = "delta"; +static char __pyx_k_dists[] = "dists"; static char __pyx_k_dtype[] = "dtype"; static char __pyx_k_numpy[] = "numpy"; static char __pyx_k_probs[] = "probs"; static char __pyx_k_range[] = "range"; static char __pyx_k_roots[] = "roots"; -static char __pyx_k_throw[] = "throw"; +static char __pyx_k_seeds[] = "seeds"; static char __pyx_k_zeros[] = "zeros"; static char __pyx_k_arange[] = "arange"; static char __pyx_k_import[] = "__import__"; static char __pyx_k_thresh[] = "thresh"; static char __pyx_k_float64[] = "float64"; -static char __pyx_k_genexpr[] = "genexpr"; static char __pyx_k_n_nodes[] = "n_nodes"; static char __pyx_k_n_roots[] = "n_roots"; static char __pyx_k_parents[] = "parents"; @@ -1325,15 +1246,17 @@ static char __pyx_k_probs_nv[] = "probs_nv"; static char __pyx_k_enumerate[] = "enumerate"; static char __pyx_k_max_roots[] = "max_roots"; static char __pyx_k_n_victims[] = "n_victims"; +static char __pyx_k_non_seeds[] = "non_seeds"; static char __pyx_k_successes[] = "successes"; static char __pyx_k_ValueError[] = "ValueError"; static char __pyx_k_itervalues[] = "itervalues"; +static char __pyx_k_parent_dts[] = "parent_dts"; static char __pyx_k_probs_fail[] = "probs_fail"; 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_parent_dists[] = "parent_dists"; static char __pyx_k_root_victims[] = "root_victims"; -static char __pyx_k_ml_locals_genexpr[] = "ml..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"; static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; @@ -1351,18 +1274,17 @@ static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_age; static PyObject *__pyx_n_s_alpha; static PyObject *__pyx_n_s_arange; -static PyObject *__pyx_n_s_args; static PyObject *__pyx_n_s_beta; static PyObject *__pyx_n_s_beta_add; -static PyObject *__pyx_n_s_close; static PyObject *__pyx_n_s_delta; static PyObject *__pyx_n_s_dist; +static PyObject *__pyx_n_s_dists; static PyObject *__pyx_n_s_dt; +static PyObject *__pyx_n_s_dts; static PyObject *__pyx_n_s_dtype; static PyObject *__pyx_n_s_enumerate; static PyObject *__pyx_n_s_failures; static PyObject *__pyx_n_s_float64; -static PyObject *__pyx_n_s_genexpr; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_import; static PyObject *__pyx_kp_s_inf; @@ -1370,43 +1292,47 @@ static PyObject *__pyx_n_s_itervalues; static PyObject *__pyx_n_s_l; static PyObject *__pyx_n_s_ll; static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_max; static PyObject *__pyx_n_s_max_beta; static PyObject *__pyx_n_s_max_beta_add; static PyObject *__pyx_n_s_max_roots; static PyObject *__pyx_n_s_ml; -static PyObject *__pyx_n_s_ml_locals_genexpr; static PyObject *__pyx_n_s_n_nodes; static PyObject *__pyx_n_s_n_roots; static PyObject *__pyx_n_s_n_victims; static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; +static PyObject *__pyx_n_s_non_seeds; static PyObject *__pyx_n_s_non_victims; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; +static PyObject *__pyx_n_s_parent_dists; +static PyObject *__pyx_n_s_parent_dts; static PyObject *__pyx_n_s_parents; +static PyObject *__pyx_n_s_prnt; +static PyObject *__pyx_n_s_prob; static PyObject *__pyx_n_s_probs; static PyObject *__pyx_n_s_probs_fail; static PyObject *__pyx_n_s_probs_nv; static PyObject *__pyx_n_s_range; static PyObject *__pyx_n_s_root_victims; static PyObject *__pyx_n_s_roots; -static PyObject *__pyx_n_s_send; +static PyObject *__pyx_n_s_s; +static PyObject *__pyx_n_s_seeds; static PyObject *__pyx_n_s_successes; static PyObject *__pyx_n_s_sum; static PyObject *__pyx_n_s_t; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_thresh; -static PyObject *__pyx_n_s_throw; static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; static PyObject *__pyx_n_s_victims; static PyObject *__pyx_n_s_w1; static PyObject *__pyx_n_s_w2; static PyObject *__pyx_n_s_w3; static PyObject *__pyx_n_s_zeros; -static PyObject *__pyx_float__2; -static PyObject *__pyx_float__002; -static PyObject *__pyx_float_0_001; +static PyObject *__pyx_float_1_; +static PyObject *__pyx_float__01; +static PyObject *__pyx_float_0_01; +static PyObject *__pyx_int_148152; static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; @@ -1436,33 +1362,33 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_success(int __pyx_v_dist, int __py /* "ml.pyx":13 * """weight for successful infection, exponential time model""" * cdef DTYPE_t structural, temporal, result - * structural = dist * log(delta) # <<<<<<<<<<<<<< - * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - * temporal = log(exp(alpha)-1.) - alpha*dt + * structural = delta ** dist # <<<<<<<<<<<<<< + * temporal = log(exp(alpha)-1.) - alpha*dt/7. + * result = log(structural) + temporal + */ + __pyx_v_structural = pow(__pyx_v_delta, ((__pyx_t_2ml_DTYPE_t)__pyx_v_dist)); + + /* "ml.pyx":14 + * cdef DTYPE_t structural, temporal, result + * structural = delta ** dist + * temporal = log(exp(alpha)-1.) - alpha*dt/7. # <<<<<<<<<<<<<< + * result = log(structural) + temporal + * return result */ - __pyx_v_structural = (__pyx_v_dist * log(__pyx_v_delta)); + __pyx_v_temporal = (log((exp(__pyx_v_alpha) - 1.)) - ((__pyx_v_alpha * __pyx_v_dt) / 7.)); /* "ml.pyx":15 - * structural = dist * log(delta) - * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - * temporal = log(exp(alpha)-1.) - alpha*dt # <<<<<<<<<<<<<< - * # temporal = 1 - exp(-alpha*dt) - * # if exp(-alpha*dt)==0.: print 'UNDERFLOW ERROR' - */ - __pyx_v_temporal = (log((exp(__pyx_v_alpha) - 1.)) - (__pyx_v_alpha * __pyx_v_dt)); - - /* "ml.pyx":19 - * # 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 # <<<<<<<<<<<<<< - * # print 'st', structural, temporal + * structural = delta ** dist + * temporal = log(exp(alpha)-1.) - alpha*dt/7. + * result = log(structural) + temporal # <<<<<<<<<<<<<< * return result + * */ - __pyx_v_result = (__pyx_v_structural + __pyx_v_temporal); + __pyx_v_result = (log(__pyx_v_structural) + __pyx_v_temporal); - /* "ml.pyx":21 - * result = structural + temporal - * # print 'st', structural, temporal + /* "ml.pyx":16 + * temporal = log(exp(alpha)-1.) - alpha*dt/7. + * result = log(structural) + temporal * return result # <<<<<<<<<<<<<< * * cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, @@ -1484,7 +1410,7 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_success(int __pyx_v_dist, int __py return __pyx_r; } -/* "ml.pyx":23 +/* "ml.pyx":18 * return result * * cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<< @@ -1500,36 +1426,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":22 * """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 = exp(-alpha * dt) + * temporal = exp(-alpha * dt/7.) + * result = log(1. - structural + structural * temporal) */ __pyx_v_structural = pow(__pyx_v_delta, ((__pyx_t_2ml_DTYPE_t)__pyx_v_dist)); - /* "ml.pyx":29 + /* "ml.pyx":23 + * cdef DTYPE_t structural, temporal, result * structural = delta ** dist - * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - * temporal = exp(-alpha * dt) # <<<<<<<<<<<<<< - * # temporal = 1. - 1. / (1. + dt/alpha)**0.01 + * temporal = exp(-alpha * dt/7.) # <<<<<<<<<<<<<< * result = log(1. - structural + structural * temporal) + * return result */ - __pyx_v_temporal = exp(((-__pyx_v_alpha) * __pyx_v_dt)); + __pyx_v_temporal = exp((((-__pyx_v_alpha) * __pyx_v_dt) / 7.)); - /* "ml.pyx":31 - * temporal = exp(-alpha * dt) - * # temporal = 1. - 1. / (1. + dt/alpha)**0.01 + /* "ml.pyx":24 + * structural = delta ** dist + * temporal = exp(-alpha * dt/7.) * result = log(1. - structural + structural * temporal) # <<<<<<<<<<<<<< - * # print 'stnv', structural, temporal * return result + * */ __pyx_v_result = log(((1. - __pyx_v_structural) + (__pyx_v_structural * __pyx_v_temporal))); - /* "ml.pyx":33 + /* "ml.pyx":25 + * temporal = exp(-alpha * dt/7.) * 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, @@ -1537,7 +1463,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":18 * return result * * cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<< @@ -1551,7 +1477,7 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_failure(int __pyx_v_dist, int __py return __pyx_r; } -/* "ml.pyx":35 +/* "ml.pyx":27 * return result * * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<< @@ -1599,31 +1525,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 = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __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 = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __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 = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __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 = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __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 = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __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 = 35; __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 = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { goto __pyx_L5_argtuple_error; @@ -1638,21 +1564,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 = 35; __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 = 36; __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 = 36; __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 = 27; __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 = 28; __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 = 28; __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 = 35; __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 = 27; __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 = 35; __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 = 35; __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 = 35; __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 = 27; __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 = 27; __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 = 27; __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 */ @@ -1663,167 +1589,45 @@ static PyObject *__pyx_pw_2ml_1ml(PyObject *__pyx_self, PyObject *__pyx_args, Py __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ - -/* "ml.pyx":59 - * 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 - */ - -static PyObject *__pyx_pf_2ml_2ml_genexpr(PyObject *__pyx_self) { - struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *__pyx_cur_scope; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("genexpr", 0); - __pyx_cur_scope = (struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *)__pyx_tp_new_2ml___pyx_scope_struct_1_genexpr(__pyx_ptype_2ml___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL); - if (unlikely(!__pyx_cur_scope)) { - __Pyx_RefNannyFinishContext(); - return NULL; - } - __Pyx_GOTREF(__pyx_cur_scope); - __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_2ml___pyx_scope_struct__ml *) __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 = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_cur_scope); - __Pyx_RefNannyFinishContext(); - return (PyObject *) gen; - } - - /* function exit code */ - __pyx_L1_error:; - __Pyx_AddTraceback("ml.ml.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ -{ - struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *)__pyx_generator->closure); - PyObject *__pyx_r = NULL; - Py_ssize_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - Py_ssize_t __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("None", 0); - switch (__pyx_generator->resume_label) { - case 0: goto __pyx_L3_first_run; - case 1: goto __pyx_L6_resume_from_yield; - default: /* CPython raises the right error here */ - __Pyx_RefNannyFinishContext(); - return NULL; - } - __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __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 = 59; __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 = 59; __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 = 59; __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); - __Pyx_GIVEREF(__pyx_t_4); - __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 = 59; __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 = 59; __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 = 59; __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 = 59; __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; - __pyx_t_5 = 0; - __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; - __Pyx_XGIVEREF(__pyx_t_2); - __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; - __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - /* return from generator, yielding value */ - __pyx_generator->resume_label = 1; - return __pyx_r; - __pyx_L6_resume_from_yield:; - __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; - __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - __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 = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* function exit code */ - PyErr_SetNone(PyExc_StopIteration); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_L0:; - __Pyx_XDECREF(__pyx_r); - __pyx_generator->resume_label = -1; - __Pyx_Generator_clear((PyObject*)__pyx_generator); - __Pyx_RefNannyFinishContext(); - return NULL; -} - -/* "ml.pyx":35 - * return result - * - * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<< - * DTYPE_t alpha, DTYPE_t delta): - * cdef: - */ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_root_victims, PyObject *__pyx_v_victims, PyObject *__pyx_v_non_victims, CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_age, __pyx_t_2ml_DTYPE_t __pyx_v_alpha, __pyx_t_2ml_DTYPE_t __pyx_v_delta) { - struct __pyx_obj_2ml___pyx_scope_struct__ml *__pyx_cur_scope; int __pyx_v_n_roots; int __pyx_v_n_victims; - int __pyx_v_n_nodes; int __pyx_v_roots; int __pyx_v_i; int __pyx_v_dist; int __pyx_v_dt; + int __pyx_v_l; __pyx_t_2ml_DTYPE_t __pyx_v_beta; __pyx_t_2ml_DTYPE_t __pyx_v_ll; __pyx_t_2ml_DTYPE_t __pyx_v_beta_add; __pyx_t_2ml_DTYPE_t __pyx_v_max_beta; __pyx_t_2ml_DTYPE_t __pyx_v_max_beta_add; PyObject *__pyx_v_parents = 0; + PyObject *__pyx_v_failures = 0; + PyObject *__pyx_v_successes = 0; + PyObject *__pyx_v_n_nodes = NULL; PyArrayObject *__pyx_v_probs = 0; PyArrayObject *__pyx_v_probs_fail = 0; + PyArrayObject *__pyx_v_parent_dists = 0; + PyArrayObject *__pyx_v_parent_dts = 0; PyArrayObject *__pyx_v_probs_nv = 0; + PyObject *__pyx_v_dists = NULL; + PyObject *__pyx_v_dts = NULL; + PyObject *__pyx_v_s = NULL; + PyObject *__pyx_v_prob = NULL; double __pyx_v_thresh; + PyObject *__pyx_v_seeds = NULL; + PyObject *__pyx_v_non_seeds = NULL; int __pyx_v_max_roots; + CYTHON_UNUSED PyObject *__pyx_v_prnt = NULL; PyObject *__pyx_v_w1 = NULL; PyObject *__pyx_v_w2 = NULL; PyObject *__pyx_v_w3 = NULL; + __Pyx_LocalBuf_ND __pyx_pybuffernd_parent_dists; + __Pyx_Buffer __pyx_pybuffer_parent_dists; + __Pyx_LocalBuf_ND __pyx_pybuffernd_parent_dts; + __Pyx_Buffer __pyx_pybuffer_parent_dts; __Pyx_LocalBuf_ND __pyx_pybuffernd_probs; __Pyx_Buffer __pyx_pybuffer_probs; __Pyx_LocalBuf_ND __pyx_pybuffernd_probs_fail; @@ -1841,36 +1645,37 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ PyArrayObject *__pyx_t_7 = NULL; PyArrayObject *__pyx_t_8 = NULL; PyArrayObject *__pyx_t_9 = NULL; - int __pyx_t_10; - int __pyx_t_11; + PyArrayObject *__pyx_t_10 = NULL; + PyArrayObject *__pyx_t_11 = NULL; int __pyx_t_12; - Py_ssize_t __pyx_t_13; - PyObject *__pyx_t_14 = NULL; - PyObject *__pyx_t_15 = NULL; + int __pyx_t_13; + int __pyx_t_14; + Py_ssize_t __pyx_t_15; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; - PyObject *(*__pyx_t_20)(PyObject *); - int __pyx_t_21; - __pyx_t_2ml_DTYPE_t __pyx_t_22; - __pyx_t_2ml_DTYPE_t __pyx_t_23; - __pyx_t_2ml_DTYPE_t __pyx_t_24; - int __pyx_t_25; - int __pyx_t_26; - double __pyx_t_27; - PyObject *(*__pyx_t_28)(PyObject *); - int __pyx_t_29; + PyObject *__pyx_t_20 = NULL; + PyObject *__pyx_t_21 = NULL; + PyObject *__pyx_t_22 = NULL; + PyObject *(*__pyx_t_23)(PyObject *); + int __pyx_t_24; + __pyx_t_2ml_DTYPE_t __pyx_t_25; + __pyx_t_2ml_DTYPE_t __pyx_t_26; + __pyx_t_2ml_DTYPE_t __pyx_t_27; + int __pyx_t_28; + double __pyx_t_29; + int __pyx_t_30; + int __pyx_t_31; + int __pyx_t_32; + int __pyx_t_33; + int __pyx_t_34; + int __pyx_t_35; + PyObject *(*__pyx_t_36)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("ml", 0); - __pyx_cur_scope = (struct __pyx_obj_2ml___pyx_scope_struct__ml *)__pyx_tp_new_2ml___pyx_scope_struct__ml(__pyx_ptype_2ml___pyx_scope_struct__ml, __pyx_empty_tuple, NULL); - if (unlikely(!__pyx_cur_scope)) { - __Pyx_RefNannyFinishContext(); - return NULL; - } - __Pyx_GOTREF(__pyx_cur_scope); __pyx_pybuffer_probs.pybuffer.buf = NULL; __pyx_pybuffer_probs.refcount = 0; __pyx_pybuffernd_probs.data = NULL; @@ -1879,12 +1684,20 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_pybuffer_probs_fail.refcount = 0; __pyx_pybuffernd_probs_fail.data = NULL; __pyx_pybuffernd_probs_fail.rcbuffer = &__pyx_pybuffer_probs_fail; + __pyx_pybuffer_parent_dists.pybuffer.buf = NULL; + __pyx_pybuffer_parent_dists.refcount = 0; + __pyx_pybuffernd_parent_dists.data = NULL; + __pyx_pybuffernd_parent_dists.rcbuffer = &__pyx_pybuffer_parent_dists; + __pyx_pybuffer_parent_dts.pybuffer.buf = NULL; + __pyx_pybuffer_parent_dts.refcount = 0; + __pyx_pybuffernd_parent_dts.data = NULL; + __pyx_pybuffernd_parent_dts.rcbuffer = &__pyx_pybuffer_parent_dts; __pyx_pybuffer_probs_nv.pybuffer.buf = NULL; __pyx_pybuffer_probs_nv.refcount = 0; __pyx_pybuffernd_probs_nv.data = NULL; __pyx_pybuffernd_probs_nv.rcbuffer = &__pyx_pybuffer_probs_nv; - /* "ml.pyx":41 + /* "ml.pyx":33 * DTYPE_t beta, ll, beta_add, max_beta, max_beta_add * list parents, failures, successes * n_roots, n_victims = len(root_victims), len(victims) # <<<<<<<<<<<<<< @@ -1893,63 +1706,64 @@ 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 = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __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 = 41; __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 = 33; __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 = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __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 = 41; __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 = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_n_roots = __pyx_t_1; __pyx_v_n_victims = __pyx_t_2; - /* "ml.pyx":42 + /* "ml.pyx":34 * list parents, failures, successes * n_roots, n_victims = len(root_victims), len(victims) * n_nodes = 148152 # <<<<<<<<<<<<<< * cdef: * np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE) */ - __pyx_v_n_nodes = 148152; + __Pyx_INCREF(__pyx_int_148152); + __pyx_v_n_nodes = __pyx_int_148152; - /* "ml.pyx":44 + /* "ml.pyx":36 * 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) + * np.ndarray[DTYPE_t] parent_dists = np.zeros(n_victims, dtype=DTYPE) */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __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 = 36; __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 = 44; __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 = 36; __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 = 44; __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 = 36; __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 = 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 = 36; __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 = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __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 = 44; __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 = 36; __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 = 44; __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 = 36; __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 = 44; __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 = 36; __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 = 44; __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 = 36; __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 = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __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]; } } @@ -1957,43 +1771,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":45 + /* "ml.pyx":37 * 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) - * + * np.ndarray[DTYPE_t] parent_dists = np.zeros(n_victims, dtype=DTYPE) + * np.ndarray[DTYPE_t] parent_dts = np.zeros(n_victims, dtype=DTYPE) */ - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __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 = 37; __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 = 45; __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 = 37; __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 = 45; __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 = 37; __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 = 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 = 37; __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 = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __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 = 45; __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 = 37; __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 = 45; __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 = 37; __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 = 45; __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 = 37; __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 = 45; __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 = 37; __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 = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __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]; } } @@ -2001,829 +1815,1304 @@ 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":46 + /* "ml.pyx":38 * 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 + * np.ndarray[DTYPE_t] parent_dists = np.zeros(n_victims, dtype=DTYPE) # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t] parent_dts = np.zeros(n_victims, dtype=DTYPE) + * np.ndarray[DTYPE_t] probs_nv = np.zeros(len(non_victims), dtype=DTYPE) */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __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 = 38; __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 = 46; __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 = 38; __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 = 46; __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 = 46; __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 = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_victims); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __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 = 46; __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 = 38; __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 = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __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 = 46; __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 = 38; __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 = 46; __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 = 38; __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 = 46; __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 = 38; __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 = 46; __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 = 38; __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 = 46; __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]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_parent_dists.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_parent_dists = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_parent_dists.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_parent_dists.diminfo[0].strides = __pyx_pybuffernd_parent_dists.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_parent_dists.diminfo[0].shape = __pyx_pybuffernd_parent_dists.rcbuffer->pybuffer.shape[0]; } } __pyx_t_9 = 0; - __pyx_v_probs_nv = ((PyArrayObject *)__pyx_t_3); + __pyx_v_parent_dists = ((PyArrayObject *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "ml.pyx":39 + * np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE) + * np.ndarray[DTYPE_t] parent_dists = np.zeros(n_victims, dtype=DTYPE) + * np.ndarray[DTYPE_t] parent_dts = 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 = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_parent_dts.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) { + __pyx_v_parent_dts = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_parent_dts.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_parent_dts.diminfo[0].strides = __pyx_pybuffernd_parent_dts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_parent_dts.diminfo[0].shape = __pyx_pybuffernd_parent_dts.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_10 = 0; + __pyx_v_parent_dts = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + + /* "ml.pyx":40 + * np.ndarray[DTYPE_t] parent_dists = np.zeros(n_victims, dtype=DTYPE) + * np.ndarray[DTYPE_t] parent_dts = np.zeros(n_victims, dtype=DTYPE) + * np.ndarray[DTYPE_t] probs_nv = np.zeros(len(non_victims), dtype=DTYPE) # <<<<<<<<<<<<<< + * + * # loop through victims + */ + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __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 = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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 = 40; __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 = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __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 = 40; __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 = 40; __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 = 40; __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 = 40; __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 = 40; __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 = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_probs_nv.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__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 = 40; __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]; + } + } + __pyx_t_11 = 0; + __pyx_v_probs_nv = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; - /* "ml.pyx":49 + /* "ml.pyx":43 * * # loop through victims * for i, parents in enumerate(victims.itervalues()): # <<<<<<<<<<<<<< * # for each victim node i, compute the probability that all its parents * # fail to infect it, also computes the probability that its most */ - __pyx_t_10 = 0; + __pyx_t_12 = 0; __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 = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __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 = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_3); - __pyx_t_3 = __pyx_t_4; - __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_dict_iterator(__pyx_v_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_1), (&__pyx_t_13)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_4); + __pyx_t_4 = __pyx_t_6; + __pyx_t_6 = 0; 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 = 49; __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 = 49; __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); + __pyx_t_14 = __Pyx_dict_iter_next(__pyx_t_4, __pyx_t_1, &__pyx_t_2, NULL, &__pyx_t_6, NULL, __pyx_t_13); + if (unlikely(__pyx_t_14 == 0)) break; + if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (!(likely(PyList_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_parents, ((PyObject*)__pyx_t_6)); + __pyx_t_6 = 0; + __pyx_v_i = __pyx_t_12; + __pyx_t_12 = (__pyx_t_12 + 1); - /* "ml.pyx":53 + /* "ml.pyx":47 * # 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] + * for (prnt, 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 = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyList_New(0); 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); - /* "ml.pyx":54 + /* "ml.pyx":48 * # likely parent infects it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< * probs_fail[i] = sum(failures) * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) */ if (unlikely(__pyx_v_parents == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_5 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_5); __pyx_t_13 = 0; + __pyx_t_5 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_5); __pyx_t_15 = 0; for (;;) { - if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_5)) break; + if (__pyx_t_15 >= 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 = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __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 = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __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; + if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { + PyObject* sequence = __pyx_t_3; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif - if (unlikely(size != 5)) { - if (size > 5) __Pyx_RaiseTooManyValuesError(5); + if (unlikely(size != 6)) { + if (size > 6) __Pyx_RaiseTooManyValuesError(6); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_14 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_15 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_16 = PyTuple_GET_ITEM(sequence, 2); - __pyx_t_17 = PyTuple_GET_ITEM(sequence, 3); - __pyx_t_18 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_16 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_17 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_18 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_19 = PyTuple_GET_ITEM(sequence, 3); + __pyx_t_20 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_21 = PyTuple_GET_ITEM(sequence, 5); } else { - __pyx_t_14 = PyList_GET_ITEM(sequence, 0); - __pyx_t_15 = PyList_GET_ITEM(sequence, 1); - __pyx_t_16 = PyList_GET_ITEM(sequence, 2); - __pyx_t_17 = PyList_GET_ITEM(sequence, 3); - __pyx_t_18 = PyList_GET_ITEM(sequence, 4); + __pyx_t_16 = PyList_GET_ITEM(sequence, 0); + __pyx_t_17 = PyList_GET_ITEM(sequence, 1); + __pyx_t_18 = PyList_GET_ITEM(sequence, 2); + __pyx_t_19 = PyList_GET_ITEM(sequence, 3); + __pyx_t_20 = PyList_GET_ITEM(sequence, 4); + __pyx_t_21 = PyList_GET_ITEM(sequence, 5); } - __Pyx_INCREF(__pyx_t_14); - __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(__pyx_t_18); + __Pyx_INCREF(__pyx_t_19); + __Pyx_INCREF(__pyx_t_20); + __Pyx_INCREF(__pyx_t_21); #else { 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 = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20,&__pyx_t_21}; + for (i=0; i < 6; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } 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 = 54; __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; - for (index=0; index < 5; index++) { - PyObject* item = __pyx_t_20(__pyx_t_19); if (unlikely(!item)) goto __pyx_L7_unpacking_failed; + PyObject** temps[6] = {&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20,&__pyx_t_21}; + __pyx_t_22 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_22); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_23 = Py_TYPE(__pyx_t_22)->tp_iternext; + for (index=0; index < 6; index++) { + PyObject* item = __pyx_t_23(__pyx_t_22); if (unlikely(!item)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_20 = NULL; - __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; + if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_22), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_23 = NULL; + __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; goto __pyx_L8_unpacking_done; __pyx_L7_unpacking_failed:; - __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; - __pyx_t_20 = NULL; + __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; + __pyx_t_23 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __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 = 54; __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 = 54; __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; - __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_16); + __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; + __pyx_t_24 = __Pyx_PyInt_As_int(__pyx_t_18); if (unlikely((__pyx_t_24 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; + __Pyx_XDECREF_SET(__pyx_v_prnt, __pyx_t_16); __pyx_t_16 = 0; - __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_17); - __pyx_t_17 = 0; - __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_18); - __pyx_t_18 = 0; - - /* "ml.pyx":53 + __pyx_v_dist = __pyx_t_14; + __pyx_v_dt = __pyx_t_24; + __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_19); + __pyx_t_19 = 0; + __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_20); + __pyx_t_20 = 0; + __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_21); + __pyx_t_21 = 0; + + /* "ml.pyx":47 * # 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] + * for (prnt, 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 = 53; __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 = 53; __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 = 53; __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 = 53; __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 = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_25 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_26 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble(__pyx_f_2ml_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_25, __pyx_t_26, __pyx_t_27)); 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); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "ml.pyx":54 + /* "ml.pyx":48 * # likely parent infects it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< * probs_fail[i] = sum(failures) * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) */ } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_failures); - __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_failures, ((PyObject*)__pyx_t_4)); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_failures, ((PyObject*)__pyx_t_6)); + __pyx_t_6 = 0; - /* "ml.pyx":55 + /* "ml.pyx":49 * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] + * for (prnt, 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] + * for (prnt, 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 = 55; __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 = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_failures); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_failures); + __Pyx_GIVEREF(__pyx_v_failures); + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __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 = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __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; + __pyx_t_24 = __pyx_v_i; + if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_pybuffernd_probs_fail.diminfo[0].shape; + *__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs_fail.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_probs_fail.diminfo[0].strides) = __pyx_t_27; - /* "ml.pyx":56 - * for (dist, dt, w1, w2, w3) in parents] + /* "ml.pyx":50 + * for (prnt, 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}) + * for (prnt, dist, dt, w1, w2, w3) in parents] + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] */ - __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __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 = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - /* "ml.pyx":57 + /* "ml.pyx":51 * 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}) - * probs[i] = max(s - failures[l] for l, s in enumerate(successes)) + * for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] + * dts = [dt for (prnt, dist, dt, w1, w2, w3) in parents] */ if (unlikely(__pyx_v_parents == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __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_v_parents; __Pyx_INCREF(__pyx_t_4); __pyx_t_13 = 0; + __pyx_t_6 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0; for (;;) { - if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_4)) break; + if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_6)) 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 = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __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 = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __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; + if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { + PyObject* sequence = __pyx_t_3; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif - if (unlikely(size != 5)) { - if (size > 5) __Pyx_RaiseTooManyValuesError(5); + if (unlikely(size != 6)) { + if (size > 6) __Pyx_RaiseTooManyValuesError(6); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_18 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_17 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_16 = PyTuple_GET_ITEM(sequence, 2); - __pyx_t_15 = PyTuple_GET_ITEM(sequence, 3); - __pyx_t_14 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_21 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_20 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_19 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_18 = PyTuple_GET_ITEM(sequence, 3); + __pyx_t_17 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_16 = PyTuple_GET_ITEM(sequence, 5); } else { - __pyx_t_18 = PyList_GET_ITEM(sequence, 0); - __pyx_t_17 = PyList_GET_ITEM(sequence, 1); - __pyx_t_16 = PyList_GET_ITEM(sequence, 2); - __pyx_t_15 = PyList_GET_ITEM(sequence, 3); - __pyx_t_14 = PyList_GET_ITEM(sequence, 4); + __pyx_t_21 = PyList_GET_ITEM(sequence, 0); + __pyx_t_20 = PyList_GET_ITEM(sequence, 1); + __pyx_t_19 = PyList_GET_ITEM(sequence, 2); + __pyx_t_18 = PyList_GET_ITEM(sequence, 3); + __pyx_t_17 = PyList_GET_ITEM(sequence, 4); + __pyx_t_16 = PyList_GET_ITEM(sequence, 5); } + __Pyx_INCREF(__pyx_t_21); + __Pyx_INCREF(__pyx_t_20); + __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(__pyx_t_18); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(__pyx_t_16); - __Pyx_INCREF(__pyx_t_15); - __Pyx_INCREF(__pyx_t_14); #else { 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 = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_21,&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16}; + for (i=0; i < 6; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } 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 = 57; __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; - for (index=0; index < 5; index++) { - PyObject* item = __pyx_t_20(__pyx_t_19); if (unlikely(!item)) goto __pyx_L11_unpacking_failed; + PyObject** temps[6] = {&__pyx_t_21,&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16}; + __pyx_t_22 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_22); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_23 = Py_TYPE(__pyx_t_22)->tp_iternext; + for (index=0; index < 6; index++) { + PyObject* item = __pyx_t_23(__pyx_t_22); if (unlikely(!item)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_20 = NULL; - __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; + if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_22), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_23 = NULL; + __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; goto __pyx_L12_unpacking_done; __pyx_L11_unpacking_failed:; - __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; - __pyx_t_20 = NULL; + __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; + __pyx_t_23 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __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 = 57; __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 = 57; __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; - __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_16); + __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_20); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; + __pyx_t_28 = __Pyx_PyInt_As_int(__pyx_t_19); if (unlikely((__pyx_t_28 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; + __Pyx_XDECREF_SET(__pyx_v_prnt, __pyx_t_21); + __pyx_t_21 = 0; + __pyx_v_dist = __pyx_t_14; + __pyx_v_dt = __pyx_t_28; + __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_18); + __pyx_t_18 = 0; + __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_17); + __pyx_t_17 = 0; + __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_16); __pyx_t_16 = 0; - __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_15); - __pyx_t_15 = 0; - __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_14); - __pyx_t_14 = 0; - /* "ml.pyx":56 - * for (dist, dt, w1, w2, w3) in parents] + /* "ml.pyx":50 + * for (prnt, 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}) + * for (prnt, dist, dt, w1, w2, w3) in parents] + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] */ - __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 = 56; __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 = 56; __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 = 56; __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 = 56; __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 = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_26 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_25 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble(__pyx_f_2ml_weight_success(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_27, __pyx_t_26, __pyx_t_25)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "ml.pyx":57 + /* "ml.pyx":51 * 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}) - * probs[i] = max(s - failures[l] for l, s in enumerate(successes)) + * for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] + * dts = [dt for (prnt, dist, dt, w1, w2, w3) in parents] */ } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_successes); - __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_successes, ((PyObject*)__pyx_t_5)); - __Pyx_GIVEREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_successes, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0; - /* "ml.pyx":59 - * for (dist, dt, w1, w2, w3) in parents] + /* "ml.pyx":52 + * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) + * for (prnt, dist, dt, w1, w2, w3) in parents] + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * dts = [dt for (prnt, 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 = 59; __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 = 52; __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 = 59; __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); + if (unlikely(__pyx_v_parents == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_6 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0; + for (;;) { + if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_6)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { + PyObject* sequence = __pyx_t_3; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 6)) { + if (size > 6) __Pyx_RaiseTooManyValuesError(6); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_16 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_17 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_18 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_19 = PyTuple_GET_ITEM(sequence, 3); + __pyx_t_20 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_21 = PyTuple_GET_ITEM(sequence, 5); + } else { + __pyx_t_16 = PyList_GET_ITEM(sequence, 0); + __pyx_t_17 = PyList_GET_ITEM(sequence, 1); + __pyx_t_18 = PyList_GET_ITEM(sequence, 2); + __pyx_t_19 = PyList_GET_ITEM(sequence, 3); + __pyx_t_20 = PyList_GET_ITEM(sequence, 4); + __pyx_t_21 = PyList_GET_ITEM(sequence, 5); + } + __Pyx_INCREF(__pyx_t_16); + __Pyx_INCREF(__pyx_t_17); + __Pyx_INCREF(__pyx_t_18); + __Pyx_INCREF(__pyx_t_19); + __Pyx_INCREF(__pyx_t_20); + __Pyx_INCREF(__pyx_t_21); + #else + { + Py_ssize_t i; + PyObject** temps[6] = {&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20,&__pyx_t_21}; + for (i=0; i < 6; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(item); + *(temps[i]) = item; + } + } + #endif + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + Py_ssize_t index = -1; + PyObject** temps[6] = {&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20,&__pyx_t_21}; + __pyx_t_22 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_22); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_23 = Py_TYPE(__pyx_t_22)->tp_iternext; + for (index=0; index < 6; index++) { + PyObject* item = __pyx_t_23(__pyx_t_22); if (unlikely(!item)) goto __pyx_L15_unpacking_failed; + __Pyx_GOTREF(item); + *(temps[index]) = item; + } + if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_22), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_23 = NULL; + __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; + goto __pyx_L16_unpacking_done; + __pyx_L15_unpacking_failed:; + __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; + __pyx_t_23 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L16_unpacking_done:; + } + __pyx_t_28 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_28 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; + __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_18); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; + __Pyx_XDECREF_SET(__pyx_v_prnt, __pyx_t_16); + __pyx_t_16 = 0; + __pyx_v_dist = __pyx_t_28; + __pyx_v_dt = __pyx_t_14; + __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_19); + __pyx_t_19 = 0; + __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_20); + __pyx_t_20 = 0; + __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_21); + __pyx_t_21 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dist); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_dists, ((PyObject*)__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 = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "ml.pyx":53 + * for (prnt, dist, dt, w1, w2, w3) in parents] + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] + * dts = [dt for (prnt, 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)) + */ + __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __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 = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + 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_t_6 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0; + for (;;) { + if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_6)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { + PyObject* sequence = __pyx_t_3; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 6)) { + if (size > 6) __Pyx_RaiseTooManyValuesError(6); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_21 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_20 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_19 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_18 = PyTuple_GET_ITEM(sequence, 3); + __pyx_t_17 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_16 = PyTuple_GET_ITEM(sequence, 5); + } else { + __pyx_t_21 = PyList_GET_ITEM(sequence, 0); + __pyx_t_20 = PyList_GET_ITEM(sequence, 1); + __pyx_t_19 = PyList_GET_ITEM(sequence, 2); + __pyx_t_18 = PyList_GET_ITEM(sequence, 3); + __pyx_t_17 = PyList_GET_ITEM(sequence, 4); + __pyx_t_16 = PyList_GET_ITEM(sequence, 5); + } + __Pyx_INCREF(__pyx_t_21); + __Pyx_INCREF(__pyx_t_20); + __Pyx_INCREF(__pyx_t_19); + __Pyx_INCREF(__pyx_t_18); + __Pyx_INCREF(__pyx_t_17); + __Pyx_INCREF(__pyx_t_16); + #else + { + Py_ssize_t i; + PyObject** temps[6] = {&__pyx_t_21,&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16}; + for (i=0; i < 6; 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;} + __Pyx_GOTREF(item); + *(temps[i]) = item; + } + } + #endif + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + Py_ssize_t index = -1; + PyObject** temps[6] = {&__pyx_t_21,&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16}; + __pyx_t_22 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_22); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_23 = Py_TYPE(__pyx_t_22)->tp_iternext; + for (index=0; index < 6; index++) { + PyObject* item = __pyx_t_23(__pyx_t_22); if (unlikely(!item)) goto __pyx_L19_unpacking_failed; + __Pyx_GOTREF(item); + *(temps[index]) = item; + } + if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_22), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_23 = NULL; + __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; + goto __pyx_L20_unpacking_done; + __pyx_L19_unpacking_failed:; + __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; + __pyx_t_23 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L20_unpacking_done:; + } + __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_20); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; + __pyx_t_28 = __Pyx_PyInt_As_int(__pyx_t_19); if (unlikely((__pyx_t_28 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; + __Pyx_XDECREF_SET(__pyx_v_prnt, __pyx_t_21); + __pyx_t_21 = 0; + __pyx_v_dist = __pyx_t_14; + __pyx_v_dt = __pyx_t_28; + __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_18); + __pyx_t_18 = 0; + __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_17); + __pyx_t_17 = 0; + __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_16); + __pyx_t_16 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_dts, ((PyObject*)__pyx_t_5)); + __pyx_t_5 = 0; + + /* "ml.pyx":56 + * # find parent that maximizes log(p) - log(\tilde{p}) + * # probs[i] = max(s - failures[l] for l, s in enumerate(successes)) + * probs[i] = float("-inf") # <<<<<<<<<<<<<< + * for l, s in enumerate(successes): + * prob = s - failures[l] + */ + __pyx_t_29 = __Pyx_PyObject_AsDouble(__pyx_kp_s_inf); if (unlikely(__pyx_t_29 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_28 = __pyx_v_i; + if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_pybuffernd_probs.diminfo[0].shape; + *__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_probs.diminfo[0].strides) = __pyx_t_29; + + /* "ml.pyx":57 + * # probs[i] = max(s - failures[l] for l, s in enumerate(successes)) + * probs[i] = float("-inf") + * for l, s in enumerate(successes): # <<<<<<<<<<<<<< + * prob = s - failures[l] + * if prob > probs[i]: + */ + __pyx_t_14 = 0; + __pyx_t_5 = __pyx_v_successes; __Pyx_INCREF(__pyx_t_5); __pyx_t_15 = 0; + for (;;) { + if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_15); __Pyx_INCREF(__pyx_t_6); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_6); + __pyx_t_6 = 0; + __pyx_v_l = __pyx_t_14; + __pyx_t_14 = (__pyx_t_14 + 1); + + /* "ml.pyx":58 + * probs[i] = float("-inf") + * for l, s in enumerate(successes): + * prob = s - failures[l] # <<<<<<<<<<<<<< + * if prob > probs[i]: + * probs[i] = prob + */ + __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_failures, __pyx_v_l, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyNumber_Subtract(__pyx_v_s, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_prob, __pyx_t_3); + __pyx_t_3 = 0; + + /* "ml.pyx":59 + * for l, s in enumerate(successes): + * prob = s - failures[l] + * if prob > probs[i]: # <<<<<<<<<<<<<< + * probs[i] = prob + * parent_dists[i] = dists[l] + */ + __pyx_t_30 = __pyx_v_i; + if (__pyx_t_30 < 0) __pyx_t_30 += __pyx_pybuffernd_probs.diminfo[0].shape; + __pyx_t_3 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_probs.diminfo[0].strides))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyObject_RichCompare(__pyx_v_prob, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_31 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_31 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_31) { + + /* "ml.pyx":60 + * prob = s - failures[l] + * if prob > probs[i]: + * probs[i] = prob # <<<<<<<<<<<<<< + * parent_dists[i] = dists[l] + * parent_dts[i] = dts[l] + */ + __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_v_prob); if (unlikely((__pyx_t_25 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_32 = __pyx_v_i; + if (__pyx_t_32 < 0) __pyx_t_32 += __pyx_pybuffernd_probs.diminfo[0].shape; + *__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_probs.diminfo[0].strides) = __pyx_t_25; + + /* "ml.pyx":61 + * if prob > probs[i]: + * probs[i] = prob + * parent_dists[i] = dists[l] # <<<<<<<<<<<<<< + * parent_dts[i] = dts[l] + * # probs_fail[i] = failures[l] + */ + __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_dists, __pyx_v_l, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_25 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_33 = __pyx_v_i; + if (__pyx_t_33 < 0) __pyx_t_33 += __pyx_pybuffernd_parent_dists.diminfo[0].shape; + *__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_parent_dists.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_parent_dists.diminfo[0].strides) = __pyx_t_25; + + /* "ml.pyx":62 + * probs[i] = prob + * parent_dists[i] = dists[l] + * parent_dts[i] = dts[l] # <<<<<<<<<<<<<< + * # probs_fail[i] = failures[l] + * + */ + __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_dts, __pyx_v_l, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_25 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_34 = __pyx_v_i; + if (__pyx_t_34 < 0) __pyx_t_34 += __pyx_pybuffernd_parent_dts.diminfo[0].shape; + *__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_parent_dts.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_parent_dts.diminfo[0].strides) = __pyx_t_25; + goto __pyx_L23; + } + __pyx_L23:; + + /* "ml.pyx":57 + * # probs[i] = max(s - failures[l] for l, s in enumerate(successes)) + * probs[i] = float("-inf") + * for l, s in enumerate(successes): # <<<<<<<<<<<<<< + * prob = s - failures[l] + * if prob > probs[i]: + */ + } __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; - *__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_probs.diminfo[0].strides) = __pyx_t_22; } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "ml.pyx":62 + /* "ml.pyx":66 * * # loop through non-victims * for i, parents in enumerate(non_victims.itervalues()): # <<<<<<<<<<<<<< * # for each non victim node, compute the probability that all its * # parents fail to infect it */ - __pyx_t_10 = 0; + __pyx_t_12 = 0; __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 = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __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 = 62; __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_13)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_3); - __pyx_t_3 = __pyx_t_5; + __Pyx_XDECREF(__pyx_t_4); + __pyx_t_4 = __pyx_t_5; __pyx_t_5 = 0; 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 = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = __Pyx_dict_iter_next(__pyx_t_4, __pyx_t_2, &__pyx_t_1, NULL, &__pyx_t_5, NULL, __pyx_t_13); + if (unlikely(__pyx_t_14 == 0)) break; + if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __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 = 62; __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 = 66; __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); + __pyx_v_i = __pyx_t_12; + __pyx_t_12 = (__pyx_t_12 + 1); - /* "ml.pyx":65 + /* "ml.pyx":69 * # 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] + * for (prnt, 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 = 65; __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 = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - /* "ml.pyx":66 + /* "ml.pyx":70 * # parents fail to infect it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< * probs_nv[i] = sum(failures) * */ if (unlikely(__pyx_v_parents == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_4 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_4); __pyx_t_13 = 0; + __pyx_t_6 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0; for (;;) { - if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_4)) break; + if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_6)) 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 = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __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 = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __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; + if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { + PyObject* sequence = __pyx_t_3; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif - if (unlikely(size != 5)) { - if (size > 5) __Pyx_RaiseTooManyValuesError(5); + if (unlikely(size != 6)) { + if (size > 6) __Pyx_RaiseTooManyValuesError(6); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_14 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_15 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_16 = PyTuple_GET_ITEM(sequence, 2); - __pyx_t_17 = PyTuple_GET_ITEM(sequence, 3); - __pyx_t_18 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_16 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_17 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_18 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_19 = PyTuple_GET_ITEM(sequence, 3); + __pyx_t_20 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_21 = PyTuple_GET_ITEM(sequence, 5); } else { - __pyx_t_14 = PyList_GET_ITEM(sequence, 0); - __pyx_t_15 = PyList_GET_ITEM(sequence, 1); - __pyx_t_16 = PyList_GET_ITEM(sequence, 2); - __pyx_t_17 = PyList_GET_ITEM(sequence, 3); - __pyx_t_18 = PyList_GET_ITEM(sequence, 4); + __pyx_t_16 = PyList_GET_ITEM(sequence, 0); + __pyx_t_17 = PyList_GET_ITEM(sequence, 1); + __pyx_t_18 = PyList_GET_ITEM(sequence, 2); + __pyx_t_19 = PyList_GET_ITEM(sequence, 3); + __pyx_t_20 = PyList_GET_ITEM(sequence, 4); + __pyx_t_21 = PyList_GET_ITEM(sequence, 5); } - __Pyx_INCREF(__pyx_t_14); - __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(__pyx_t_18); + __Pyx_INCREF(__pyx_t_19); + __Pyx_INCREF(__pyx_t_20); + __Pyx_INCREF(__pyx_t_21); #else { 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 = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20,&__pyx_t_21}; + for (i=0; i < 6; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } 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 = 66; __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; - for (index=0; index < 5; index++) { - PyObject* item = __pyx_t_20(__pyx_t_19); if (unlikely(!item)) goto __pyx_L17_unpacking_failed; + PyObject** temps[6] = {&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20,&__pyx_t_21}; + __pyx_t_22 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_22); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_23 = Py_TYPE(__pyx_t_22)->tp_iternext; + for (index=0; index < 6; index++) { + PyObject* item = __pyx_t_23(__pyx_t_22); if (unlikely(!item)) goto __pyx_L28_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __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; - __pyx_L17_unpacking_failed:; - __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; - __pyx_t_20 = NULL; + if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_22), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_23 = NULL; + __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; + goto __pyx_L29_unpacking_done; + __pyx_L28_unpacking_failed:; + __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; + __pyx_t_23 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L18_unpacking_done:; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L29_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 = 66; __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 = 66; __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; - __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_16); + __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; + __pyx_t_35 = __Pyx_PyInt_As_int(__pyx_t_18); if (unlikely((__pyx_t_35 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; + __Pyx_XDECREF_SET(__pyx_v_prnt, __pyx_t_16); __pyx_t_16 = 0; - __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_17); - __pyx_t_17 = 0; - __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_18); - __pyx_t_18 = 0; - - /* "ml.pyx":65 + __pyx_v_dist = __pyx_t_14; + __pyx_v_dt = __pyx_t_35; + __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_19); + __pyx_t_19 = 0; + __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_20); + __pyx_t_20 = 0; + __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_21); + __pyx_t_21 = 0; + + /* "ml.pyx":69 * # 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] + * for (prnt, 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 = 65; __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 = 65; __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 = 65; __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 = 65; __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 = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_25 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_26 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble(__pyx_f_2ml_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_25, __pyx_t_26, __pyx_t_27)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "ml.pyx":66 + /* "ml.pyx":70 * # parents fail to infect it * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< * probs_nv[i] = sum(failures) * */ } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_failures); - __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_failures, ((PyObject*)__pyx_t_5)); - __Pyx_GIVEREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_failures, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0; - /* "ml.pyx":67 + /* "ml.pyx":71 * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] + * for (prnt, dist, dt, w1, w2, w3) in parents] * probs_nv[i] = sum(failures) # <<<<<<<<<<<<<< * - * # print successes + * # calculate log likelihood */ - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __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 = 71; __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 = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_failures); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_failures); + __Pyx_GIVEREF(__pyx_v_failures); + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); __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 = 67; __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; - *__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs_nv.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_probs_nv.diminfo[0].strides) = __pyx_t_24; + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_35 = __pyx_v_i; + if (__pyx_t_35 < 0) __pyx_t_35 += __pyx_pybuffernd_probs_nv.diminfo[0].shape; + *__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs_nv.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_probs_nv.diminfo[0].strides) = __pyx_t_27; } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "ml.pyx":77 - * # cdef: - * # np.ndarray[DTYPE_t] cums = probs.cumsum() - * ll = probs_fail.sum() # add probability that all edges to victims fail # <<<<<<<<<<<<<< + /* "ml.pyx":74 + * + * # calculate log likelihood + * ll = probs_fail.sum() # add probability that all edges to all 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 = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_fail), __pyx_n_s_sum); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); + __Pyx_DECREF_SET(__pyx_t_6, function); } } 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 = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __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 = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __Pyx_GOTREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __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 = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_ll = __pyx_t_24; + __pyx_v_ll = __pyx_t_27; - /* "ml.pyx":78 - * # np.ndarray[DTYPE_t] cums = probs.cumsum() - * ll = probs_fail.sum() # add probability that all edges to victims fail + /* "ml.pyx":75 + * # calculate log likelihood + * ll = probs_fail.sum() # add probability that all edges to all victims fail * ll += probs_nv.sum() # add probability that all edges to non_victims fail # <<<<<<<<<<<<<< * * # print 'probs', probs */ - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __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 = 78; __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 = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __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 = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = NULL; + __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } - 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 = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_3) { + __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { - __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __Pyx_GOTREF(__pyx_t_4); + __Pyx_GOTREF(__pyx_t_6); __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 = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __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 = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_ll = __pyx_t_24; + __pyx_v_ll = __pyx_t_27; - /* "ml.pyx":81 + /* "ml.pyx":78 * * # print 'probs', probs * max_beta_add = float('-inf') # <<<<<<<<<<<<<< * # iterate over all victim nodes to find the optimal threshold - * for beta in np.arange(0.001, .2, .002): + * for beta in np.arange(0.01, 1., .01): */ - __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 = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_max_beta_add = __pyx_t_27; + __pyx_t_29 = __Pyx_PyObject_AsDouble(__pyx_kp_s_inf); if (unlikely(__pyx_t_29 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_max_beta_add = __pyx_t_29; - /* "ml.pyx":83 + /* "ml.pyx":80 * max_beta_add = float('-inf') * # iterate over all victim nodes to find the optimal threshold - * for beta in np.arange(0.001, .2, .002): # <<<<<<<<<<<<<< + * for beta in np.arange(0.01, 1., .01): # <<<<<<<<<<<<<< * thresh = log(beta/(3012.*(1.-beta))) - * # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh]) + * seeds = probstp_iternext; if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_36 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; for (;;) { - if (likely(!__pyx_t_28)) { - if (likely(PyList_CheckExact(__pyx_t_4))) { - if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_4)) break; + if (likely(!__pyx_t_36)) { + if (likely(PyList_CheckExact(__pyx_t_6))) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } } else { - __pyx_t_5 = __pyx_t_28(__pyx_t_4); + __pyx_t_5 = __pyx_t_36(__pyx_t_6); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_5); } - __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 = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_beta = __pyx_t_24; + __pyx_v_beta = __pyx_t_27; - /* "ml.pyx":84 + /* "ml.pyx":81 * # iterate over all victim nodes to find the optimal threshold - * for beta in np.arange(0.001, .2, .002): + * for beta in np.arange(0.01, 1., .01): * thresh = log(beta/(3012.*(1.-beta))) # <<<<<<<<<<<<<< - * # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh]) - * roots = n_roots + len(probs[probs=thresh */ __pyx_v_thresh = log((__pyx_v_beta / (3012. * (1. - __pyx_v_beta)))); - /* "ml.pyx":86 + /* "ml.pyx":82 + * for beta in np.arange(0.01, 1., .01): * thresh = log(beta/(3012.*(1.-beta))) - * # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh]) - * roots = n_roots + len(probs[probs=thresh + * roots = n_roots + sum(seeds) + */ + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF_SET(__pyx_v_seeds, __pyx_t_4); + __pyx_t_4 = 0; + + /* "ml.pyx":83 + * thresh = log(beta/(3012.*(1.-beta))) + * seeds = probs=thresh # <<<<<<<<<<<<<< + * roots = n_roots + sum(seeds) + * + */ + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_non_seeds, __pyx_t_5); + __pyx_t_5 = 0; + + /* "ml.pyx":84 + * seeds = probs=thresh + * roots = n_roots + sum(seeds) # <<<<<<<<<<<<<< * * beta_add = 0. */ - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_roots); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __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 = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_seeds); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_seeds); + __Pyx_GIVEREF(__pyx_v_seeds); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_t_3); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_1 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_roots = (__pyx_v_n_roots + __pyx_t_1); + __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_roots = __pyx_t_12; - /* "ml.pyx":88 - * roots = n_roots + len(probs[probs=thresh]).sum() + * beta_add += (probs[non_seeds]).sum() */ __pyx_v_beta_add = 0.; - /* "ml.pyx":90 + /* "ml.pyx":88 * beta_add = 0. * # add probability for realized edges and subtract probability these edges fail - * beta_add += (probs[probs>=thresh]).sum() # <<<<<<<<<<<<<< + * beta_add += (probs[non_seeds]).sum() # <<<<<<<<<<<<<< * # add probability for the seeds and non-seeds * beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) */ - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_v_non_seeds); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_18 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_6, Py_GE); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_t_18); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; - __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_sum); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_18); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_18))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_18); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18); - __Pyx_INCREF(__pyx_t_6); + __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sum); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_21); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_21))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_21); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21); + __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_18, function); + __Pyx_DECREF_SET(__pyx_t_21, function); } } - if (__pyx_t_6) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_18, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_5) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_21, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __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_18); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_21); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; - __pyx_t_18 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_18); + __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; + __pyx_t_21 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_21); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_21); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; + __pyx_v_beta_add = __pyx_t_27; + + /* "ml.pyx":90 + * beta_add += (probs[non_seeds]).sum() + * # add probability for the seeds and non-seeds + * beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) # <<<<<<<<<<<<<< + * + * if beta_add > max_beta_add: + */ + __pyx_t_21 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_21); + __pyx_t_3 = PyFloat_FromDouble((__pyx_v_roots * log((__pyx_v_beta / 3012.)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyNumber_Subtract(__pyx_v_n_nodes, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyFloat_FromDouble(log((1. - __pyx_v_beta))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_20 = PyNumber_Multiply(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_20); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_18); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; - __pyx_v_beta_add = __pyx_t_24; + __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; + __pyx_t_20 = PyNumber_InPlaceAdd(__pyx_t_21, __pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_20); + __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_20); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; + __pyx_v_beta_add = __pyx_t_27; /* "ml.pyx":92 - * beta_add += (probs[probs>=thresh]).sum() - * # add probability for the seeds and non-seeds - * beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) # <<<<<<<<<<<<<< - * - * if beta_add > max_beta_add: - */ - __pyx_v_beta_add = (__pyx_v_beta_add + ((__pyx_v_roots * log((__pyx_v_beta / 3012.))) + ((__pyx_v_n_nodes - __pyx_v_roots) * log((1. - __pyx_v_beta))))); - - /* "ml.pyx":94 * beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) * * if beta_add > max_beta_add: # <<<<<<<<<<<<<< * max_beta = beta * max_roots = roots */ - __pyx_t_29 = ((__pyx_v_beta_add > __pyx_v_max_beta_add) != 0); - if (__pyx_t_29) { + __pyx_t_31 = ((__pyx_v_beta_add > __pyx_v_max_beta_add) != 0); + if (__pyx_t_31) { - /* "ml.pyx":95 + /* "ml.pyx":93 * * if beta_add > max_beta_add: * max_beta = beta # <<<<<<<<<<<<<< @@ -2832,7 +3121,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ __pyx_v_max_beta = __pyx_v_beta; - /* "ml.pyx":96 + /* "ml.pyx":94 * if beta_add > max_beta_add: * max_beta = beta * max_roots = roots # <<<<<<<<<<<<<< @@ -2841,7 +3130,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ __pyx_v_max_roots = __pyx_v_roots; - /* "ml.pyx":97 + /* "ml.pyx":95 * max_beta = beta * max_roots = roots * max_beta_add = beta_add # <<<<<<<<<<<<<< @@ -2849,21 +3138,21 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ * */ __pyx_v_max_beta_add = __pyx_v_beta_add; - goto __pyx_L21; + goto __pyx_L32; } - __pyx_L21:; + __pyx_L32:; - /* "ml.pyx":83 + /* "ml.pyx":80 * max_beta_add = float('-inf') * # iterate over all victim nodes to find the optimal threshold - * for beta in np.arange(0.001, .2, .002): # <<<<<<<<<<<<<< + * for beta in np.arange(0.01, 1., .01): # <<<<<<<<<<<<<< * thresh = log(beta/(3012.*(1.-beta))) - * # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh]) + * seeds = probspybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_parent_dts.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs_fail.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs_nv.rcbuffer->pybuffer); @@ -2947,18 +3239,31 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_parent_dists.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_parent_dts.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs_fail.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs_nv.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF(__pyx_v_parents); + __Pyx_XDECREF(__pyx_v_failures); + __Pyx_XDECREF(__pyx_v_successes); + __Pyx_XDECREF(__pyx_v_n_nodes); __Pyx_XDECREF((PyObject *)__pyx_v_probs); __Pyx_XDECREF((PyObject *)__pyx_v_probs_fail); + __Pyx_XDECREF((PyObject *)__pyx_v_parent_dists); + __Pyx_XDECREF((PyObject *)__pyx_v_parent_dts); __Pyx_XDECREF((PyObject *)__pyx_v_probs_nv); + __Pyx_XDECREF(__pyx_v_dists); + __Pyx_XDECREF(__pyx_v_dts); + __Pyx_XDECREF(__pyx_v_s); + __Pyx_XDECREF(__pyx_v_prob); + __Pyx_XDECREF(__pyx_v_seeds); + __Pyx_XDECREF(__pyx_v_non_seeds); + __Pyx_XDECREF(__pyx_v_prnt); __Pyx_XDECREF(__pyx_v_w1); __Pyx_XDECREF(__pyx_v_w2); __Pyx_XDECREF(__pyx_v_w3); - __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; @@ -4966,233 +5271,6 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py return __pyx_r; } -static struct __pyx_obj_2ml___pyx_scope_struct__ml *__pyx_freelist_2ml___pyx_scope_struct__ml[8]; -static int __pyx_freecount_2ml___pyx_scope_struct__ml = 0; - -static PyObject *__pyx_tp_new_2ml___pyx_scope_struct__ml(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - PyObject *o; - if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_2ml___pyx_scope_struct__ml > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_2ml___pyx_scope_struct__ml)))) { - o = (PyObject*)__pyx_freelist_2ml___pyx_scope_struct__ml[--__pyx_freecount_2ml___pyx_scope_struct__ml]; - memset(o, 0, sizeof(struct __pyx_obj_2ml___pyx_scope_struct__ml)); - (void) PyObject_INIT(o, t); - PyObject_GC_Track(o); - } else { - o = (*t->tp_alloc)(t, 0); - if (unlikely(!o)) return 0; - } - return o; -} - -static void __pyx_tp_dealloc_2ml___pyx_scope_struct__ml(PyObject *o) { - struct __pyx_obj_2ml___pyx_scope_struct__ml *p = (struct __pyx_obj_2ml___pyx_scope_struct__ml *)o; - PyObject_GC_UnTrack(o); - Py_CLEAR(p->__pyx_v_failures); - Py_CLEAR(p->__pyx_v_successes); - if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_2ml___pyx_scope_struct__ml < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_2ml___pyx_scope_struct__ml)))) { - __pyx_freelist_2ml___pyx_scope_struct__ml[__pyx_freecount_2ml___pyx_scope_struct__ml++] = ((struct __pyx_obj_2ml___pyx_scope_struct__ml *)o); - } else { - (*Py_TYPE(o)->tp_free)(o); - } -} - -static int __pyx_tp_traverse_2ml___pyx_scope_struct__ml(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_2ml___pyx_scope_struct__ml *p = (struct __pyx_obj_2ml___pyx_scope_struct__ml *)o; - if (p->__pyx_v_failures) { - e = (*v)(p->__pyx_v_failures, a); if (e) return e; - } - if (p->__pyx_v_successes) { - e = (*v)(p->__pyx_v_successes, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_2ml___pyx_scope_struct__ml(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_2ml___pyx_scope_struct__ml *p = (struct __pyx_obj_2ml___pyx_scope_struct__ml *)o; - tmp = ((PyObject*)p->__pyx_v_failures); - p->__pyx_v_failures = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_successes); - p->__pyx_v_successes = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyTypeObject __pyx_type_2ml___pyx_scope_struct__ml = { - PyVarObject_HEAD_INIT(0, 0) - "ml.__pyx_scope_struct__ml", /*tp_name*/ - sizeof(struct __pyx_obj_2ml___pyx_scope_struct__ml), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_2ml___pyx_scope_struct__ml, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #else - 0, /*reserved*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_2ml___pyx_scope_struct__ml, /*tp_traverse*/ - __pyx_tp_clear_2ml___pyx_scope_struct__ml, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - 0, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_2ml___pyx_scope_struct__ml, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - -static struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *__pyx_freelist_2ml___pyx_scope_struct_1_genexpr[8]; -static int __pyx_freecount_2ml___pyx_scope_struct_1_genexpr = 0; - -static PyObject *__pyx_tp_new_2ml___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - PyObject *o; - if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_2ml___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr)))) { - o = (PyObject*)__pyx_freelist_2ml___pyx_scope_struct_1_genexpr[--__pyx_freecount_2ml___pyx_scope_struct_1_genexpr]; - memset(o, 0, sizeof(struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr)); - (void) PyObject_INIT(o, t); - PyObject_GC_Track(o); - } else { - o = (*t->tp_alloc)(t, 0); - if (unlikely(!o)) return 0; - } - return o; -} - -static void __pyx_tp_dealloc_2ml___pyx_scope_struct_1_genexpr(PyObject *o) { - struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *)o; - PyObject_GC_UnTrack(o); - Py_CLEAR(p->__pyx_outer_scope); - Py_CLEAR(p->__pyx_v_s); - Py_CLEAR(p->__pyx_t_1); - if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_2ml___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr)))) { - __pyx_freelist_2ml___pyx_scope_struct_1_genexpr[__pyx_freecount_2ml___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *)o); - } else { - (*Py_TYPE(o)->tp_free)(o); - } -} - -static int __pyx_tp_traverse_2ml___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *)o; - if (p->__pyx_outer_scope) { - e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e; - } - if (p->__pyx_v_s) { - e = (*v)(p->__pyx_v_s, a); if (e) return e; - } - if (p->__pyx_t_1) { - e = (*v)(p->__pyx_t_1, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_2ml___pyx_scope_struct_1_genexpr(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr *)o; - tmp = ((PyObject*)p->__pyx_outer_scope); - p->__pyx_outer_scope = ((struct __pyx_obj_2ml___pyx_scope_struct__ml *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_s); - p->__pyx_v_s = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_t_1); - p->__pyx_t_1 = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyTypeObject __pyx_type_2ml___pyx_scope_struct_1_genexpr = { - PyVarObject_HEAD_INIT(0, 0) - "ml.__pyx_scope_struct_1_genexpr", /*tp_name*/ - sizeof(struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_2ml___pyx_scope_struct_1_genexpr, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #else - 0, /*reserved*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_2ml___pyx_scope_struct_1_genexpr, /*tp_traverse*/ - __pyx_tp_clear_2ml___pyx_scope_struct_1_genexpr, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - 0, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_2ml___pyx_scope_struct_1_genexpr, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; @@ -5226,18 +5304,17 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_age, __pyx_k_age, sizeof(__pyx_k_age), 0, 0, 1, 1}, {&__pyx_n_s_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 0, 0, 1, 1}, {&__pyx_n_s_arange, __pyx_k_arange, sizeof(__pyx_k_arange), 0, 0, 1, 1}, - {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, {&__pyx_n_s_beta, __pyx_k_beta, sizeof(__pyx_k_beta), 0, 0, 1, 1}, {&__pyx_n_s_beta_add, __pyx_k_beta_add, sizeof(__pyx_k_beta_add), 0, 0, 1, 1}, - {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, {&__pyx_n_s_delta, __pyx_k_delta, sizeof(__pyx_k_delta), 0, 0, 1, 1}, {&__pyx_n_s_dist, __pyx_k_dist, sizeof(__pyx_k_dist), 0, 0, 1, 1}, + {&__pyx_n_s_dists, __pyx_k_dists, sizeof(__pyx_k_dists), 0, 0, 1, 1}, {&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1}, + {&__pyx_n_s_dts, __pyx_k_dts, sizeof(__pyx_k_dts), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 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_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}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_kp_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 0}, @@ -5245,34 +5322,37 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1}, {&__pyx_n_s_ll, __pyx_k_ll, sizeof(__pyx_k_ll), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1}, {&__pyx_n_s_max_beta, __pyx_k_max_beta, sizeof(__pyx_k_max_beta), 0, 0, 1, 1}, {&__pyx_n_s_max_beta_add, __pyx_k_max_beta_add, sizeof(__pyx_k_max_beta_add), 0, 0, 1, 1}, {&__pyx_n_s_max_roots, __pyx_k_max_roots, sizeof(__pyx_k_max_roots), 0, 0, 1, 1}, {&__pyx_n_s_ml, __pyx_k_ml, sizeof(__pyx_k_ml), 0, 0, 1, 1}, - {&__pyx_n_s_ml_locals_genexpr, __pyx_k_ml_locals_genexpr, sizeof(__pyx_k_ml_locals_genexpr), 0, 0, 1, 1}, {&__pyx_n_s_n_nodes, __pyx_k_n_nodes, sizeof(__pyx_k_n_nodes), 0, 0, 1, 1}, {&__pyx_n_s_n_roots, __pyx_k_n_roots, sizeof(__pyx_k_n_roots), 0, 0, 1, 1}, {&__pyx_n_s_n_victims, __pyx_k_n_victims, sizeof(__pyx_k_n_victims), 0, 0, 1, 1}, {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, + {&__pyx_n_s_non_seeds, __pyx_k_non_seeds, sizeof(__pyx_k_non_seeds), 0, 0, 1, 1}, {&__pyx_n_s_non_victims, __pyx_k_non_victims, sizeof(__pyx_k_non_victims), 0, 0, 1, 1}, {&__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_parent_dists, __pyx_k_parent_dists, sizeof(__pyx_k_parent_dists), 0, 0, 1, 1}, + {&__pyx_n_s_parent_dts, __pyx_k_parent_dts, sizeof(__pyx_k_parent_dts), 0, 0, 1, 1}, {&__pyx_n_s_parents, __pyx_k_parents, sizeof(__pyx_k_parents), 0, 0, 1, 1}, + {&__pyx_n_s_prnt, __pyx_k_prnt, sizeof(__pyx_k_prnt), 0, 0, 1, 1}, + {&__pyx_n_s_prob, __pyx_k_prob, sizeof(__pyx_k_prob), 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}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_root_victims, __pyx_k_root_victims, sizeof(__pyx_k_root_victims), 0, 0, 1, 1}, {&__pyx_n_s_roots, __pyx_k_roots, sizeof(__pyx_k_roots), 0, 0, 1, 1}, - {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, + {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1}, + {&__pyx_n_s_seeds, __pyx_k_seeds, sizeof(__pyx_k_seeds), 0, 0, 1, 1}, {&__pyx_n_s_successes, __pyx_k_successes, sizeof(__pyx_k_successes), 0, 0, 1, 1}, {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1}, {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_thresh, __pyx_k_thresh, sizeof(__pyx_k_thresh), 0, 0, 1, 1}, - {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1}, {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, {&__pyx_n_s_victims, __pyx_k_victims, sizeof(__pyx_k_victims), 0, 0, 1, 1}, {&__pyx_n_s_w1, __pyx_k_w1, sizeof(__pyx_k_w1), 0, 0, 1, 1}, @@ -5282,9 +5362,8 @@ 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 = 49; __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 = 55; __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 = 59; __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 = 43; __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 = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __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;} __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -5297,14 +5376,14 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "ml.pyx":83 + /* "ml.pyx":80 * max_beta_add = float('-inf') * # iterate over all victim nodes to find the optimal threshold - * for beta in np.arange(0.001, .2, .002): # <<<<<<<<<<<<<< + * for beta in np.arange(0.01, 1., .01): # <<<<<<<<<<<<<< * thresh = log(beta/(3012.*(1.-beta))) - * # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh]) + * seeds = probs= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (PyErr_ExceptionMatches(PyExc_OverflowError)) - PyErr_Clear(); - else - return NULL; - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; #if CYTHON_COMPILING_IN_CPYTHON @@ -6740,57 +6732,135 @@ static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* iter_obj, Py_ssize_t ori if (unlikely(!next_item)) { return __Pyx_IterFinish(); } - } - if (pitem) { - *pitem = next_item; - } else if (pkey && pvalue) { - if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1)) - return -1; - } else if (pkey) { - *pkey = next_item; + } + if (pitem) { + *pitem = next_item; + } else if (pkey && pvalue) { + if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1)) + return -1; + } else if (pkey) { + *pkey = next_item; + } else { + *pvalue = next_item; + } + return 1; +} + +static double __Pyx__PyObject_AsDouble(PyObject* obj) { + PyObject* float_value; +#if CYTHON_COMPILING_IN_PYPY + float_value = PyNumber_Float(obj); +#else + PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number; + if (likely(nb) && likely(nb->nb_float)) { + float_value = nb->nb_float(obj); + if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) { + PyErr_Format(PyExc_TypeError, + "__float__ returned non-float (type %.200s)", + Py_TYPE(float_value)->tp_name); + Py_DECREF(float_value); + goto bad; + } + } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) { +#if PY_MAJOR_VERSION >= 3 + float_value = PyFloat_FromString(obj); +#else + float_value = PyFloat_FromString(obj, 0); +#endif + } else { + PyObject* args = PyTuple_New(1); + if (unlikely(!args)) goto bad; + PyTuple_SET_ITEM(args, 0, obj); + float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0); + PyTuple_SET_ITEM(args, 0, 0); + Py_DECREF(args); + } +#endif + if (likely(float_value)) { + double value = PyFloat_AS_DOUBLE(float_value); + Py_DECREF(float_value); + return value; + } +bad: + return (double)-1; +} + +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } } else { - *pvalue = next_item; - } - return 1; -} - -static double __Pyx__PyObject_AsDouble(PyObject* obj) { - PyObject* float_value; -#if CYTHON_COMPILING_IN_PYPY - float_value = PyNumber_Float(obj); -#else - PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number; - if (likely(nb) && likely(nb->nb_float)) { - float_value = nb->nb_float(obj); - if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) { - PyErr_Format(PyExc_TypeError, - "__float__ returned non-float (type %.200s)", - Py_TYPE(float_value)->tp_name); - Py_DECREF(float_value); - goto bad; + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + return NULL; + } + } + return m->sq_item(o, i); } - } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) { -#if PY_MAJOR_VERSION >= 3 - float_value = PyFloat_FromString(obj); + } #else - float_value = PyFloat_FromString(obj, 0); -#endif - } else { - PyObject* args = PyTuple_New(1); - if (unlikely(!args)) goto bad; - PyTuple_SET_ITEM(args, 0, obj); - float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0); - PyTuple_SET_ITEM(args, 0, 0); - Py_DECREF(args); + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); } #endif - if (likely(float_value)) { - double value = PyFloat_AS_DOUBLE(float_value); - Py_DECREF(float_value); - return value; - } -bad: - return (double)-1; + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { @@ -7737,639 +7807,6 @@ raise_neg_overflow: return (long) -1; } -static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { - PyObject* fake_module; - PyTypeObject* cached_type = NULL; - fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); - if (!fake_module) return NULL; - Py_INCREF(fake_module); - cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); - if (cached_type) { - if (!PyType_Check((PyObject*)cached_type)) { - PyErr_Format(PyExc_TypeError, - "Shared Cython type %.200s is not a type object", - type->tp_name); - goto bad; - } - if (cached_type->tp_basicsize != type->tp_basicsize) { - PyErr_Format(PyExc_TypeError, - "Shared Cython type %.200s has the wrong size, try recompiling", - type->tp_name); - goto bad; - } - } else { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; - PyErr_Clear(); - if (PyType_Ready(type) < 0) goto bad; - if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) - goto bad; - Py_INCREF(type); - cached_type = type; - } -done: - Py_DECREF(fake_module); - return cached_type; -bad: - Py_XDECREF(cached_type); - cached_type = NULL; - goto done; -} - -static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; -#if CYTHON_COMPILING_IN_CPYTHON - PyThreadState *tstate = PyThreadState_GET(); - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = *type; - tstate->exc_value = *value; - tstate->exc_traceback = *tb; -#else - PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); - PyErr_SetExcInfo(*type, *value, *tb); -#endif - *type = tmp_type; - *value = tmp_value; - *tb = tmp_tb; -} - -static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { - PyObject *method, *result = NULL; - method = __Pyx_PyObject_GetAttrStr(obj, method_name); - if (unlikely(!method)) goto bad; -#if CYTHON_COMPILING_IN_CPYTHON - if (likely(PyMethod_Check(method))) { - PyObject *self = PyMethod_GET_SELF(method); - if (likely(self)) { - PyObject *args; - PyObject *function = PyMethod_GET_FUNCTION(method); - args = PyTuple_New(2); - if (unlikely(!args)) goto bad; - Py_INCREF(self); - PyTuple_SET_ITEM(args, 0, self); - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 1, arg); - Py_INCREF(function); - Py_DECREF(method); method = NULL; - result = __Pyx_PyObject_Call(function, args, NULL); - Py_DECREF(args); - Py_DECREF(function); - return result; - } - } -#endif - result = __Pyx_PyObject_CallOneArg(method, arg); -bad: - Py_XDECREF(method); - return result; -} - -static PyObject *__Pyx_Generator_Next(PyObject *self); -static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value); -static PyObject *__Pyx_Generator_Close(PyObject *self); -static PyObject *__Pyx_Generator_Throw(PyObject *gen, PyObject *args); -static PyTypeObject *__pyx_GeneratorType = 0; -#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType) -#define __Pyx_Generator_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) -#if 1 || PY_VERSION_HEX < 0x030300B0 -static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) { - PyObject *et, *ev, *tb; - PyObject *value = NULL; - __Pyx_ErrFetch(&et, &ev, &tb); - if (!et) { - Py_XDECREF(tb); - Py_XDECREF(ev); - Py_INCREF(Py_None); - *pvalue = Py_None; - return 0; - } - if (unlikely(et != PyExc_StopIteration) && - unlikely(!PyErr_GivenExceptionMatches(et, PyExc_StopIteration))) { - __Pyx_ErrRestore(et, ev, tb); - return -1; - } - if (likely(et == PyExc_StopIteration)) { - if (likely(!ev) || !PyObject_IsInstance(ev, PyExc_StopIteration)) { - if (!ev) { - Py_INCREF(Py_None); - ev = Py_None; - } - Py_XDECREF(tb); - Py_DECREF(et); - *pvalue = ev; - return 0; - } - } - PyErr_NormalizeException(&et, &ev, &tb); - if (unlikely(!PyObject_IsInstance(ev, PyExc_StopIteration))) { - __Pyx_ErrRestore(et, ev, tb); - return -1; - } - Py_XDECREF(tb); - Py_DECREF(et); -#if PY_VERSION_HEX >= 0x030300A0 - value = ((PyStopIterationObject *)ev)->value; - Py_INCREF(value); - Py_DECREF(ev); -#else - { - PyObject* args = PyObject_GetAttr(ev, __pyx_n_s_args); - Py_DECREF(ev); - if (likely(args)) { - value = PyObject_GetItem(args, 0); - Py_DECREF(args); - } - if (unlikely(!value)) { - __Pyx_ErrRestore(NULL, NULL, NULL); - Py_INCREF(Py_None); - value = Py_None; - } - } -#endif - *pvalue = value; - return 0; -} -#endif -static CYTHON_INLINE -void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self) { - PyObject *exc_type = self->exc_type; - PyObject *exc_value = self->exc_value; - PyObject *exc_traceback = self->exc_traceback; - self->exc_type = NULL; - self->exc_value = NULL; - self->exc_traceback = NULL; - Py_XDECREF(exc_type); - Py_XDECREF(exc_value); - Py_XDECREF(exc_traceback); -} -static CYTHON_INLINE -int __Pyx_Generator_CheckRunning(__pyx_GeneratorObject *gen) { - if (unlikely(gen->is_running)) { - PyErr_SetString(PyExc_ValueError, - "generator already executing"); - return 1; - } - return 0; -} -static CYTHON_INLINE -PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) { - PyObject *retval; - assert(!self->is_running); - if (unlikely(self->resume_label == 0)) { - if (unlikely(value && value != Py_None)) { - PyErr_SetString(PyExc_TypeError, - "can't send non-None value to a " - "just-started generator"); - return NULL; - } - } - if (unlikely(self->resume_label == -1)) { - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } - if (value) { -#if CYTHON_COMPILING_IN_PYPY -#else - if (self->exc_traceback) { - PyThreadState *tstate = PyThreadState_GET(); - PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; - PyFrameObject *f = tb->tb_frame; - Py_XINCREF(tstate->frame); - assert(f->f_back == NULL); - f->f_back = tstate->frame; - } -#endif - __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, - &self->exc_traceback); - } else { - __Pyx_Generator_ExceptionClear(self); - } - self->is_running = 1; - retval = self->body((PyObject *) self, value); - self->is_running = 0; - if (retval) { - __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value, - &self->exc_traceback); -#if CYTHON_COMPILING_IN_PYPY -#else - if (self->exc_traceback) { - PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback; - PyFrameObject *f = tb->tb_frame; - Py_CLEAR(f->f_back); - } -#endif - } else { - __Pyx_Generator_ExceptionClear(self); - } - return retval; -} -static CYTHON_INLINE -PyObject *__Pyx_Generator_FinishDelegation(__pyx_GeneratorObject *gen) { - PyObject *ret; - PyObject *val = NULL; - __Pyx_Generator_Undelegate(gen); - __Pyx_PyGen_FetchStopIterationValue(&val); - ret = __Pyx_Generator_SendEx(gen, val); - Py_XDECREF(val); - return ret; -} -static PyObject *__Pyx_Generator_Next(PyObject *self) { - __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self; - PyObject *yf = gen->yieldfrom; - if (unlikely(__Pyx_Generator_CheckRunning(gen))) - return NULL; - if (yf) { - PyObject *ret; - gen->is_running = 1; - ret = Py_TYPE(yf)->tp_iternext(yf); - gen->is_running = 0; - if (likely(ret)) { - return ret; - } - return __Pyx_Generator_FinishDelegation(gen); - } - return __Pyx_Generator_SendEx(gen, Py_None); -} -static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) { - __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self; - PyObject *yf = gen->yieldfrom; - if (unlikely(__Pyx_Generator_CheckRunning(gen))) - return NULL; - if (yf) { - PyObject *ret; - gen->is_running = 1; - if (__Pyx_Generator_CheckExact(yf)) { - ret = __Pyx_Generator_Send(yf, value); - } else { - if (value == Py_None) - ret = PyIter_Next(yf); - else - ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value); - } - gen->is_running = 0; - if (likely(ret)) { - return ret; - } - return __Pyx_Generator_FinishDelegation(gen); - } - return __Pyx_Generator_SendEx(gen, value); -} -static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) { - PyObject *retval = NULL; - int err = 0; - if (__Pyx_Generator_CheckExact(yf)) { - retval = __Pyx_Generator_Close(yf); - if (!retval) - return -1; - } else { - PyObject *meth; - gen->is_running = 1; - meth = PyObject_GetAttr(yf, __pyx_n_s_close); - if (unlikely(!meth)) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_WriteUnraisable(yf); - } - PyErr_Clear(); - } else { - retval = PyObject_CallFunction(meth, NULL); - Py_DECREF(meth); - if (!retval) - err = -1; - } - gen->is_running = 0; - } - Py_XDECREF(retval); - return err; -} -static PyObject *__Pyx_Generator_Close(PyObject *self) { - __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; - PyObject *retval, *raised_exception; - PyObject *yf = gen->yieldfrom; - int err = 0; - if (unlikely(__Pyx_Generator_CheckRunning(gen))) - return NULL; - if (yf) { - Py_INCREF(yf); - err = __Pyx_Generator_CloseIter(gen, yf); - __Pyx_Generator_Undelegate(gen); - Py_DECREF(yf); - } - if (err == 0) - PyErr_SetNone(PyExc_GeneratorExit); - retval = __Pyx_Generator_SendEx(gen, NULL); - if (retval) { - Py_DECREF(retval); - PyErr_SetString(PyExc_RuntimeError, - "generator ignored GeneratorExit"); - return NULL; - } - raised_exception = PyErr_Occurred(); - if (!raised_exception - || raised_exception == PyExc_StopIteration - || raised_exception == PyExc_GeneratorExit - || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit) - || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration)) - { - if (raised_exception) PyErr_Clear(); - Py_INCREF(Py_None); - return Py_None; - } - return NULL; -} -static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) { - __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; - PyObject *typ; - PyObject *tb = NULL; - PyObject *val = NULL; - PyObject *yf = gen->yieldfrom; - if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) - return NULL; - if (unlikely(__Pyx_Generator_CheckRunning(gen))) - return NULL; - if (yf) { - PyObject *ret; - Py_INCREF(yf); - if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) { - int err = __Pyx_Generator_CloseIter(gen, yf); - Py_DECREF(yf); - __Pyx_Generator_Undelegate(gen); - if (err < 0) - return __Pyx_Generator_SendEx(gen, NULL); - goto throw_here; - } - gen->is_running = 1; - if (__Pyx_Generator_CheckExact(yf)) { - ret = __Pyx_Generator_Throw(yf, args); - } else { - PyObject *meth = PyObject_GetAttr(yf, __pyx_n_s_throw); - if (unlikely(!meth)) { - Py_DECREF(yf); - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { - gen->is_running = 0; - return NULL; - } - PyErr_Clear(); - __Pyx_Generator_Undelegate(gen); - gen->is_running = 0; - goto throw_here; - } - ret = PyObject_CallObject(meth, args); - Py_DECREF(meth); - } - gen->is_running = 0; - Py_DECREF(yf); - if (!ret) { - ret = __Pyx_Generator_FinishDelegation(gen); - } - return ret; - } -throw_here: - __Pyx_Raise(typ, val, tb, NULL); - return __Pyx_Generator_SendEx(gen, NULL); -} -static int __Pyx_Generator_traverse(PyObject *self, visitproc visit, void *arg) { - __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; - Py_VISIT(gen->closure); - Py_VISIT(gen->classobj); - Py_VISIT(gen->yieldfrom); - Py_VISIT(gen->exc_type); - Py_VISIT(gen->exc_value); - Py_VISIT(gen->exc_traceback); - return 0; -} -static int __Pyx_Generator_clear(PyObject *self) { - __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; - Py_CLEAR(gen->closure); - Py_CLEAR(gen->classobj); - Py_CLEAR(gen->yieldfrom); - Py_CLEAR(gen->exc_type); - Py_CLEAR(gen->exc_value); - Py_CLEAR(gen->exc_traceback); - Py_CLEAR(gen->gi_name); - Py_CLEAR(gen->gi_qualname); - return 0; -} -static void __Pyx_Generator_dealloc(PyObject *self) { - __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; - PyObject_GC_UnTrack(gen); - if (gen->gi_weakreflist != NULL) - PyObject_ClearWeakRefs(self); - if (gen->resume_label > 0) { - PyObject_GC_Track(self); -#if PY_VERSION_HEX >= 0x030400a1 - if (PyObject_CallFinalizerFromDealloc(self)) -#else - Py_TYPE(gen)->tp_del(self); - if (self->ob_refcnt > 0) -#endif - { - return; - } - PyObject_GC_UnTrack(self); - } - __Pyx_Generator_clear(self); - PyObject_GC_Del(gen); -} -static void __Pyx_Generator_del(PyObject *self) { - PyObject *res; - PyObject *error_type, *error_value, *error_traceback; - __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; - if (gen->resume_label <= 0) - return ; -#if PY_VERSION_HEX < 0x030400a1 - assert(self->ob_refcnt == 0); - self->ob_refcnt = 1; -#endif - __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); - res = __Pyx_Generator_Close(self); - if (res == NULL) - PyErr_WriteUnraisable(self); - else - Py_DECREF(res); - __Pyx_ErrRestore(error_type, error_value, error_traceback); -#if PY_VERSION_HEX < 0x030400a1 - assert(self->ob_refcnt > 0); - if (--self->ob_refcnt == 0) { - return; - } - { - Py_ssize_t refcnt = self->ob_refcnt; - _Py_NewReference(self); - self->ob_refcnt = refcnt; - } -#if CYTHON_COMPILING_IN_CPYTHON - assert(PyType_IS_GC(self->ob_type) && - _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); - _Py_DEC_REFTOTAL; -#endif -#ifdef COUNT_ALLOCS - --Py_TYPE(self)->tp_frees; - --Py_TYPE(self)->tp_allocs; -#endif -#endif -} -static PyObject * -__Pyx_Generator_get_name(__pyx_GeneratorObject *self) -{ - Py_INCREF(self->gi_name); - return self->gi_name; -} -static int -__Pyx_Generator_set_name(__pyx_GeneratorObject *self, PyObject *value) -{ - PyObject *tmp; -#if PY_MAJOR_VERSION >= 3 - if (unlikely(value == NULL || !PyUnicode_Check(value))) { -#else - if (unlikely(value == NULL || !PyString_Check(value))) { -#endif - PyErr_SetString(PyExc_TypeError, - "__name__ must be set to a string object"); - return -1; - } - tmp = self->gi_name; - Py_INCREF(value); - self->gi_name = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_Generator_get_qualname(__pyx_GeneratorObject *self) -{ - Py_INCREF(self->gi_qualname); - return self->gi_qualname; -} -static int -__Pyx_Generator_set_qualname(__pyx_GeneratorObject *self, PyObject *value) -{ - PyObject *tmp; -#if PY_MAJOR_VERSION >= 3 - if (unlikely(value == NULL || !PyUnicode_Check(value))) { -#else - if (unlikely(value == NULL || !PyString_Check(value))) { -#endif - PyErr_SetString(PyExc_TypeError, - "__qualname__ must be set to a string object"); - return -1; - } - tmp = self->gi_qualname; - Py_INCREF(value); - self->gi_qualname = value; - Py_XDECREF(tmp); - return 0; -} -static PyGetSetDef __pyx_Generator_getsets[] = { - {(char *) "__name__", (getter)__Pyx_Generator_get_name, (setter)__Pyx_Generator_set_name, - (char*) PyDoc_STR("name of the generator"), 0}, - {(char *) "__qualname__", (getter)__Pyx_Generator_get_qualname, (setter)__Pyx_Generator_set_qualname, - (char*) PyDoc_STR("qualified name of the generator"), 0}, - {0, 0, 0, 0, 0} -}; -static PyMemberDef __pyx_Generator_memberlist[] = { - {(char *) "gi_running", T_BOOL, offsetof(__pyx_GeneratorObject, is_running), READONLY, NULL}, - {0, 0, 0, 0, 0} -}; -static PyMethodDef __pyx_Generator_methods[] = { - {"send", (PyCFunction) __Pyx_Generator_Send, METH_O, 0}, - {"throw", (PyCFunction) __Pyx_Generator_Throw, METH_VARARGS, 0}, - {"close", (PyCFunction) __Pyx_Generator_Close, METH_NOARGS, 0}, - {0, 0, 0, 0} -}; -static PyTypeObject __pyx_GeneratorType_type = { - PyVarObject_HEAD_INIT(0, 0) - "generator", - sizeof(__pyx_GeneratorObject), - 0, - (destructor) __Pyx_Generator_dealloc, - 0, - 0, - 0, -#if PY_MAJOR_VERSION < 3 - 0, -#else - 0, -#endif - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, - 0, - (traverseproc) __Pyx_Generator_traverse, - 0, - 0, - offsetof(__pyx_GeneratorObject, gi_weakreflist), - 0, - (iternextfunc) __Pyx_Generator_Next, - __pyx_Generator_methods, - __pyx_Generator_memberlist, - __pyx_Generator_getsets, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, -#if PY_VERSION_HEX >= 0x030400a1 - 0, -#else - __Pyx_Generator_del, -#endif - 0, -#if PY_VERSION_HEX >= 0x030400a1 - __Pyx_Generator_del, -#endif -}; -static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body, - PyObject *closure, PyObject *name, PyObject *qualname) { - __pyx_GeneratorObject *gen = - PyObject_GC_New(__pyx_GeneratorObject, &__pyx_GeneratorType_type); - if (gen == NULL) - return NULL; - gen->body = body; - gen->closure = closure; - Py_XINCREF(closure); - gen->is_running = 0; - gen->resume_label = 0; - gen->classobj = NULL; - gen->yieldfrom = NULL; - gen->exc_type = NULL; - gen->exc_value = NULL; - gen->exc_traceback = NULL; - gen->gi_weakreflist = NULL; - Py_XINCREF(qualname); - gen->gi_qualname = qualname; - Py_XINCREF(name); - gen->gi_name = name; - PyObject_GC_Track(gen); - return gen; -} -static int __pyx_Generator_init(void) { - __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr; - __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; - __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type); - if (__pyx_GeneratorType == NULL) { - return -1; - } - return 0; -} - static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); diff --git a/experiments/ml.pyx b/experiments/ml.pyx index c8c99cc..858207f 100644 --- a/experiments/ml.pyx +++ b/experiments/ml.pyx @@ -10,14 +10,9 @@ 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 = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - temporal = log(exp(alpha)-1.) - alpha*dt - # temporal = 1 - exp(-alpha*dt) - # 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 - # print 'st', structural, temporal + structural = delta ** dist + temporal = log(exp(alpha)-1.) - alpha*dt/7. + result = log(structural) + temporal return result cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, @@ -25,17 +20,14 @@ cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, """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 = exp(-alpha * dt) - # temporal = 1. - 1. / (1. + dt/alpha)**0.01 + temporal = exp(-alpha * dt/7.) 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, DTYPE_t alpha, DTYPE_t delta): cdef: - int n_roots, n_victims, n_nodes, roots, i, dist, dt, t, l + int n_roots, n_victims, roots, i, dist, dt, t, l DTYPE_t beta, ll, beta_add, max_beta, max_beta_add list parents, failures, successes n_roots, n_victims = len(root_victims), len(victims) @@ -43,6 +35,8 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, 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] parent_dists = np.zeros(n_victims, dtype=DTYPE) + np.ndarray[DTYPE_t] parent_dts = np.zeros(n_victims, dtype=DTYPE) np.ndarray[DTYPE_t] probs_nv = np.zeros(len(non_victims), dtype=DTYPE) # loop through victims @@ -51,43 +45,47 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # 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] + for (prnt, 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] + for (prnt, dist, dt, w1, w2, w3) in parents] + dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] + dts = [dt for (prnt, 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)) + # probs[i] = max(s - failures[l] for l, s in enumerate(successes)) + probs[i] = float("-inf") + for l, s in enumerate(successes): + prob = s - failures[l] + if prob > probs[i]: + probs[i] = prob + parent_dists[i] = dists[l] + parent_dts[i] = dts[l] + # probs_fail[i] = failures[l] # loop through non-victims for i, parents in enumerate(non_victims.itervalues()): # 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] + for (prnt, dist, dt, w1, w2, w3) in parents] probs_nv[i] = sum(failures) - # print successes - # print failures - # print probs - # calculate log likelihood - # probs.sort(); probs = probs[::-1] # sort probs in descending order - # cdef: - # np.ndarray[DTYPE_t] cums = probs.cumsum() - ll = probs_fail.sum() # add probability that all edges to victims fail + ll = probs_fail.sum() # add probability that all edges to all victims fail ll += probs_nv.sum() # add probability that all edges to non_victims fail # print 'probs', probs max_beta_add = float('-inf') # iterate over all victim nodes to find the optimal threshold - for beta in np.arange(0.001, .2, .002): + for beta in np.arange(0.01, 1., .01): thresh = log(beta/(3012.*(1.-beta))) - # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh]) - roots = n_roots + len(probs[probs=thresh + roots = n_roots + sum(seeds) beta_add = 0. # add probability for realized edges and subtract probability these edges fail - beta_add += (probs[probs>=thresh]).sum() + beta_add += (probs[non_seeds]).sum() # add probability for the seeds and non-seeds beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) diff --git a/experiments/ml.so b/experiments/ml.so index 7832e67..a08d635 100755 Binary files a/experiments/ml.so and b/experiments/ml.so differ diff --git a/experiments/ml3.c b/experiments/ml3.c index 59de174..7ad3edb 100644 --- a/experiments/ml3.c +++ b/experiments/ml3.c @@ -695,7 +695,7 @@ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; * DTYPE = np.float64 * ctypedef np.float_t DTYPE_t # <<<<<<<<<<<<<< * - * cdef DTYPE_t weight_success(int dist, DTYPE_t dt, DTYPE_t alpha, DTYPE_t delta, + * cdef DTYPE_t weight_success(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, */ typedef __pyx_t_5numpy_float_t __pyx_t_3ml3_DTYPE_t; #if CYTHON_CCOMPLEX @@ -1169,8 +1169,8 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, cha /* Module declarations from 'libc.math' */ /* Module declarations from 'ml3' */ -static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_success(int, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t); /*proto*/ -static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_failure(int, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t); /*proto*/ +static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_success(int, int, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t); /*proto*/ +static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_failure(int, int, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t, __pyx_t_3ml3_DTYPE_t); /*proto*/ static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_3ml3_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_3ml3_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; #define __Pyx_MODULE_NAME "ml3" int __pyx_module_is_main_ml3 = 0; @@ -1217,7 +1217,7 @@ static char __pyx_k_sum[] = "sum"; static char __pyx_k_beta[] = "beta"; static char __pyx_k_dist[] = "dist"; static char __pyx_k_main[] = "__main__"; -static char __pyx_k_ones[] = "ones"; +static char __pyx_k_prnt[] = "prnt"; static char __pyx_k_prob[] = "prob"; static char __pyx_k_test[] = "__test__"; static char __pyx_k_DTYPE[] = "DTYPE"; @@ -1233,7 +1233,6 @@ static char __pyx_k_seeds[] = "seeds"; static char __pyx_k_zeros[] = "zeros"; static char __pyx_k_arange[] = "arange"; static char __pyx_k_import[] = "__import__"; -static char __pyx_k_isSeed[] = "isSeed"; static char __pyx_k_thresh[] = "thresh"; static char __pyx_k_float64[] = "float64"; static char __pyx_k_n_roots[] = "n_roots"; @@ -1287,7 +1286,6 @@ static PyObject *__pyx_n_s_float64; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_import; static PyObject *__pyx_kp_s_inf; -static PyObject *__pyx_n_s_isSeed; static PyObject *__pyx_n_s_itervalues; static PyObject *__pyx_n_s_l; static PyObject *__pyx_n_s_ll; @@ -1304,10 +1302,10 @@ static PyObject *__pyx_n_s_non_seeds; static PyObject *__pyx_n_s_non_victims; static PyObject *__pyx_n_s_np; static PyObject *__pyx_n_s_numpy; -static PyObject *__pyx_n_s_ones; static PyObject *__pyx_n_s_parent_dists; static PyObject *__pyx_n_s_parent_dts; static PyObject *__pyx_n_s_parents; +static PyObject *__pyx_n_s_prnt; static PyObject *__pyx_n_s_prob; static PyObject *__pyx_n_s_probs; static PyObject *__pyx_n_s_probs_fail; @@ -1327,9 +1325,8 @@ static PyObject *__pyx_n_s_w1; static PyObject *__pyx_n_s_w2; static PyObject *__pyx_n_s_w3; static PyObject *__pyx_n_s_zeros; -static PyObject *__pyx_float_1_; -static PyObject *__pyx_float_0_00001; -static PyObject *__pyx_int_0; +static PyObject *__pyx_float__01; +static PyObject *__pyx_float_0_01; static PyObject *__pyx_int_1; static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; @@ -1344,12 +1341,12 @@ static PyObject *__pyx_codeobj__9; /* "ml3.pyx":9 * ctypedef np.float_t DTYPE_t * - * cdef DTYPE_t weight_success(int dist, DTYPE_t dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<< + * 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""" */ -static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_success(int __pyx_v_dist, __pyx_t_3ml3_DTYPE_t __pyx_v_dt, __pyx_t_3ml3_DTYPE_t __pyx_v_alpha, __pyx_t_3ml3_DTYPE_t __pyx_v_delta, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w1, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w2, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w3) { +static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_success(int __pyx_v_dist, int __pyx_v_dt, __pyx_t_3ml3_DTYPE_t __pyx_v_alpha, __pyx_t_3ml3_DTYPE_t __pyx_v_delta, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w1, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w2, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w3) { __pyx_t_3ml3_DTYPE_t __pyx_v_structural; __pyx_t_3ml3_DTYPE_t __pyx_v_temporal; __pyx_t_3ml3_DTYPE_t __pyx_v_result; @@ -1389,7 +1386,7 @@ static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_success(int __pyx_v_dist, __pyx_ * result = log(structural) + temporal * return result # <<<<<<<<<<<<<< * - * cdef DTYPE_t weight_failure(int dist, DTYPE_t dt, DTYPE_t alpha, DTYPE_t delta, + * cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, */ __pyx_r = __pyx_v_result; goto __pyx_L0; @@ -1397,7 +1394,7 @@ static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_success(int __pyx_v_dist, __pyx_ /* "ml3.pyx":9 * ctypedef np.float_t DTYPE_t * - * cdef DTYPE_t weight_success(int dist, DTYPE_t dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<< + * 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""" */ @@ -1411,12 +1408,12 @@ static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_success(int __pyx_v_dist, __pyx_ /* "ml3.pyx":18 * return result * - * cdef DTYPE_t weight_failure(int dist, DTYPE_t dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<< + * cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<< * DTYPE_t w1, DTYPE_t w2, DTYPE_t w3): * """weight for failed infection, exponential time model""" */ -static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_failure(int __pyx_v_dist, __pyx_t_3ml3_DTYPE_t __pyx_v_dt, __pyx_t_3ml3_DTYPE_t __pyx_v_alpha, __pyx_t_3ml3_DTYPE_t __pyx_v_delta, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w1, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w2, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w3) { +static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_failure(int __pyx_v_dist, int __pyx_v_dt, __pyx_t_3ml3_DTYPE_t __pyx_v_alpha, __pyx_t_3ml3_DTYPE_t __pyx_v_delta, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w1, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w2, CYTHON_UNUSED __pyx_t_3ml3_DTYPE_t __pyx_v_w3) { __pyx_t_3ml3_DTYPE_t __pyx_v_structural; __pyx_t_3ml3_DTYPE_t __pyx_v_temporal; __pyx_t_3ml3_DTYPE_t __pyx_v_result; @@ -1464,7 +1461,7 @@ static __pyx_t_3ml3_DTYPE_t __pyx_f_3ml3_weight_failure(int __pyx_v_dist, __pyx_ /* "ml3.pyx":18 * return result * - * cdef DTYPE_t weight_failure(int dist, DTYPE_t dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<< + * cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<< * DTYPE_t w1, DTYPE_t w2, DTYPE_t w3): * """weight for failed infection, exponential time model""" */ @@ -1608,20 +1605,18 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject PyArrayObject *__pyx_v_probs_fail = 0; PyArrayObject *__pyx_v_parent_dists = 0; PyArrayObject *__pyx_v_parent_dts = 0; - PyArrayObject *__pyx_v_isSeed = 0; PyObject *__pyx_v_dists = NULL; PyObject *__pyx_v_dts = NULL; PyObject *__pyx_v_s = NULL; PyObject *__pyx_v_prob = NULL; - CYTHON_UNUSED double __pyx_v_thresh; + double __pyx_v_thresh; PyObject *__pyx_v_seeds = NULL; PyObject *__pyx_v_non_seeds = NULL; int __pyx_v_max_roots; + CYTHON_UNUSED PyObject *__pyx_v_prnt = NULL; PyObject *__pyx_v_w1 = NULL; PyObject *__pyx_v_w2 = NULL; PyObject *__pyx_v_w3 = NULL; - __Pyx_LocalBuf_ND __pyx_pybuffernd_isSeed; - __Pyx_Buffer __pyx_pybuffer_isSeed; __Pyx_LocalBuf_ND __pyx_pybuffernd_parent_dists; __Pyx_Buffer __pyx_pybuffer_parent_dists; __Pyx_LocalBuf_ND __pyx_pybuffernd_parent_dts; @@ -1642,11 +1637,11 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject PyArrayObject *__pyx_t_8 = NULL; PyArrayObject *__pyx_t_9 = NULL; PyArrayObject *__pyx_t_10 = NULL; - PyArrayObject *__pyx_t_11 = NULL; + int __pyx_t_11; int __pyx_t_12; int __pyx_t_13; - int __pyx_t_14; - Py_ssize_t __pyx_t_15; + Py_ssize_t __pyx_t_14; + PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; @@ -1686,10 +1681,6 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __pyx_pybuffer_parent_dts.refcount = 0; __pyx_pybuffernd_parent_dts.data = NULL; __pyx_pybuffernd_parent_dts.rcbuffer = &__pyx_pybuffer_parent_dts; - __pyx_pybuffer_isSeed.pybuffer.buf = NULL; - __pyx_pybuffer_isSeed.refcount = 0; - __pyx_pybuffernd_isSeed.data = NULL; - __pyx_pybuffernd_isSeed.rcbuffer = &__pyx_pybuffer_isSeed; /* "ml3.pyx":33 * DTYPE_t beta, ll, beta_add, max_beta, max_beta_add @@ -1804,7 +1795,7 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject * np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE) * np.ndarray[DTYPE_t] parent_dists = np.zeros(n_victims, dtype=DTYPE) # <<<<<<<<<<<<<< * np.ndarray[DTYPE_t] parent_dts = np.zeros(n_victims, dtype=DTYPE) - * np.ndarray[DTYPE_t] isSeed = np.ones(n_victims, dtype=DTYPE) + * */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); @@ -1847,8 +1838,8 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject * np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE) * np.ndarray[DTYPE_t] parent_dists = np.zeros(n_victims, dtype=DTYPE) * np.ndarray[DTYPE_t] parent_dts = np.zeros(n_victims, dtype=DTYPE) # <<<<<<<<<<<<<< - * np.ndarray[DTYPE_t] isSeed = np.ones(n_victims, dtype=DTYPE) * + * # loop through victims */ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); @@ -1887,134 +1878,93 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __pyx_v_parent_dts = ((PyArrayObject *)__pyx_t_6); __pyx_t_6 = 0; - /* "ml3.pyx":39 - * np.ndarray[DTYPE_t] parent_dists = np.zeros(n_victims, dtype=DTYPE) - * np.ndarray[DTYPE_t] parent_dts = np.zeros(n_victims, dtype=DTYPE) - * np.ndarray[DTYPE_t] isSeed = np.ones(n_victims, dtype=DTYPE) # <<<<<<<<<<<<<< - * - * # loop through victims - */ - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ones); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __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 = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_11 = ((PyArrayObject *)__pyx_t_4); - { - __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_isSeed.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_3ml3_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { - __pyx_v_isSeed = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_isSeed.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } else {__pyx_pybuffernd_isSeed.diminfo[0].strides = __pyx_pybuffernd_isSeed.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_isSeed.diminfo[0].shape = __pyx_pybuffernd_isSeed.rcbuffer->pybuffer.shape[0]; - } - } - __pyx_t_11 = 0; - __pyx_v_isSeed = ((PyArrayObject *)__pyx_t_4); - __pyx_t_4 = 0; - - /* "ml3.pyx":42 + /* "ml3.pyx":41 * * # loop through victims * for i, parents in enumerate(victims.itervalues()): # <<<<<<<<<<<<<< * # for each victim node i, compute the probability that all its parents * # fail to infect it, also computes the probability that its most */ - __pyx_t_12 = 0; + __pyx_t_11 = 0; __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 = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_6 = __Pyx_dict_iterator(__pyx_v_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_1), (&__pyx_t_13)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_4); - __pyx_t_4 = __pyx_t_6; - __pyx_t_6 = 0; + __pyx_t_3 = __Pyx_dict_iterator(__pyx_v_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_1), (&__pyx_t_12)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_6); + __pyx_t_6 = __pyx_t_3; + __pyx_t_3 = 0; while (1) { - __pyx_t_14 = __Pyx_dict_iter_next(__pyx_t_4, __pyx_t_1, &__pyx_t_2, NULL, &__pyx_t_6, NULL, __pyx_t_13); - if (unlikely(__pyx_t_14 == 0)) break; - if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - if (!(likely(PyList_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_XDECREF_SET(__pyx_v_parents, ((PyObject*)__pyx_t_6)); - __pyx_t_6 = 0; - __pyx_v_i = __pyx_t_12; - __pyx_t_12 = (__pyx_t_12 + 1); + __pyx_t_13 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_1, &__pyx_t_2, NULL, &__pyx_t_3, NULL, __pyx_t_12); + if (unlikely(__pyx_t_13 == 0)) break; + if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_parents, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + __pyx_v_i = __pyx_t_11; + __pyx_t_11 = (__pyx_t_11 + 1); - /* "ml3.pyx":46 + /* "ml3.pyx":45 * # fail to infect it, also computes the probability that its most * # likely parent infects it - * failures = [weight_failure(dist, dt/100., alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< - * for (dist, dt, w1, w2, w3) in parents] + * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< + * for (prnt, dist, dt, w1, w2, w3) in parents] * probs_fail[i] = sum(failures) */ - __pyx_t_6 = PyList_New(0); 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_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); - /* "ml3.pyx":47 + /* "ml3.pyx":46 * # likely parent infects it - * failures = [weight_failure(dist, dt/100., alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) + * for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< * probs_fail[i] = sum(failures) - * successes = [weight_success(dist, dt/100., alpha, delta, w1, w2, w3) + * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) */ if (unlikely(__pyx_v_parents == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_5 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_5); __pyx_t_15 = 0; + __pyx_t_5 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_5); __pyx_t_14 = 0; for (;;) { - if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_5)) break; + if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_5)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_14); __Pyx_INCREF(__pyx_t_4); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif - if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { - PyObject* sequence = __pyx_t_3; + if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { + PyObject* sequence = __pyx_t_4; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif - if (unlikely(size != 5)) { - if (size > 5) __Pyx_RaiseTooManyValuesError(5); + if (unlikely(size != 6)) { + if (size > 6) __Pyx_RaiseTooManyValuesError(6); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_16 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_17 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_18 = PyTuple_GET_ITEM(sequence, 2); - __pyx_t_19 = PyTuple_GET_ITEM(sequence, 3); - __pyx_t_20 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_15 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_16 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_17 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_18 = PyTuple_GET_ITEM(sequence, 3); + __pyx_t_19 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_20 = PyTuple_GET_ITEM(sequence, 5); } else { - __pyx_t_16 = PyList_GET_ITEM(sequence, 0); - __pyx_t_17 = PyList_GET_ITEM(sequence, 1); - __pyx_t_18 = PyList_GET_ITEM(sequence, 2); - __pyx_t_19 = PyList_GET_ITEM(sequence, 3); - __pyx_t_20 = PyList_GET_ITEM(sequence, 4); + __pyx_t_15 = PyList_GET_ITEM(sequence, 0); + __pyx_t_16 = PyList_GET_ITEM(sequence, 1); + __pyx_t_17 = PyList_GET_ITEM(sequence, 2); + __pyx_t_18 = PyList_GET_ITEM(sequence, 3); + __pyx_t_19 = PyList_GET_ITEM(sequence, 4); + __pyx_t_20 = PyList_GET_ITEM(sequence, 5); } + __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(__pyx_t_18); @@ -2023,28 +1973,28 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject #else { Py_ssize_t i; - PyObject** temps[5] = {&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20}; - for (i=0; i < 5; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20}; + for (i=0; i < 6; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; - PyObject** temps[5] = {&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20}; - __pyx_t_21 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20}; + __pyx_t_21 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_22 = Py_TYPE(__pyx_t_21)->tp_iternext; - for (index=0; index < 5; index++) { + for (index=0; index < 6; index++) { PyObject* item = __pyx_t_22(__pyx_t_21); if (unlikely(!item)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_22(__pyx_t_21), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_22(__pyx_t_21), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_22 = NULL; __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; goto __pyx_L8_unpacking_done; @@ -2052,14 +2002,16 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_22 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L8_unpacking_done:; } - __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_16); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_t_16); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; - __pyx_t_23 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_23 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_23 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_23 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - __pyx_v_dist = __pyx_t_14; + __Pyx_XDECREF_SET(__pyx_v_prnt, __pyx_t_15); + __pyx_t_15 = 0; + __pyx_v_dist = __pyx_t_13; __pyx_v_dt = __pyx_t_23; __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_18); __pyx_t_18 = 0; @@ -2068,94 +2020,94 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_20); __pyx_t_20 = 0; - /* "ml3.pyx":46 + /* "ml3.pyx":45 * # fail to infect it, also computes the probability that its most * # likely parent infects it - * failures = [weight_failure(dist, dt/100., alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< - * for (dist, dt, w1, w2, w3) in parents] + * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< + * for (prnt, dist, dt, w1, w2, w3) in parents] * probs_fail[i] = sum(failures) */ - __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 = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_25 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_26 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = PyFloat_FromDouble(__pyx_f_3ml3_weight_failure(__pyx_v_dist, (__pyx_v_dt / 100.), __pyx_v_alpha, __pyx_v_delta, __pyx_t_24, __pyx_t_25, __pyx_t_26)); 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); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __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 = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_25 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_26 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(__pyx_f_3ml3_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_24, __pyx_t_25, __pyx_t_26)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "ml3.pyx":47 + /* "ml3.pyx":46 * # likely parent infects it - * failures = [weight_failure(dist, dt/100., alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) + * for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< * probs_fail[i] = sum(failures) - * successes = [weight_success(dist, dt/100., alpha, delta, w1, w2, w3) + * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) */ } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_XDECREF_SET(__pyx_v_failures, ((PyObject*)__pyx_t_6)); - __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_failures, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; - /* "ml3.pyx":48 - * failures = [weight_failure(dist, dt/100., alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] + /* "ml3.pyx":47 + * failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) + * for (prnt, dist, dt, w1, w2, w3) in parents] * probs_fail[i] = sum(failures) # <<<<<<<<<<<<<< - * successes = [weight_success(dist, dt/100., alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] + * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) + * for (prnt, dist, dt, w1, w2, w3) in parents] */ - __pyx_t_6 = PyTuple_New(1); 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_t_3 = PyTuple_New(1); 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_INCREF(__pyx_v_failures); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_failures); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_failures); __Pyx_GIVEREF(__pyx_v_failures); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_3, NULL); 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); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_26 == (npy_double)-1) && PyErr_Occurred())) {__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_26 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_26 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_23 = __pyx_v_i; if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_pybuffernd_probs_fail.diminfo[0].shape; *__Pyx_BufPtrStrided1d(__pyx_t_3ml3_DTYPE_t *, __pyx_pybuffernd_probs_fail.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_probs_fail.diminfo[0].strides) = __pyx_t_26; - /* "ml3.pyx":49 - * for (dist, dt, w1, w2, w3) in parents] + /* "ml3.pyx":48 + * for (prnt, dist, dt, w1, w2, w3) in parents] * probs_fail[i] = sum(failures) - * successes = [weight_success(dist, dt/100., alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< - * for (dist, dt, w1, w2, w3) in parents] - * dists = [dist for (dist, dt, w1, w2, w3) in parents] + * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< + * for (prnt, dist, dt, w1, w2, w3) in parents] + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] */ - __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __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 = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - /* "ml3.pyx":50 + /* "ml3.pyx":49 * probs_fail[i] = sum(failures) - * successes = [weight_success(dist, dt/100., alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< - * dists = [dist for (dist, dt, w1, w2, w3) in parents] - * dts = [dt for (dist, dt, w1, w2, w3) in parents] + * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) + * for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] + * dts = [dt for (prnt, dist, dt, w1, w2, w3) in parents] */ if (unlikely(__pyx_v_parents == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_6 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0; + __pyx_t_3 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_3); __pyx_t_14 = 0; for (;;) { - if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_6)) break; + if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_14); __Pyx_INCREF(__pyx_t_4); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif - if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { - PyObject* sequence = __pyx_t_3; + if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { + PyObject* sequence = __pyx_t_4; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif - if (unlikely(size != 5)) { - if (size > 5) __Pyx_RaiseTooManyValuesError(5); + if (unlikely(size != 6)) { + if (size > 6) __Pyx_RaiseTooManyValuesError(6); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -2164,43 +2116,46 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __pyx_t_18 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_17 = PyTuple_GET_ITEM(sequence, 3); __pyx_t_16 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_15 = PyTuple_GET_ITEM(sequence, 5); } else { __pyx_t_20 = PyList_GET_ITEM(sequence, 0); __pyx_t_19 = PyList_GET_ITEM(sequence, 1); __pyx_t_18 = PyList_GET_ITEM(sequence, 2); __pyx_t_17 = PyList_GET_ITEM(sequence, 3); __pyx_t_16 = PyList_GET_ITEM(sequence, 4); + __pyx_t_15 = PyList_GET_ITEM(sequence, 5); } __Pyx_INCREF(__pyx_t_20); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(__pyx_t_18); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(__pyx_t_16); + __Pyx_INCREF(__pyx_t_15); #else { Py_ssize_t i; - PyObject** temps[5] = {&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16}; - for (i=0; i < 5; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16,&__pyx_t_15}; + for (i=0; i < 6; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; - PyObject** temps[5] = {&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16}; - __pyx_t_21 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16,&__pyx_t_15}; + __pyx_t_21 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_22 = Py_TYPE(__pyx_t_21)->tp_iternext; - for (index=0; index < 5; index++) { + for (index=0; index < 6; index++) { PyObject* item = __pyx_t_22(__pyx_t_21); if (unlikely(!item)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_22(__pyx_t_21), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_22(__pyx_t_21), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_22 = NULL; __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; goto __pyx_L12_unpacking_done; @@ -2208,96 +2163,101 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_22 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L12_unpacking_done:; } - __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_20); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; - __pyx_t_27 = __Pyx_PyInt_As_int(__pyx_t_19); if (unlikely((__pyx_t_27 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_t_19); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; - __pyx_v_dist = __pyx_t_14; + __pyx_t_27 = __Pyx_PyInt_As_int(__pyx_t_18); if (unlikely((__pyx_t_27 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; + __Pyx_XDECREF_SET(__pyx_v_prnt, __pyx_t_20); + __pyx_t_20 = 0; + __pyx_v_dist = __pyx_t_13; __pyx_v_dt = __pyx_t_27; - __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_18); - __pyx_t_18 = 0; - __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_17); + __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_17); __pyx_t_17 = 0; - __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_16); + __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_16); __pyx_t_16 = 0; + __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_15); + __pyx_t_15 = 0; - /* "ml3.pyx":49 - * for (dist, dt, w1, w2, w3) in parents] + /* "ml3.pyx":48 + * for (prnt, dist, dt, w1, w2, w3) in parents] * probs_fail[i] = sum(failures) - * successes = [weight_success(dist, dt/100., alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< - * for (dist, dt, w1, w2, w3) in parents] - * dists = [dist for (dist, dt, w1, w2, w3) in parents] - */ - __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_26 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_25 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __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 = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = PyFloat_FromDouble(__pyx_f_3ml3_weight_success(__pyx_v_dist, (__pyx_v_dt / 100.), __pyx_v_alpha, __pyx_v_delta, __pyx_t_26, __pyx_t_25, __pyx_t_24)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<< + * for (prnt, dist, dt, w1, w2, w3) in parents] + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] + */ + __pyx_t_26 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_26 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_25 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __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 = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(__pyx_f_3ml3_weight_success(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_26, __pyx_t_25, __pyx_t_24)); 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); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "ml3.pyx":50 + /* "ml3.pyx":49 * probs_fail[i] = sum(failures) - * successes = [weight_success(dist, dt/100., alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< - * dists = [dist for (dist, dt, w1, w2, w3) in parents] - * dts = [dt for (dist, dt, w1, w2, w3) in parents] + * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) + * for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] + * dts = [dt for (prnt, dist, dt, w1, w2, w3) in parents] */ } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_successes, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0; - /* "ml3.pyx":51 - * successes = [weight_success(dist, dt/100., alpha, delta, w1, w2, w3) - * for (dist, dt, w1, w2, w3) in parents] - * dists = [dist for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< - * dts = [dt for (dist, dt, w1, w2, w3) in parents] + /* "ml3.pyx":50 + * successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) + * for (prnt, dist, dt, w1, w2, w3) in parents] + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + * dts = [dt for (prnt, 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 = 51; __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 = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); if (unlikely(__pyx_v_parents == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_6 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0; + __pyx_t_3 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_3); __pyx_t_14 = 0; for (;;) { - if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_6)) break; + if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_14); __Pyx_INCREF(__pyx_t_4); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif - if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { - PyObject* sequence = __pyx_t_3; + if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { + PyObject* sequence = __pyx_t_4; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif - if (unlikely(size != 5)) { - if (size > 5) __Pyx_RaiseTooManyValuesError(5); + if (unlikely(size != 6)) { + if (size > 6) __Pyx_RaiseTooManyValuesError(6); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_16 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_17 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_18 = PyTuple_GET_ITEM(sequence, 2); - __pyx_t_19 = PyTuple_GET_ITEM(sequence, 3); - __pyx_t_20 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_15 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_16 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_17 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_18 = PyTuple_GET_ITEM(sequence, 3); + __pyx_t_19 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_20 = PyTuple_GET_ITEM(sequence, 5); } else { - __pyx_t_16 = PyList_GET_ITEM(sequence, 0); - __pyx_t_17 = PyList_GET_ITEM(sequence, 1); - __pyx_t_18 = PyList_GET_ITEM(sequence, 2); - __pyx_t_19 = PyList_GET_ITEM(sequence, 3); - __pyx_t_20 = PyList_GET_ITEM(sequence, 4); + __pyx_t_15 = PyList_GET_ITEM(sequence, 0); + __pyx_t_16 = PyList_GET_ITEM(sequence, 1); + __pyx_t_17 = PyList_GET_ITEM(sequence, 2); + __pyx_t_18 = PyList_GET_ITEM(sequence, 3); + __pyx_t_19 = PyList_GET_ITEM(sequence, 4); + __pyx_t_20 = PyList_GET_ITEM(sequence, 5); } + __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(__pyx_t_18); @@ -2306,28 +2266,28 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject #else { Py_ssize_t i; - PyObject** temps[5] = {&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20}; - for (i=0; i < 5; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20}; + for (i=0; i < 6; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; - PyObject** temps[5] = {&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20}; - __pyx_t_21 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18,&__pyx_t_19,&__pyx_t_20}; + __pyx_t_21 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_22 = Py_TYPE(__pyx_t_21)->tp_iternext; - for (index=0; index < 5; index++) { + for (index=0; index < 6; index++) { PyObject* item = __pyx_t_22(__pyx_t_21); if (unlikely(!item)) goto __pyx_L15_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_22(__pyx_t_21), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_22(__pyx_t_21), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_22 = NULL; __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; goto __pyx_L16_unpacking_done; @@ -2335,62 +2295,64 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_22 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L16_unpacking_done:; } - __pyx_t_27 = __Pyx_PyInt_As_int(__pyx_t_16); if (unlikely((__pyx_t_27 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __Pyx_PyInt_As_int(__pyx_t_16); if (unlikely((__pyx_t_27 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; - __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; + __Pyx_XDECREF_SET(__pyx_v_prnt, __pyx_t_15); + __pyx_t_15 = 0; __pyx_v_dist = __pyx_t_27; - __pyx_v_dt = __pyx_t_14; + __pyx_v_dt = __pyx_t_13; __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_20); __pyx_t_20 = 0; - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dist); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_dist); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_dists, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0; - /* "ml3.pyx":52 - * for (dist, dt, w1, w2, w3) in parents] - * dists = [dist for (dist, dt, w1, w2, w3) in parents] - * dts = [dt for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<< + /* "ml3.pyx":51 + * for (prnt, dist, dt, w1, w2, w3) in parents] + * dists = [dist for (prnt, dist, dt, w1, w2, w3) in parents] + * dts = [dt for (prnt, 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)) */ - __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __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 = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); if (unlikely(__pyx_v_parents == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_6 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0; + __pyx_t_3 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_3); __pyx_t_14 = 0; for (;;) { - if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_6)) break; + if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_14); __Pyx_INCREF(__pyx_t_4); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif - if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { - PyObject* sequence = __pyx_t_3; + if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { + PyObject* sequence = __pyx_t_4; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else Py_ssize_t size = PySequence_Size(sequence); #endif - if (unlikely(size != 5)) { - if (size > 5) __Pyx_RaiseTooManyValuesError(5); + if (unlikely(size != 6)) { + if (size > 6) __Pyx_RaiseTooManyValuesError(6); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -2399,43 +2361,46 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __pyx_t_18 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_17 = PyTuple_GET_ITEM(sequence, 3); __pyx_t_16 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_15 = PyTuple_GET_ITEM(sequence, 5); } else { __pyx_t_20 = PyList_GET_ITEM(sequence, 0); __pyx_t_19 = PyList_GET_ITEM(sequence, 1); __pyx_t_18 = PyList_GET_ITEM(sequence, 2); __pyx_t_17 = PyList_GET_ITEM(sequence, 3); __pyx_t_16 = PyList_GET_ITEM(sequence, 4); + __pyx_t_15 = PyList_GET_ITEM(sequence, 5); } __Pyx_INCREF(__pyx_t_20); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(__pyx_t_18); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(__pyx_t_16); + __Pyx_INCREF(__pyx_t_15); #else { Py_ssize_t i; - PyObject** temps[5] = {&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16}; - for (i=0; i < 5; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16,&__pyx_t_15}; + for (i=0; i < 6; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; - PyObject** temps[5] = {&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16}; - __pyx_t_21 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + PyObject** temps[6] = {&__pyx_t_20,&__pyx_t_19,&__pyx_t_18,&__pyx_t_17,&__pyx_t_16,&__pyx_t_15}; + __pyx_t_21 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_22 = Py_TYPE(__pyx_t_21)->tp_iternext; - for (index=0; index < 5; index++) { + for (index=0; index < 6; index++) { PyObject* item = __pyx_t_22(__pyx_t_21); if (unlikely(!item)) goto __pyx_L19_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_22(__pyx_t_21), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_22(__pyx_t_21), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_22 = NULL; __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; goto __pyx_L20_unpacking_done; @@ -2443,79 +2408,81 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_22 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L20_unpacking_done:; } - __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_20); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; - __pyx_t_27 = __Pyx_PyInt_As_int(__pyx_t_19); if (unlikely((__pyx_t_27 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_t_19); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; - __pyx_v_dist = __pyx_t_14; + __pyx_t_27 = __Pyx_PyInt_As_int(__pyx_t_18); if (unlikely((__pyx_t_27 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; + __Pyx_XDECREF_SET(__pyx_v_prnt, __pyx_t_20); + __pyx_t_20 = 0; + __pyx_v_dist = __pyx_t_13; __pyx_v_dt = __pyx_t_27; - __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_18); - __pyx_t_18 = 0; - __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_17); + __Pyx_XDECREF_SET(__pyx_v_w1, __pyx_t_17); __pyx_t_17 = 0; - __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_16); + __Pyx_XDECREF_SET(__pyx_v_w2, __pyx_t_16); __pyx_t_16 = 0; - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_15); + __pyx_t_15 = 0; + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_dt); 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); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_dts, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0; - /* "ml3.pyx":55 + /* "ml3.pyx":54 * # find parent that maximizes log(p) - log(\tilde{p}) * # probs[i] = max(s - failures[l] for l, s in enumerate(successes)) * probs[i] = float("-inf") # <<<<<<<<<<<<<< * for l, s in enumerate(successes): * prob = s - failures[l] */ - __pyx_t_28 = __Pyx_PyObject_AsDouble(__pyx_kp_s_inf); if (unlikely(__pyx_t_28 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_28 = __Pyx_PyObject_AsDouble(__pyx_kp_s_inf); if (unlikely(__pyx_t_28 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_27 = __pyx_v_i; if (__pyx_t_27 < 0) __pyx_t_27 += __pyx_pybuffernd_probs.diminfo[0].shape; *__Pyx_BufPtrStrided1d(__pyx_t_3ml3_DTYPE_t *, __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_probs.diminfo[0].strides) = __pyx_t_28; - /* "ml3.pyx":56 + /* "ml3.pyx":55 * # probs[i] = max(s - failures[l] for l, s in enumerate(successes)) * probs[i] = float("-inf") * for l, s in enumerate(successes): # <<<<<<<<<<<<<< * prob = s - failures[l] * if prob > probs[i]: */ - __pyx_t_14 = 0; - __pyx_t_5 = __pyx_v_successes; __Pyx_INCREF(__pyx_t_5); __pyx_t_15 = 0; + __pyx_t_13 = 0; + __pyx_t_5 = __pyx_v_successes; __Pyx_INCREF(__pyx_t_5); __pyx_t_14 = 0; for (;;) { - if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_5)) break; + if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_5)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_15); __Pyx_INCREF(__pyx_t_6); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_14); __Pyx_INCREF(__pyx_t_3); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif - __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_v_l = __pyx_t_14; - __pyx_t_14 = (__pyx_t_14 + 1); + __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_v_l = __pyx_t_13; + __pyx_t_13 = (__pyx_t_13 + 1); - /* "ml3.pyx":57 + /* "ml3.pyx":56 * probs[i] = float("-inf") * for l, s in enumerate(successes): * prob = s - failures[l] # <<<<<<<<<<<<<< * if prob > probs[i]: * probs[i] = prob */ - __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_failures, __pyx_v_l, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyNumber_Subtract(__pyx_v_s, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_failures, __pyx_v_l, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF_SET(__pyx_v_prob, __pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_4 = PyNumber_Subtract(__pyx_v_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_prob, __pyx_t_4); + __pyx_t_4 = 0; - /* "ml3.pyx":58 + /* "ml3.pyx":57 * for l, s in enumerate(successes): * prob = s - failures[l] * if prob > probs[i]: # <<<<<<<<<<<<<< @@ -2524,52 +2491,52 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject */ __pyx_t_29 = __pyx_v_i; if (__pyx_t_29 < 0) __pyx_t_29 += __pyx_pybuffernd_probs.diminfo[0].shape; - __pyx_t_3 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_3ml3_DTYPE_t *, __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_probs.diminfo[0].strides))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyObject_RichCompare(__pyx_v_prob, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(__pyx_t_3ml3_DTYPE_t *, __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_probs.diminfo[0].strides))); 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_t_3 = PyObject_RichCompare(__pyx_v_prob, __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_30 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_30 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_30 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_30 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_30) { - /* "ml3.pyx":59 + /* "ml3.pyx":58 * prob = s - failures[l] * if prob > probs[i]: * probs[i] = prob # <<<<<<<<<<<<<< * parent_dists[i] = dists[l] * parent_dts[i] = dts[l] */ - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_prob); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_prob); 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_31 = __pyx_v_i; if (__pyx_t_31 < 0) __pyx_t_31 += __pyx_pybuffernd_probs.diminfo[0].shape; *__Pyx_BufPtrStrided1d(__pyx_t_3ml3_DTYPE_t *, __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_probs.diminfo[0].strides) = __pyx_t_24; - /* "ml3.pyx":60 + /* "ml3.pyx":59 * if prob > probs[i]: * probs[i] = prob * parent_dists[i] = dists[l] # <<<<<<<<<<<<<< * parent_dts[i] = dts[l] * # probs_fail[i] = failures[l] */ - __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_dists, __pyx_v_l, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_dists, __pyx_v_l, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_3); + __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 = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_32 = __pyx_v_i; if (__pyx_t_32 < 0) __pyx_t_32 += __pyx_pybuffernd_parent_dists.diminfo[0].shape; *__Pyx_BufPtrStrided1d(__pyx_t_3ml3_DTYPE_t *, __pyx_pybuffernd_parent_dists.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_parent_dists.diminfo[0].strides) = __pyx_t_24; - /* "ml3.pyx":61 + /* "ml3.pyx":60 * probs[i] = prob * parent_dists[i] = dists[l] * parent_dts[i] = dts[l] # <<<<<<<<<<<<<< * # probs_fail[i] = failures[l] * */ - __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_dts, __pyx_v_l, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_dts, __pyx_v_l, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_3); + __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 = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_33 = __pyx_v_i; if (__pyx_t_33 < 0) __pyx_t_33 += __pyx_pybuffernd_parent_dts.diminfo[0].shape; *__Pyx_BufPtrStrided1d(__pyx_t_3ml3_DTYPE_t *, __pyx_pybuffernd_parent_dts.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_parent_dts.diminfo[0].strides) = __pyx_t_24; @@ -2577,7 +2544,7 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject } __pyx_L23:; - /* "ml3.pyx":56 + /* "ml3.pyx":55 * # probs[i] = max(s - failures[l] for l, s in enumerate(successes)) * probs[i] = float("-inf") * for l, s in enumerate(successes): # <<<<<<<<<<<<<< @@ -2587,163 +2554,169 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "ml3.pyx":65 + /* "ml3.pyx":64 * * # calculate log likelihood - * ll = probs_fail.sum() # add probability that all edges to all victims fail # <<<<<<<<<<<<<< + * ll = probs_fail.sum() # add probability that all edges to all victims fail # <<<<<<<<<<<<<< * * # print 'probs', probs */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_fail), __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_fail), __pyx_n_s_sum); 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_t_6 = NULL; + __pyx_t_3 = NULL; if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } - 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 = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_3) { + __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { - __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __Pyx_GOTREF(__pyx_t_4); + __Pyx_GOTREF(__pyx_t_6); __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 = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_6); 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_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_ll = __pyx_t_24; - /* "ml3.pyx":68 + /* "ml3.pyx":67 * * # print 'probs', probs * max_beta_add = float('-inf') # <<<<<<<<<<<<<< * # iterate over all victim nodes to find the optimal threshold - * for beta in np.arange(0.00001, 1., 1.): + * for beta in np.arange(0.01, 1, .01): */ - __pyx_t_28 = __Pyx_PyObject_AsDouble(__pyx_kp_s_inf); if (unlikely(__pyx_t_28 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_28 = __Pyx_PyObject_AsDouble(__pyx_kp_s_inf); if (unlikely(__pyx_t_28 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_max_beta_add = __pyx_t_28; - /* "ml3.pyx":70 + /* "ml3.pyx":69 * max_beta_add = float('-inf') * # iterate over all victim nodes to find the optimal threshold - * for beta in np.arange(0.00001, 1., 1.): # <<<<<<<<<<<<<< + * for beta in np.arange(0.01, 1, .01): # <<<<<<<<<<<<<< * thresh = log(beta/(3012.*(1.-beta))) - * seeds = isSeed==1 + * seeds = probstp_iternext; if (unlikely(!__pyx_t_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_34 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_34)) {__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_DECREF(__pyx_t_6); __pyx_t_6 = 0; for (;;) { if (likely(!__pyx_t_34)) { if (likely(PyList_CheckExact(__pyx_t_5))) { if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_5)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_6); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_6); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } } else { - __pyx_t_4 = __pyx_t_34(__pyx_t_5); - if (unlikely(!__pyx_t_4)) { + __pyx_t_6 = __pyx_t_34(__pyx_t_5); + if (unlikely(!__pyx_t_6)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } - __Pyx_GOTREF(__pyx_t_4); + __Pyx_GOTREF(__pyx_t_6); } - __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 = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_6); 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_6); __pyx_t_6 = 0; __pyx_v_beta = __pyx_t_24; - /* "ml3.pyx":71 + /* "ml3.pyx":70 * # iterate over all victim nodes to find the optimal threshold - * for beta in np.arange(0.00001, 1., 1.): + * for beta in np.arange(0.01, 1, .01): * thresh = log(beta/(3012.*(1.-beta))) # <<<<<<<<<<<<<< - * seeds = isSeed==1 - * non_seeds = isSeed==0 + * seeds = probs=thresh */ __pyx_v_thresh = log((__pyx_v_beta / (3012. * (1. - __pyx_v_beta)))); - /* "ml3.pyx":72 - * for beta in np.arange(0.00001, 1., 1.): + /* "ml3.pyx":71 + * for beta in np.arange(0.01, 1, .01): * thresh = log(beta/(3012.*(1.-beta))) - * seeds = isSeed==1 # <<<<<<<<<<<<<< - * non_seeds = isSeed==0 + * seeds = probs=thresh * roots = n_roots + sum(seeds) */ - __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_isSeed), __pyx_int_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_XDECREF_SET(__pyx_v_seeds, __pyx_t_4); - __pyx_t_4 = 0; + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_seeds, __pyx_t_3); + __pyx_t_3 = 0; - /* "ml3.pyx":73 + /* "ml3.pyx":72 * thresh = log(beta/(3012.*(1.-beta))) - * seeds = isSeed==1 - * non_seeds = isSeed==0 # <<<<<<<<<<<<<< + * seeds = probs=thresh # <<<<<<<<<<<<<< * roots = n_roots + sum(seeds) * */ - __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_isSeed), __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_XDECREF_SET(__pyx_v_non_seeds, __pyx_t_4); - __pyx_t_4 = 0; + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_non_seeds, __pyx_t_6); + __pyx_t_6 = 0; - /* "ml3.pyx":74 - * seeds = isSeed==1 - * non_seeds = isSeed==0 + /* "ml3.pyx":73 + * seeds = probs=thresh * roots = n_roots + sum(seeds) # <<<<<<<<<<<<<< * * beta_add = 0. */ - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_roots); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_roots); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_seeds); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_seeds); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_seeds); __Pyx_GIVEREF(__pyx_v_seeds); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Add(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_v_roots = __pyx_t_12; + __pyx_v_roots = __pyx_t_11; - /* "ml3.pyx":76 + /* "ml3.pyx":75 * roots = n_roots + sum(seeds) * * beta_add = 0. # <<<<<<<<<<<<<< @@ -2752,84 +2725,84 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject */ __pyx_v_beta_add = 0.; - /* "ml3.pyx":78 + /* "ml3.pyx":77 * beta_add = 0. * # add probability for realized edges and subtract probability these edges fail * beta_add += (probs[non_seeds]).sum() # <<<<<<<<<<<<<< * # add probability for the seeds and non-seeds * beta_add += roots * log(beta/3012.) + sum(non_seeds) * log(1. - beta) */ - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_v_non_seeds); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_v_non_seeds); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sum); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_16); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_16))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_16); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); - __Pyx_INCREF(__pyx_t_4); + __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_sum); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_15))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); + __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_16, function); + __Pyx_DECREF_SET(__pyx_t_15, function); } } - if (__pyx_t_4) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { - __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_16); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; - __pyx_t_16 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_16); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_15 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_16); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_15); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_v_beta_add = __pyx_t_24; - /* "ml3.pyx":80 + /* "ml3.pyx":79 * beta_add += (probs[non_seeds]).sum() * # add probability for the seeds and non-seeds * beta_add += roots * log(beta/3012.) + sum(non_seeds) * log(1. - beta) # <<<<<<<<<<<<<< * * if beta_add > max_beta_add: */ - __pyx_t_16 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_16); - __pyx_t_3 = PyFloat_FromDouble((__pyx_v_roots * log((__pyx_v_beta / 3012.)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_4 = PyFloat_FromDouble((__pyx_v_roots * log((__pyx_v_beta / 3012.)))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_non_seeds); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_non_seeds); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_non_seeds); __Pyx_GIVEREF(__pyx_v_non_seeds); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyFloat_FromDouble(log((1. - __pyx_v_beta))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_17 = PyNumber_Multiply(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_17); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyFloat_FromDouble(log((1. - __pyx_v_beta))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_16 = PyNumber_Multiply(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_t_17); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - __pyx_t_17 = PyNumber_InPlaceAdd(__pyx_t_16, __pyx_t_6); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_17); + __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_16); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; + __pyx_t_16 = PyNumber_InPlaceAdd(__pyx_t_15, __pyx_t_3); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_16); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_16); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_17); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_v_beta_add = __pyx_t_24; - /* "ml3.pyx":82 + /* "ml3.pyx":81 * beta_add += roots * log(beta/3012.) + sum(non_seeds) * log(1. - beta) * * if beta_add > max_beta_add: # <<<<<<<<<<<<<< @@ -2839,7 +2812,7 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __pyx_t_30 = ((__pyx_v_beta_add > __pyx_v_max_beta_add) != 0); if (__pyx_t_30) { - /* "ml3.pyx":83 + /* "ml3.pyx":82 * * if beta_add > max_beta_add: * max_beta = beta # <<<<<<<<<<<<<< @@ -2848,7 +2821,7 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject */ __pyx_v_max_beta = __pyx_v_beta; - /* "ml3.pyx":84 + /* "ml3.pyx":83 * if beta_add > max_beta_add: * max_beta = beta * max_roots = roots # <<<<<<<<<<<<<< @@ -2857,7 +2830,7 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject */ __pyx_v_max_roots = __pyx_v_roots; - /* "ml3.pyx":85 + /* "ml3.pyx":84 * max_beta = beta * max_roots = roots * max_beta_add = beta_add # <<<<<<<<<<<<<< @@ -2869,17 +2842,17 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject } __pyx_L26:; - /* "ml3.pyx":70 + /* "ml3.pyx":69 * max_beta_add = float('-inf') * # iterate over all victim nodes to find the optimal threshold - * for beta in np.arange(0.00001, 1., 1.): # <<<<<<<<<<<<<< + * for beta in np.arange(0.01, 1, .01): # <<<<<<<<<<<<<< * thresh = log(beta/(3012.*(1.-beta))) - * seeds = isSeed==1 + * seeds = probspybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_parent_dists.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_parent_dts.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs.rcbuffer->pybuffer); @@ -2965,7 +2938,6 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __pyx_r = NULL; goto __pyx_L2; __pyx_L0:; - __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_isSeed.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_parent_dists.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_parent_dts.rcbuffer->pybuffer); __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs.rcbuffer->pybuffer); @@ -2978,13 +2950,13 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject __Pyx_XDECREF((PyObject *)__pyx_v_probs_fail); __Pyx_XDECREF((PyObject *)__pyx_v_parent_dists); __Pyx_XDECREF((PyObject *)__pyx_v_parent_dts); - __Pyx_XDECREF((PyObject *)__pyx_v_isSeed); __Pyx_XDECREF(__pyx_v_dists); __Pyx_XDECREF(__pyx_v_dts); __Pyx_XDECREF(__pyx_v_s); __Pyx_XDECREF(__pyx_v_prob); __Pyx_XDECREF(__pyx_v_seeds); __Pyx_XDECREF(__pyx_v_non_seeds); + __Pyx_XDECREF(__pyx_v_prnt); __Pyx_XDECREF(__pyx_v_w1); __Pyx_XDECREF(__pyx_v_w2); __Pyx_XDECREF(__pyx_v_w3); @@ -5042,7 +5014,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_kp_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 0}, - {&__pyx_n_s_isSeed, __pyx_k_isSeed, sizeof(__pyx_k_isSeed), 0, 0, 1, 1}, {&__pyx_n_s_itervalues, __pyx_k_itervalues, sizeof(__pyx_k_itervalues), 0, 0, 1, 1}, {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1}, {&__pyx_n_s_ll, __pyx_k_ll, sizeof(__pyx_k_ll), 0, 0, 1, 1}, @@ -5059,10 +5030,10 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_non_victims, __pyx_k_non_victims, sizeof(__pyx_k_non_victims), 0, 0, 1, 1}, {&__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_ones, __pyx_k_ones, sizeof(__pyx_k_ones), 0, 0, 1, 1}, {&__pyx_n_s_parent_dists, __pyx_k_parent_dists, sizeof(__pyx_k_parent_dists), 0, 0, 1, 1}, {&__pyx_n_s_parent_dts, __pyx_k_parent_dts, sizeof(__pyx_k_parent_dts), 0, 0, 1, 1}, {&__pyx_n_s_parents, __pyx_k_parents, sizeof(__pyx_k_parents), 0, 0, 1, 1}, + {&__pyx_n_s_prnt, __pyx_k_prnt, sizeof(__pyx_k_prnt), 0, 0, 1, 1}, {&__pyx_n_s_prob, __pyx_k_prob, sizeof(__pyx_k_prob), 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}, @@ -5085,8 +5056,8 @@ 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 = 42; __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 = 48; __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 = 41; __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 = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __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;} __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -5099,14 +5070,14 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "ml3.pyx":70 + /* "ml3.pyx":69 * max_beta_add = float('-inf') * # iterate over all victim nodes to find the optimal threshold - * for beta in np.arange(0.00001, 1., 1.): # <<<<<<<<<<<<<< + * for beta in np.arange(0.01, 1, .01): # <<<<<<<<<<<<<< * thresh = log(beta/(3012.*(1.-beta))) - * seeds = isSeed==1 + * seeds = probs=thresh roots = n_roots + sum(seeds) beta_add = 0. @@ -89,4 +88,4 @@ def ml3(dict root_victims, dict victims, dict non_victims, DTYPE_t age, roots = max_roots beta = max_beta # print n_nodes, n_roots, n_victims, max_i, roots - return (beta, roots, ll) + return (beta, roots, ll) \ No newline at end of file diff --git a/experiments/ml3.so b/experiments/ml3.so index d2b6898..fb8afc9 100755 Binary files a/experiments/ml3.so and b/experiments/ml3.so differ diff --git a/experiments/out.log b/experiments/out.log index 98ddbb1..a718511 100644 --- a/experiments/out.log +++ b/experiments/out.log @@ -1,30 +1,100 @@ -0.15 0.08 0.1 47 -9267.41771294 -0.15 0.09 0.1 47 -9252.48080998 -0.15 0.1 0.1 47 -9284.46218119 -0.16 0.08 0.1 47 -9264.20398958 -0.16 0.09 0.1 47 -9248.68415885 -0.16 0.1 0.1 47 -9280.20703963 -0.17 0.08 0.1 47 -9262.86382359 -0.17 0.09 0.1 47 -9246.64573861 -0.17 0.1 0.1 47 -9278.035135 -0.18 0.08 0.1 47 -9263.17461439 -0.18 0.09 0.1 47 -9246.47738823 -0.18 0.1 0.1 47 -9276.64980284 -0.19 0.08 0.1 47 -9264.88048993 -0.19 0.09 0.1 47 -9246.9887665 -0.19 0.1 0.1 47 -9276.34422971 -0.2 0.08 0.1 47 -9267.64171914 -0.2 0.09 0.1 47 -9248.12259288 -0.2 0.1 0.1 47 -9276.81325712 -0.21 0.08 0.1 47 -9270.44267951 -0.21 0.09 0.1 47 -9249.95231714 -0.21 0.1 0.1 47 -9277.29709878 -0.22 0.08 0.1 47 -9273.93909307 -0.22 0.09 0.1 47 -9252.08035758 -0.22 0.1 0.1 47 -9279.14946242 -0.23 0.08 0.1 47 -9277.80574763 -0.23 0.09 0.1 47 -9255.27746396 -0.23 0.1 0.1 47 -9281.37029413 -0.24 0.08 0.1 47 -9282.57182493 -0.24 0.09 0.1 47 -9258.93035339 -0.24 0.1 0.1 47 -9284.2416322 +0.001 0.001 0.08 11270 -130174.021949 +0.001 0.0016681005372 0.08 11270 -130186.81792 +0.001 0.00278255940221 0.08 11270 -130208.510741 +0.001 0.00464158883361 0.08 11270 -130245.688267 +0.001 0.00774263682681 0.08 11270 -130310.57411 +0.001 0.0129154966501 0.08 11270 -130427.308991 +0.001 0.0215443469003 0.08 11270 -130648.06397 +0.001 0.035938136638 0.04 6478 -128816.657559 +0.001 0.0599484250319 0.04 6478 -127394.665041 +0.001 0.1 0.04 6478 -127688.933813 +0.0016681005372 0.001 0.08 11270 -130184.321487 +0.0016681005372 0.0016681005372 0.08 11270 -130204.10481 +0.0016681005372 0.00278255940221 0.08 11270 -130237.646155 +0.0016681005372 0.00464158883361 0.08 11270 -130295.138019 +0.0016681005372 0.00774263682681 0.08 11270 -130395.500445 +0.0016681005372 0.0129154966501 0.08 11270 -130576.118953 +0.0016681005372 0.0215443469003 0.04 6478 -128846.541805 +0.0016681005372 0.035938136638 0.04 6478 -127087.253323 +0.0016681005372 0.0599484250319 0.04 6478 -126230.808822 +0.0016681005372 0.1 0.02 2792 -126557.181556 +0.00278255940221 0.001 0.08 11270 -130198.331202 +0.00278255940221 0.0016681005372 0.08 11270 -130227.620554 +0.00278255940221 0.00278255940221 0.08 11270 -130277.284253 +0.00278255940221 0.00464158883361 0.08 11270 -130362.425847 +0.00278255940221 0.00774263682681 0.08 11270 -130511.096608 +0.00278255940221 0.0129154966501 0.04 6499 -129059.422383 +0.00278255940221 0.0215443469003 0.04 6478 -127109.015024 +0.00278255940221 0.035938136638 0.04 6478 -125684.241338 +0.00278255940221 0.0599484250319 0.04 6478 -125600.024485 +0.00278255940221 0.1 0.02 2792 -126287.212393 +0.00464158883361 0.001 0.08 11270 -130215.294173 +0.00464158883361 0.0016681005372 0.08 11270 -130256.095445 +0.00464158883361 0.00278255940221 0.08 11270 -130325.28705 +0.00464158883361 0.00464158883361 0.08 11270 -130443.928528 +0.00464158883361 0.00774263682681 0.05 7027 -129395.352373 +0.00464158883361 0.0129154966501 0.04 6516 -127431.591365 +0.00464158883361 0.0215443469003 0.04 6478 -125683.037727 +0.00464158883361 0.035938136638 0.04 6478 -124664.01619 +0.00464158883361 0.0599484250319 0.02 2914 -124502.496739 +0.00464158883361 0.1 0.02 2792 -127134.604186 +0.00774263682681 0.001 0.08 11270 -130232.773853 +0.00774263682681 0.0016681005372 0.08 11270 -130285.439066 +0.00774263682681 0.00278255940221 0.08 11270 -130374.758088 +0.00774263682681 0.00464158883361 0.05 7652 -129744.991978 +0.00774263682681 0.00774263682681 0.05 6995 -127969.97982 +0.00774263682681 0.0129154966501 0.05 6677 -126168.108707 +0.00774263682681 0.0215443469003 0.04 6513 -124653.173909 +0.00774263682681 0.035938136638 0.04 6478 -124060.374554 +0.00774263682681 0.0599484250319 0.02 2937 -123459.631205 +0.00774263682681 0.1 0.01 1199 -128091.177099 +0.0129154966501 0.001 0.08 11270 -130247.637572 +0.0129154966501 0.0016681005372 0.08 11270 -130310.391126 +0.0129154966501 0.00278255940221 0.06 8952 -129978.711147 +0.0129154966501 0.00464158883361 0.05 7622 -128580.851845 +0.0129154966501 0.00774263682681 0.05 7183 -126905.034076 +0.0129154966501 0.0129154966501 0.05 6902 -125304.331411 +0.0129154966501 0.0215443469003 0.05 6712 -124093.056726 +0.0129154966501 0.035938136638 0.03 4220 -123607.130582 +0.0129154966501 0.0599484250319 0.02 3041 -122971.205801 +0.0129154966501 0.1 0.01 1210 -129142.326165 +0.0215443469003 0.001 0.08 11270 -130258.217698 +0.0215443469003 0.0016681005372 0.07 9957 -130081.814439 +0.0215443469003 0.00278255940221 0.06 8662 -129124.841865 +0.0215443469003 0.00464158883361 0.05 7864 -127781.895187 +0.0215443469003 0.00774263682681 0.05 7487 -126287.652103 +0.0215443469003 0.0129154966501 0.05 7248 -124916.428004 +0.0215443469003 0.0215443469003 0.05 7058 -124002.594007 +0.0215443469003 0.035938136638 0.03 4060 -122986.296269 +0.0215443469003 0.0599484250319 0.02 3225 -122943.105886 +0.0215443469003 0.1 0.01 1280 -129952.279246 +0.035938136638 0.001 0.07 10368 -130108.933188 +0.035938136638 0.0016681005372 0.06 9401 -129491.738149 +0.035938136638 0.00278255940221 0.06 8856 -128521.580165 +0.035938136638 0.00464158883361 0.06 8372 -127371.393158 +0.035938136638 0.00774263682681 0.05 7935 -126147.240183 +0.035938136638 0.0129154966501 0.05 7682 -125046.741534 +0.035938136638 0.0215443469003 0.05 7476 -124429.198394 +0.035938136638 0.035938136638 0.03 4307 -122878.240073 +0.035938136638 0.0599484250319 0.02 2939 -123316.885543 +0.035938136638 0.1 0.01 1389 -130593.383741 +0.0599484250319 0.001 0.07 10079 -129709.888924 +0.0599484250319 0.0016681005372 0.06 9545 -129062.475372 +0.0599484250319 0.00278255940221 0.06 9190 -128212.556391 +0.0599484250319 0.00464158883361 0.06 8868 -127288.891344 +0.0599484250319 0.00774263682681 0.06 8559 -126362.833809 +0.0599484250319 0.0129154966501 0.06 8304 -125604.769419 +0.0599484250319 0.0215443469003 0.04 6187 -124909.433209 +0.0599484250319 0.035938136638 0.03 4809 -123357.362127 +0.0599484250319 0.0599484250319 0.02 2564 -123821.010849 +0.0599484250319 0.1 0.01 1603 -131308.788018 +0.1 0.001 0.07 10122 -129407.183852 +0.1 0.0016681005372 0.07 9858 -128826.387421 +0.1 0.00278255940221 0.06 9551 -128164.459489 +0.1 0.00464158883361 0.06 9323 -127449.154213 +0.1 0.00774263682681 0.06 9138 -126798.726378 +0.1 0.0129154966501 0.06 8941 -126366.966378 +0.1 0.0215443469003 0.05 6820 -125456.586416 +0.1 0.035938136638 0.04 5608 -124150.372812 +0.1 0.0599484250319 0.02 2771 -124505.31667 +0.1 0.1 0.01 1909 -132157.286741 diff --git a/experiments/process.py b/experiments/process.py index 0115bd4..a0c9b98 100644 --- a/experiments/process.py +++ b/experiments/process.py @@ -15,29 +15,29 @@ if __name__ == "__main__": sys.exit("usage: {0} ".format(sys.argv[0])) root_victims, victims, non_victims, age = load(open(sys.argv[1])) - # # alphas = np.arange(1e-3, 1e-2, 8e-4) # parameter of the time component - # alphas = np.logspace(-4,-1,num=15) - # # deltas = np.arange(0.001, 0.3, 0.008) # parameter of the structural component - # deltas = np.logspace(-4,-1.7,num=15) - # with open("out.log", "w") as fh: - # for alpha, delta in product(alphas, deltas): - # beta, roots, ll = ml3(root_victims, victims, non_victims, age, alpha, delta) - # print "\t".join(map(str, [alpha, delta, beta, roots, ll])) - # fh.write("\t".join(map(str, [alpha, delta, beta, roots, ll])) + "\n") - # fh.flush() - - alphas = np.arange(.15, .25, .01) # parameter of the time component - # alphas = np.logspace(-4,-.5,num=15) - deltas = np.arange(.08, .1, .01) # parameter of the structural component - # deltas = np.logspace(-2,-.1,num=15) - lmbda = 0.10#np.logspace(-12,-3,num=10) + # alphas = np.arange(.02, .1, .01) # parameter of the time component + alphas = np.logspace(-3,-1,num=10) + # deltas = np.arange(.02, .1, .01) # parameter of the structural component + deltas = np.logspace(-3,-1,num=10) with open("out.log", "w") as fh: for alpha, delta in product(alphas, deltas): - lmbda, roots, ll = ml2(root_victims, victims, non_victims, alpha, delta, lmbda) - print "\t".join(map(str, [alpha, delta, lmbda, roots, ll])) - fh.write("\t".join(map(str, [alpha, delta, lmbda, roots, ll])) + "\n") + beta, roots, ll = ml(root_victims, victims, non_victims, age, alpha, delta) + print "\t".join(map(str, [alpha, delta, beta, roots, ll])) + fh.write("\t".join(map(str, [alpha, delta, beta, roots, ll])) + "\n") fh.flush() + # alphas = np.arange(.15, .25, .01) # parameter of the time component + # # alphas = np.logspace(-4,-.5,num=15) + # deltas = np.arange(.08, .1, .01) # parameter of the structural component + # # deltas = np.logspace(-2,-.1,num=15) + # lmbda = 0.10#np.logspace(-12,-3,num=10) + # with open("out.log", "w") as fh: + # for alpha, delta in product(alphas, deltas): + # lmbda, roots, ll = ml2(root_victims, victims, non_victims, alpha, delta, lmbda) + # print "\t".join(map(str, [alpha, delta, lmbda, roots, ll])) + # fh.write("\t".join(map(str, [alpha, delta, lmbda, roots, ll])) + "\n") + # fh.flush() + # alpha = .016 # delta = 0.077 # beta, roots, ll = ml2(root_victims, victims, non_victims, alpha, delta, 1.) -- cgit v1.2.3-70-g09d2 From 110069d77815a3d62e3526f18b2a34fb79beff1e Mon Sep 17 00:00:00 2001 From: Ben Green Date: Thu, 2 Jul 2015 23:10:54 -0400 Subject: just some minor tests with ml --- R Scripts/generate-network.R | 16 +- experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o | Bin 306196 -> 306268 bytes experiments/build_network.py | 2 +- experiments/ml.c | 180 +++++++++---------- experiments/ml.pyx | 11 +- experiments/ml.so | Bin 119284 -> 119276 bytes experiments/out.log | 200 ++++++++++----------- experiments/process.py | 4 +- 8 files changed, 207 insertions(+), 206 deletions(-) diff --git a/R Scripts/generate-network.R b/R Scripts/generate-network.R index dab81a4..db7012d 100644 --- a/R Scripts/generate-network.R +++ b/R Scripts/generate-network.R @@ -3,9 +3,9 @@ setwd("~/Documents/Cascade Project/") source('criminal_cascades/R Scripts/temporal.R') source('criminal_cascades/R Scripts/structural.R') -alpha = 1/10 -beta = 0.01 -delta = 0.25 +alpha = 0.1 +beta = 0.25 +delta = 0.1 # lmbda = 1/10 t_max = 1000 @@ -16,7 +16,7 @@ plot(g, vertex.size=3, vertex.label=NA) V(g)$seed = runif(vcount(g))tp_iternext; if (unlikely(!__pyx_t_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; for (;;) { @@ -2929,16 +2929,16 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ if (likely(PyList_CheckExact(__pyx_t_6))) { if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } } else { @@ -2947,79 +2947,79 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_5); } - __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_beta = __pyx_t_27; - /* "ml.pyx":81 + /* "ml.pyx":80 * # iterate over all victim nodes to find the optimal threshold * for beta in np.arange(0.01, 1., .01): - * thresh = log(beta/(3012.*(1.-beta))) # <<<<<<<<<<<<<< + * thresh = log(beta/(1000.*(1.-beta))) # <<<<<<<<<<<<<< * seeds = probs=thresh */ - __pyx_v_thresh = log((__pyx_v_beta / (3012. * (1. - __pyx_v_beta)))); + __pyx_v_thresh = log((__pyx_v_beta / (1000. * (1. - __pyx_v_beta)))); - /* "ml.pyx":82 + /* "ml.pyx":81 * for beta in np.arange(0.01, 1., .01): - * thresh = log(beta/(3012.*(1.-beta))) + * thresh = log(beta/(1000.*(1.-beta))) * seeds = probs=thresh * roots = n_roots + sum(seeds) */ - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_seeds, __pyx_t_4); __pyx_t_4 = 0; - /* "ml.pyx":83 - * thresh = log(beta/(3012.*(1.-beta))) + /* "ml.pyx":82 + * thresh = log(beta/(1000.*(1.-beta))) * seeds = probs=thresh # <<<<<<<<<<<<<< * roots = n_roots + sum(seeds) * */ - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __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 = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_non_seeds, __pyx_t_5); __pyx_t_5 = 0; - /* "ml.pyx":84 + /* "ml.pyx":83 * seeds = probs=thresh * roots = n_roots + sum(seeds) # <<<<<<<<<<<<<< * * beta_add = 0. */ - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_roots); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_roots); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __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 = 84; __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 = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_seeds); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_seeds); __Pyx_GIVEREF(__pyx_v_seeds); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); 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_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_roots = __pyx_t_12; - /* "ml.pyx":86 + /* "ml.pyx":85 * roots = n_roots + sum(seeds) * * beta_add = 0. # <<<<<<<<<<<<<< @@ -3028,18 +3028,18 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ __pyx_v_beta_add = 0.; - /* "ml.pyx":88 + /* "ml.pyx":87 * beta_add = 0. * # add probability for realized edges and subtract probability these edges fail * beta_add += (probs[non_seeds]).sum() # <<<<<<<<<<<<<< * # add probability for the seeds and non-seeds - * beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) + * beta_add += roots * log(beta/1000.) + (n_nodes-roots) * log(1. - beta) */ - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_v_non_seeds); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_v_non_seeds); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_5); - __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sum); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sum); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; @@ -3053,57 +3053,57 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } } if (__pyx_t_5) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_21, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_21, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __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_21); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_21); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; - __pyx_t_21 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_21); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_21); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_v_beta_add = __pyx_t_27; - /* "ml.pyx":90 + /* "ml.pyx":89 * beta_add += (probs[non_seeds]).sum() * # add probability for the seeds and non-seeds - * beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) # <<<<<<<<<<<<<< + * beta_add += roots * log(beta/1000.) + (n_nodes-roots) * log(1. - beta) # <<<<<<<<<<<<<< * * if beta_add > max_beta_add: */ - __pyx_t_21 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); - __pyx_t_3 = PyFloat_FromDouble((__pyx_v_roots * log((__pyx_v_beta / 3012.)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble((__pyx_v_roots * log((__pyx_v_beta / 1000.)))); 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_t_4 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_roots); 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_5 = PyNumber_Subtract(__pyx_v_n_nodes, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Subtract(__pyx_v_n_nodes, __pyx_t_4); 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_4); __pyx_t_4 = 0; - __pyx_t_4 = PyFloat_FromDouble(log((1. - __pyx_v_beta))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(log((1. - __pyx_v_beta))); 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_20 = PyNumber_Multiply(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_20 = PyNumber_Multiply(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_20); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_20); 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_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; - __pyx_t_20 = PyNumber_InPlaceAdd(__pyx_t_21, __pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_20 = PyNumber_InPlaceAdd(__pyx_t_21, __pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_20); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_20); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_v_beta_add = __pyx_t_27; - /* "ml.pyx":92 - * beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) + /* "ml.pyx":91 + * beta_add += roots * log(beta/1000.) + (n_nodes-roots) * log(1. - beta) * * if beta_add > max_beta_add: # <<<<<<<<<<<<<< * max_beta = beta @@ -3112,7 +3112,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_t_31 = ((__pyx_v_beta_add > __pyx_v_max_beta_add) != 0); if (__pyx_t_31) { - /* "ml.pyx":93 + /* "ml.pyx":92 * * if beta_add > max_beta_add: * max_beta = beta # <<<<<<<<<<<<<< @@ -3121,7 +3121,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ __pyx_v_max_beta = __pyx_v_beta; - /* "ml.pyx":94 + /* "ml.pyx":93 * if beta_add > max_beta_add: * max_beta = beta * max_roots = roots # <<<<<<<<<<<<<< @@ -3130,7 +3130,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ __pyx_v_max_roots = __pyx_v_roots; - /* "ml.pyx":95 + /* "ml.pyx":94 * max_beta = beta * max_roots = roots * max_beta_add = beta_add # <<<<<<<<<<<<<< @@ -3142,17 +3142,17 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } __pyx_L32:; - /* "ml.pyx":80 + /* "ml.pyx":79 * max_beta_add = float('-inf') * # iterate over all victim nodes to find the optimal threshold * for beta in np.arange(0.01, 1., .01): # <<<<<<<<<<<<<< - * thresh = log(beta/(3012.*(1.-beta))) + * thresh = log(beta/(1000.*(1.-beta))) * seeds = probs=thresh roots = n_roots + sum(seeds) @@ -87,7 +86,7 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # add probability for realized edges and subtract probability these edges fail beta_add += (probs[non_seeds]).sum() # add probability for the seeds and non-seeds - beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) + beta_add += roots * log(beta/1000.) + (n_nodes-roots) * log(1. - beta) if beta_add > max_beta_add: max_beta = beta diff --git a/experiments/ml.so b/experiments/ml.so index a08d635..d4cd7b4 100755 Binary files a/experiments/ml.so and b/experiments/ml.so differ diff --git a/experiments/out.log b/experiments/out.log index a718511..895f69f 100644 --- a/experiments/out.log +++ b/experiments/out.log @@ -1,100 +1,100 @@ -0.001 0.001 0.08 11270 -130174.021949 -0.001 0.0016681005372 0.08 11270 -130186.81792 -0.001 0.00278255940221 0.08 11270 -130208.510741 -0.001 0.00464158883361 0.08 11270 -130245.688267 -0.001 0.00774263682681 0.08 11270 -130310.57411 -0.001 0.0129154966501 0.08 11270 -130427.308991 -0.001 0.0215443469003 0.08 11270 -130648.06397 -0.001 0.035938136638 0.04 6478 -128816.657559 -0.001 0.0599484250319 0.04 6478 -127394.665041 -0.001 0.1 0.04 6478 -127688.933813 -0.0016681005372 0.001 0.08 11270 -130184.321487 -0.0016681005372 0.0016681005372 0.08 11270 -130204.10481 -0.0016681005372 0.00278255940221 0.08 11270 -130237.646155 -0.0016681005372 0.00464158883361 0.08 11270 -130295.138019 -0.0016681005372 0.00774263682681 0.08 11270 -130395.500445 -0.0016681005372 0.0129154966501 0.08 11270 -130576.118953 -0.0016681005372 0.0215443469003 0.04 6478 -128846.541805 -0.0016681005372 0.035938136638 0.04 6478 -127087.253323 -0.0016681005372 0.0599484250319 0.04 6478 -126230.808822 -0.0016681005372 0.1 0.02 2792 -126557.181556 -0.00278255940221 0.001 0.08 11270 -130198.331202 -0.00278255940221 0.0016681005372 0.08 11270 -130227.620554 -0.00278255940221 0.00278255940221 0.08 11270 -130277.284253 -0.00278255940221 0.00464158883361 0.08 11270 -130362.425847 -0.00278255940221 0.00774263682681 0.08 11270 -130511.096608 -0.00278255940221 0.0129154966501 0.04 6499 -129059.422383 -0.00278255940221 0.0215443469003 0.04 6478 -127109.015024 -0.00278255940221 0.035938136638 0.04 6478 -125684.241338 -0.00278255940221 0.0599484250319 0.04 6478 -125600.024485 -0.00278255940221 0.1 0.02 2792 -126287.212393 -0.00464158883361 0.001 0.08 11270 -130215.294173 -0.00464158883361 0.0016681005372 0.08 11270 -130256.095445 -0.00464158883361 0.00278255940221 0.08 11270 -130325.28705 -0.00464158883361 0.00464158883361 0.08 11270 -130443.928528 -0.00464158883361 0.00774263682681 0.05 7027 -129395.352373 -0.00464158883361 0.0129154966501 0.04 6516 -127431.591365 -0.00464158883361 0.0215443469003 0.04 6478 -125683.037727 -0.00464158883361 0.035938136638 0.04 6478 -124664.01619 -0.00464158883361 0.0599484250319 0.02 2914 -124502.496739 -0.00464158883361 0.1 0.02 2792 -127134.604186 -0.00774263682681 0.001 0.08 11270 -130232.773853 -0.00774263682681 0.0016681005372 0.08 11270 -130285.439066 -0.00774263682681 0.00278255940221 0.08 11270 -130374.758088 -0.00774263682681 0.00464158883361 0.05 7652 -129744.991978 -0.00774263682681 0.00774263682681 0.05 6995 -127969.97982 -0.00774263682681 0.0129154966501 0.05 6677 -126168.108707 -0.00774263682681 0.0215443469003 0.04 6513 -124653.173909 -0.00774263682681 0.035938136638 0.04 6478 -124060.374554 -0.00774263682681 0.0599484250319 0.02 2937 -123459.631205 -0.00774263682681 0.1 0.01 1199 -128091.177099 -0.0129154966501 0.001 0.08 11270 -130247.637572 -0.0129154966501 0.0016681005372 0.08 11270 -130310.391126 -0.0129154966501 0.00278255940221 0.06 8952 -129978.711147 -0.0129154966501 0.00464158883361 0.05 7622 -128580.851845 -0.0129154966501 0.00774263682681 0.05 7183 -126905.034076 -0.0129154966501 0.0129154966501 0.05 6902 -125304.331411 -0.0129154966501 0.0215443469003 0.05 6712 -124093.056726 -0.0129154966501 0.035938136638 0.03 4220 -123607.130582 -0.0129154966501 0.0599484250319 0.02 3041 -122971.205801 -0.0129154966501 0.1 0.01 1210 -129142.326165 -0.0215443469003 0.001 0.08 11270 -130258.217698 -0.0215443469003 0.0016681005372 0.07 9957 -130081.814439 -0.0215443469003 0.00278255940221 0.06 8662 -129124.841865 -0.0215443469003 0.00464158883361 0.05 7864 -127781.895187 -0.0215443469003 0.00774263682681 0.05 7487 -126287.652103 -0.0215443469003 0.0129154966501 0.05 7248 -124916.428004 -0.0215443469003 0.0215443469003 0.05 7058 -124002.594007 -0.0215443469003 0.035938136638 0.03 4060 -122986.296269 -0.0215443469003 0.0599484250319 0.02 3225 -122943.105886 -0.0215443469003 0.1 0.01 1280 -129952.279246 -0.035938136638 0.001 0.07 10368 -130108.933188 -0.035938136638 0.0016681005372 0.06 9401 -129491.738149 -0.035938136638 0.00278255940221 0.06 8856 -128521.580165 -0.035938136638 0.00464158883361 0.06 8372 -127371.393158 -0.035938136638 0.00774263682681 0.05 7935 -126147.240183 -0.035938136638 0.0129154966501 0.05 7682 -125046.741534 -0.035938136638 0.0215443469003 0.05 7476 -124429.198394 -0.035938136638 0.035938136638 0.03 4307 -122878.240073 -0.035938136638 0.0599484250319 0.02 2939 -123316.885543 -0.035938136638 0.1 0.01 1389 -130593.383741 -0.0599484250319 0.001 0.07 10079 -129709.888924 -0.0599484250319 0.0016681005372 0.06 9545 -129062.475372 -0.0599484250319 0.00278255940221 0.06 9190 -128212.556391 -0.0599484250319 0.00464158883361 0.06 8868 -127288.891344 -0.0599484250319 0.00774263682681 0.06 8559 -126362.833809 -0.0599484250319 0.0129154966501 0.06 8304 -125604.769419 -0.0599484250319 0.0215443469003 0.04 6187 -124909.433209 -0.0599484250319 0.035938136638 0.03 4809 -123357.362127 -0.0599484250319 0.0599484250319 0.02 2564 -123821.010849 -0.0599484250319 0.1 0.01 1603 -131308.788018 -0.1 0.001 0.07 10122 -129407.183852 -0.1 0.0016681005372 0.07 9858 -128826.387421 -0.1 0.00278255940221 0.06 9551 -128164.459489 -0.1 0.00464158883361 0.06 9323 -127449.154213 -0.1 0.00774263682681 0.06 9138 -126798.726378 -0.1 0.0129154966501 0.06 8941 -126366.966378 -0.1 0.0215443469003 0.05 6820 -125456.586416 -0.1 0.035938136638 0.04 5608 -124150.372812 -0.1 0.0599484250319 0.02 2771 -124505.31667 -0.1 0.1 0.01 1909 -132157.286741 +0.1 0.01 0.32 1587 -16246.2835303 +0.1 0.0129154966501 0.3 1522 -16193.1560593 +0.1 0.016681005372 0.3 1482 -16136.7007139 +0.1 0.0215443469003 0.29 1445 -16083.927662 +0.1 0.0278255940221 0.28 1418 -16045.4325535 +0.1 0.035938136638 0.28 1399 -16033.3471288 +0.1 0.0464158883361 0.28 1381 -16065.8045855 +0.1 0.0599484250319 0.27 1365 -16174.1785652 +0.1 0.0774263682681 0.23 1166 -16354.0210508 +0.1 0.1 0.22 1094 -16710.6318304 +0.113646366639 0.01 0.32 1587 -16223.0544334 +0.113646366639 0.0129154966501 0.3 1522 -16169.9167648 +0.113646366639 0.016681005372 0.3 1496 -16114.7613028 +0.113646366639 0.0215443469003 0.29 1453 -16064.997114 +0.113646366639 0.0278255940221 0.29 1436 -16029.4224738 +0.113646366639 0.035938136638 0.28 1413 -16020.1691105 +0.113646366639 0.0464158883361 0.28 1399 -16057.1566663 +0.113646366639 0.0599484250319 0.26 1321 -16167.2369119 +0.113646366639 0.0774263682681 0.23 1173 -16335.8221545 +0.113646366639 0.1 0.22 1108 -16694.4584299 +0.129154966501 0.01 0.32 1587 -16201.5712361 +0.129154966501 0.0129154966501 0.31 1537 -16149.1696536 +0.129154966501 0.016681005372 0.3 1496 -16095.9372617 +0.129154966501 0.0215443469003 0.29 1464 -16049.6817227 +0.129154966501 0.0278255940221 0.29 1445 -16016.7348561 +0.129154966501 0.035938136638 0.29 1426 -16011.4090845 +0.129154966501 0.0464158883361 0.28 1407 -16051.4875514 +0.129154966501 0.0599484250319 0.26 1288 -16157.5499839 +0.129154966501 0.0774263682681 0.24 1183 -16321.8627529 +0.129154966501 0.1 0.22 1115 -16682.3833134 +0.146779926762 0.01 0.32 1587 -16182.0774435 +0.146779926762 0.0129154966501 0.31 1537 -16131.2048239 +0.146779926762 0.016681005372 0.3 1507 -16080.1708094 +0.146779926762 0.0215443469003 0.3 1482 -16037.2306303 +0.146779926762 0.0278255940221 0.29 1453 -16008.0169599 +0.146779926762 0.035938136638 0.29 1436 -16006.0071619 +0.146779926762 0.0464158883361 0.28 1418 -16050.0144027 +0.146779926762 0.0599484250319 0.26 1281 -16148.6892961 +0.146779926762 0.0774263682681 0.24 1187 -16311.3545786 +0.146779926762 0.1 0.23 1138 -16673.8963578 +0.16681005372 0.01 0.32 1587 -16164.849071 +0.16681005372 0.0129154966501 0.31 1560 -16116.449014 +0.16681005372 0.016681005372 0.3 1522 -16067.8766242 +0.16681005372 0.0215443469003 0.3 1496 -16027.3638618 +0.16681005372 0.0278255940221 0.29 1464 -16003.2426018 +0.16681005372 0.035938136638 0.29 1453 -16004.4084252 +0.16681005372 0.0464158883361 0.29 1436 -16052.4652191 +0.16681005372 0.0599484250319 0.26 1289 -16141.4404164 +0.16681005372 0.0774263682681 0.24 1196 -16303.5459122 +0.16681005372 0.1 0.23 1145 -16670.0806528 +0.189573565241 0.01 0.32 1613 -16149.7026241 +0.189573565241 0.0129154966501 0.31 1560 -16103.5965222 +0.189573565241 0.016681005372 0.31 1537 -16058.5451224 +0.189573565241 0.0215443469003 0.3 1507 -16020.9935104 +0.189573565241 0.0278255940221 0.3 1496 -16000.5729402 +0.189573565241 0.035938136638 0.29 1464 -16006.9538317 +0.189573565241 0.0464158883361 0.29 1453 -16058.7205642 +0.189573565241 0.0599484250319 0.25 1260 -16136.4254637 +0.189573565241 0.0774263682681 0.24 1206 -16299.8411955 +0.189573565241 0.1 0.23 1157 -16671.3131735 +0.215443469003 0.01 0.32 1613 -16136.2887288 +0.215443469003 0.0129154966501 0.32 1587 -16093.9635334 +0.215443469003 0.016681005372 0.31 1537 -16052.071471 +0.215443469003 0.0215443469003 0.3 1522 -16018.1621521 +0.215443469003 0.0278255940221 0.3 1507 -16000.7844822 +0.215443469003 0.035938136638 0.3 1482 -16012.1618981 +0.215443469003 0.0464158883361 0.28 1399 -16066.3079647 +0.215443469003 0.0599484250319 0.25 1272 -16136.5860246 +0.215443469003 0.0774263682681 0.24 1212 -16301.153347 +0.215443469003 0.1 0.23 1173 -16676.745682 +0.244843674682 0.01 0.32 1613 -16125.5232284 +0.244843674682 0.0129154966501 0.32 1587 -16085.6169883 +0.244843674682 0.016681005372 0.31 1560 -16048.1741694 +0.244843674682 0.0215443469003 0.31 1537 -16018.2052077 +0.244843674682 0.0278255940221 0.3 1522 -16004.8785245 +0.244843674682 0.035938136638 0.3 1507 -16019.6055296 +0.244843674682 0.0464158883361 0.28 1415 -16072.4792069 +0.244843674682 0.0599484250319 0.26 1278 -16139.4702448 +0.244843674682 0.0774263682681 0.25 1237 -16306.1951749 +0.244843674682 0.1 0.24 1195 -16688.1452238 +0.278255940221 0.01 0.33 1637 -16116.7453334 +0.278255940221 0.0129154966501 0.32 1613 -16080.0365035 +0.278255940221 0.016681005372 0.32 1587 -16046.9682889 +0.278255940221 0.0215443469003 0.31 1560 -16021.5867637 +0.278255940221 0.0278255940221 0.31 1537 -16011.7866661 +0.278255940221 0.035938136638 0.3 1522 -16030.8034204 +0.278255940221 0.0464158883361 0.27 1367 -16078.1951393 +0.278255940221 0.0599484250319 0.26 1298 -16144.7176332 +0.278255940221 0.0774263682681 0.25 1249 -16315.5245594 +0.278255940221 0.1 0.24 1207 -16702.3027221 +0.316227766017 0.01 0.33 1637 -16109.5865483 +0.316227766017 0.0129154966501 0.32 1613 -16075.7276647 +0.316227766017 0.016681005372 0.32 1587 -16046.7383729 +0.316227766017 0.0215443469003 0.31 1560 -16026.6264576 +0.316227766017 0.0278255940221 0.31 1537 -16022.2115914 +0.316227766017 0.035938136638 0.31 1537 -16044.7445633 +0.316227766017 0.0464158883361 0.27 1374 -16084.9299944 +0.316227766017 0.0599484250319 0.26 1308 -16152.3121983 +0.316227766017 0.0774263682681 0.25 1260 -16327.1609197 +0.316227766017 0.1 0.25 1235 -16718.4366844 diff --git a/experiments/process.py b/experiments/process.py index a0c9b98..6c71934 100644 --- a/experiments/process.py +++ b/experiments/process.py @@ -16,9 +16,9 @@ if __name__ == "__main__": root_victims, victims, non_victims, age = load(open(sys.argv[1])) # alphas = np.arange(.02, .1, .01) # parameter of the time component - alphas = np.logspace(-3,-1,num=10) + alphas = np.logspace(-1,-.5,num=10) # deltas = np.arange(.02, .1, .01) # parameter of the structural component - deltas = np.logspace(-3,-1,num=10) + deltas = np.logspace(-2,-1,num=10) 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) -- cgit v1.2.3-70-g09d2