summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2015-07-02 22:37:45 -0700
committerThibaut Horel <thibaut.horel@gmail.com>2015-07-02 22:37:45 -0700
commit58ed50d980a1ba240bb50b27c42db0a679f00b43 (patch)
treee7f410984ead0c8b2163edbae9d95dae66a7134b
parent5a76e2393e4f2d89f885ea99c473da840d0cd7db (diff)
parent110069d77815a3d62e3526f18b2a34fb79beff1e (diff)
downloadcriminal_cascades-58ed50d980a1ba240bb50b27c42db0a679f00b43.tar.gz
Merge branch 'master' of github.com:Thibauth/criminal_cascades
-rw-r--r--R Scripts/find-parents.R15
-rw-r--r--R Scripts/generate-hyper-lcc.R (renamed from R Scripts/create-hyper-lcc.R)0
-rw-r--r--R Scripts/generate-network.R44
-rw-r--r--R Scripts/predict-victims-plots.R12
-rw-r--r--R Scripts/predict-victims.R39
-rw-r--r--experiments/build/temp.macosx-10.6-x86_64-2.7/ml.obin299264 -> 306268 bytes
-rw-r--r--experiments/build/temp.macosx-10.6-x86_64-2.7/ml3.obin285944 -> 275440 bytes
-rw-r--r--experiments/build_network.py6
-rw-r--r--experiments/ml.c3067
-rw-r--r--experiments/ml.pyx63
-rwxr-xr-xexperiments/ml.sobin108744 -> 119276 bytes
-rwxr-xr-xexperiments/ml2.sobin123652 -> 123652 bytes
-rw-r--r--experiments/ml3.c964
-rw-r--r--experiments/ml3.pyx27
-rwxr-xr-xexperiments/ml3.sobin110884 -> 106596 bytes
-rw-r--r--experiments/out.log325
-rw-r--r--experiments/process.py22
17 files changed, 1940 insertions, 2644 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/create-hyper-lcc.R b/R Scripts/generate-hyper-lcc.R
index 786b694..786b694 100644
--- a/R Scripts/create-hyper-lcc.R
+++ b/R Scripts/generate-hyper-lcc.R
diff --git a/R Scripts/generate-network.R b/R Scripts/generate-network.R
index 3b40969..db7012d 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 = 0.1
+beta = 0.25
+delta = 0.1
# 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))<beta
seeds = which(V(g)$seed)
V(g)$vic = V(g)$seed
-V(g)$vic.day[V(g)$seed] = sample(1:t_max, sum(V(g)$seed))
+V(g)$vic.day[V(g)$seed] = sample(1:t_max, sum(V(g)$seed), replace=T) #1 if testing ml2
V(g)$spawn.date = 0
V(g)$infector = NA
@@ -28,17 +28,21 @@ for (day in 1:t_max){
dists = as.numeric(shortest.paths(g,vic,neighbors))
infected = neighbors[which(runif(length(neighbors))<structural(delta, dists))]
infected = setdiff(infected,seeds) # don't try to infect seeds
- inf.days = day + ceiling(alpha*rexp(length(infected),alpha))
- V(g)$vic[infected] = TRUE
- infects = (inf.days <= V(g)$vic.day[infected]) %in% c(NA,T)
- V(g)$vic.day[infected[infects]] = inf.days[infects]
- V(g)$infector[infected[infects]] = vic
+ inf.days = day + ceiling(rexp(length(infected),alpha))
+ realized = ((inf.days <= V(g)$vic.day[infected]) %in% c(NA,T)) & (inf.days<=t_max)
+ infected = infected[realized]
+ if(sum(realized)){
+ V(g)$vic[infected] = TRUE
+ V(g)$vic.day[infected] = inf.days[realized]
+ V(g)$infector[infected] = vic
+ }
}
}
vic_ids = which(V(g)$vic)
+print(length(vic_ids))
cols = rep('lightblue',N); cols[V(g)$vic]='red'; cols[V(g)$seed]='darkred'
-plot(g, vertex.size=5, vertex.label=NA, vertex.color=cols)
+plot(g, vertex.size=3, vertex.label=NA, vertex.color=cols)
##### generate dag_dat
dag_dat_test = data.frame(matrix(nrow=1,ncol=10))
@@ -68,12 +72,12 @@ rownames(dag_dat_test) = NULL
write.csv(dag_dat_test, file='Results/dag_dat_test.csv')
-##### analyze performance of recovery algorithm
-recovered = read.csv('Results/infectors.csv',header=F,col.names=c('victim','infector'))
-recovered = recovered[order(recovered$victim),]
-infectors = cbind(setdiff(vic_ids,seeds),
- V(g)$infector[setdiff(vic_ids,seeds)],
- recovered$infector[recovered$victim %in% setdiff(vic_ids,seeds)])
-mean(infectors[,2]==infectors[,3])
-
-dag_dat_test[dag_dat_test$to==4984,] \ No newline at end of file
+##### analyze performance of recovery algorithm ------
+# recovered = read.csv('Results/infectors.csv',header=F,col.names=c('victim','infector'))
+# recovered = recovered[order(recovered$victim),]
+# infectors = cbind(setdiff(vic_ids,seeds),
+# V(g)$infector[setdiff(vic_ids,seeds)],
+# recovered$infector[recovered$victim %in% setdiff(vic_ids,seeds)])
+# mean(infectors[,2]==infectors[,3])
+#
+# dag_dat_test[dag_dat_test$to==4984,]
diff --git a/R Scripts/predict-victims-plots.R b/R Scripts/predict-victims-plots.R
index 8a93667..553aa89 100644
--- a/R Scripts/predict-victims-plots.R
+++ b/R Scripts/predict-victims-plots.R
@@ -1,8 +1,8 @@
##### Plot results
-hist(correct_rank3,150,xlim=c(0,vcount(lcc)),col=rgb(0,0,1,1/8),
+hist(correct_rank1,150,xlim=c(0,vcount(lcc)),col=rgb(0,0,1,1/8),
xlab='Risk Ranking of Victims',main='')
hist(correct_rank1,150,xlim=c(0,vcount(lcc)),col=rgb(1,0,1,1/8),add=T)
-hist(correct_rank2,150,xlim=c(0,vcount(lcc)),col=rgb(1,0,1,1/8),add=T)
+hist(correct_rank2,150,xlim=c(0,vcount(lcc)),col=rgb(0,0,1,1/8),add=T)
legend("topright", c("Demographics Model", "Cascade Model"),
fill=c(rgb(1,0,1,1/8), rgb(0,0,1,1/8)))
@@ -12,9 +12,9 @@ counts = matrix(c(colSums(correct_rank<(vcount(lcc)/1000))*100/nvics,
nrow=3, byrow=T)
plot(lambdas,counts[1,],log='x',type='l')
-correct_rank1 = correct_rank[,length(lambdas)]
-correct_rank2 = correct_rank[,1]
-correct_rank3 = correct_rank[,which.min(colMeans(correct_rank))]
+correct_rank1 = correct_rank[,length(lambdas)] # demographics model
+correct_rank2 = correct_rank[,1] # cascade model
+correct_rank3 = correct_rank[,which.min(colMeans(correct_rank))] # best combined model
counts = matrix(c(sum(correct_rank1<(vcount(lcc)*0.001)),
sum(correct_rank1<(vcount(lcc)*0.005)),
sum(correct_rank1<(vcount(lcc)*0.01)),
@@ -36,6 +36,7 @@ legend("topleft", inset=0.05,
c("Demographics Model", "Cascade Model", "Combined Model"),
fill=c(rgb(0,0,1,1/2),rgb(1,0,0,1/2),rgb(0,1,0,1/2)))
box(which='plot')
+
par(new=T)
counts = counts/(100/nvics)
barplot(counts,
@@ -59,3 +60,4 @@ legend("bottomright", inset=0.05,
c("Demographics Model", "Cascade Model", "Combined Model"),
fill=c('red','darkblue','darkgreen'))
lines(c(0,vcount(lcc)),c(0,1))
+
diff --git a/R Scripts/predict-victims.R b/R Scripts/predict-victims.R
index 470815d..2bda7e2 100644
--- a/R Scripts/predict-victims.R
+++ b/R Scripts/predict-victims.R
@@ -1,4 +1,7 @@
library(igraph)
+library(foreach)
+library(doMC)
+registerDoMC(cores=4)
setwd('~/Documents/Cascade Project')
load('Raw Data/lcc.RData')
load('Results/hyper-lcc.RData')
@@ -7,34 +10,36 @@ source('criminal_cascades/R Scripts/temporal.R')
source('criminal_cascades/R Scripts/structural.R')
##### Initialize data
-formula = vic ~ sex + race + age + gang.member + gang.name
+formula = vic ~ sex + race + age + gang.member #+ gang.name
lcc_verts$sex = as.factor(lcc_verts$sex)
lcc_verts$race = as.factor(lcc_verts$race)
lcc_verts$age = as.numeric(lcc_verts$age)
lcc_verts$gang.name = as.factor(lcc_verts$gang.name)
# sum(hyp_lcc_verts$vic)/length(days)
+df = data.frame(ir=lcc_verts$ir_no, dem=0, cas=0, comb=0)
alpha = 0.0028
delta = 0.06
days = sort(unique(hyp_lcc_verts$vic.day)) # 70:max(hyp_lcc_verts$vic.day, na.rm=T)
lambdas = c(0,1)#c(0, exp(seq(log(0.0000001), log(.0005), length.out=150)), 1)
-nvics = sum(lcc_verts$vic)#sum(hyp_lcc_verts$vic.day %in% days)
-correct_rank = matrix(nrow=nvics, ncol=length(lambdas))
+nvics = sum(hyp_lcc_verts$vic.day %in% days)
edges_all = dag_dat_all
##### Loop through days
+writeLines(c(""), "Results/log.txt")
ptm = proc.time()
-for (day in days){
- if (which(day==days) %% 100 == 0) print(day)
-
+correct_rank = foreach (day = days, .combine=rbind) %dopar% {
+ if (which(day==days) %% 100 == 0){sink("Results/log.txt", append=TRUE);cat(paste("day:",day,"\n"))}
+
##### Demographics model
vics = match(unique(hyp_lcc_verts$ir_no[which(hyp_lcc_verts$vic.day<day)]),lcc_verts$name)
victims = lcc_verts[,c('vic','sex','race','age','gang.member','gang.name')]
victims$vic[vics] = TRUE
victims$vic[-vics] = FALSE
-# glm.fit = glm(formula, data=victims, family=binomial)
- glm.fit = lm(formula, data=victims)
- glm.probs = predict(glm.fit, newdata=lcc_verts, type='response')
+ fit = lm(formula, data=victims)
+# fit = glm(formula, data=victims, family=binomial)
+# fit = randomForest(formula, data=victims[,1:5], ntree=100)
+ probs = predict(fit, newdata=lcc_verts, type='response')
##### Cascade Model
edges = edges_all[which(edges_all$t1<day),]
@@ -49,19 +54,21 @@ for (day in days){
# maybe need to change this to reflect new algorithm that accounts for \tilde{p}
##### Combined Model
- combined = data.frame(ir=attr(glm.probs,'name'), dem=as.numeric(glm.probs), cas=0, comb=0)
- combined$cas[match(risk$ir, attr(glm.probs,'name'))] = risk$weight
+ combined = df#data.frame(ir=attr(probs,'name'), dem=as.numeric(probs), cas=0, comb=0)
+ combined$dem[match(attr(probs,'name'), df$ir)] = as.numeric(probs)
+ combined$cas[match(risk$ir, attr(probs,'name'))] = risk$weight
##### Gather results
infected_irs = hyp_lcc_verts$ir_no[which(hyp_lcc_verts$vic.day==day)]
+ crday = matrix(nrow=length(infected_irs), ncol=length(lambdas))
for (lambda in lambdas){
combined$comb = lambda*combined$dem + (1-lambda)*combined$cas
c_idx = which(lambdas==lambda)
- r_idx = head(which(is.na(correct_rank[,c_idx])),length(infected_irs))
- # !! order should be first: rank of (3,5,5,7) should be (1,2,2,4), may need to do n-rank
- correct_rank[r_idx,c_idx] = match(infected_irs, combined$ir[order(combined$comb, decreasing=T)])
- # maybe should also mark down vic/nonvic status of each?
+ crday[,c_idx] = rank(-combined$comb,ties.method='average')[match(infected_irs,combined$ir)]
}
-
+
+ return(crday)
}
print(proc.time()-ptm)
+
+# save(correct_rank, file='Results/correct_rank_62815.RData') \ No newline at end of file
diff --git a/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o b/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o
index 5861fce..8cabba1 100644
--- a/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o
+++ b/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o
Binary files differ
diff --git a/experiments/build/temp.macosx-10.6-x86_64-2.7/ml3.o b/experiments/build/temp.macosx-10.6-x86_64-2.7/ml3.o
index 8ac85ca..9a4f66b 100644
--- a/experiments/build/temp.macosx-10.6-x86_64-2.7/ml3.o
+++ b/experiments/build/temp.macosx-10.6-x86_64-2.7/ml3.o
Binary files differ
diff --git a/experiments/build_network.py b/experiments/build_network.py
index 0e912b0..c58d5cf 100644
--- a/experiments/build_network.py
+++ b/experiments/build_network.py
@@ -8,6 +8,7 @@ def build_network(filename):
victims = {}
non_victims = {}
age = 0
+ t_max = 1000
with open(filename) as fh:
reader = DictReader(fh)
for row in reader:
@@ -29,7 +30,7 @@ def build_network(filename):
victims[from_] = []
# 'to' is not a victim
else:
- dt = 1000 - int(row["t1"])
+ dt = t_max - int(row["t1"])
parent = (from_, dist, dt, w1, w2, w3)
if to not in non_victims:
# age += 3012 - int(row["spawn2"])
@@ -39,13 +40,10 @@ def build_network(filename):
age += int(row["t1"]) - int(row["spawn1"])
victims[from_] = []
root_victims = {}
- print sorted(victims.keys())
- # print victims
for victim in victims.keys():
if not victims[victim]:
del victims[victim]
root_victims[victim] = []
- print sorted(root_victims.keys())
print len(root_victims), len(victims), len(non_victims)
return root_victims, victims, non_victims, age
diff --git a/experiments/ml.c b/experiments/ml.c
index eb67db6..4b9c2ef 100644
--- a/experiments/ml.c
+++ b/experiments/ml.c
@@ -720,8 +720,6 @@ typedef __pyx_t_5numpy_float_t __pyx_t_2ml_DTYPE_t;
/*--- Type declarations ---*/
-struct __pyx_obj_2ml___pyx_scope_struct__ml;
-struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr;
/* "../../../../Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765
* ctypedef npy_longdouble longdouble_t
@@ -759,38 +757,6 @@ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
*/
typedef npy_cdouble __pyx_t_5numpy_complex_t;
-/* "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:
- */
-struct __pyx_obj_2ml___pyx_scope_struct__ml {
- PyObject_HEAD
- PyObject *__pyx_v_failures;
- PyObject *__pyx_v_successes;
-};
-
-
-/* "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
- */
-struct __pyx_obj_2ml___pyx_scope_struct_1_genexpr {
- PyObject_HEAD
- struct __pyx_obj_2ml___pyx_scope_struct__ml *__pyx_outer_scope;
- Py_ssize_t __pyx_v_l;
- PyObject *__pyx_v_s;
- Py_ssize_t __pyx_t_0;
- PyObject *__pyx_t_1;
- Py_ssize_t __pyx_t_2;
-};
-
-
/* --- Runtime support code (head) --- */
#ifndef CYTHON_REFNANNY
#define CYTHON_REFNANNY 0
@@ -883,29 +849,6 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
const char *name, int exact);
-static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);
-
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
#if CYTHON_COMPILING_IN_CPYTHON
@@ -983,6 +926,27 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj);
PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
#endif
+#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
+ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
+ __Pyx_GetItemInt_Generic(o, to_py_func(i))))
+#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
+ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
+ int wraparound, int boundscheck);
+#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
+ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
+ int wraparound, int boundscheck);
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
+ int is_list, int wraparound, int boundscheck);
+
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);
@@ -1008,8 +972,6 @@ static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif
-#include <string.h>
-
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 <structmember.h>
-#include <frameobject.h>
-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.<locals>.genexpr";
static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
static char __pyx_k_Users_ben_Documents_Cascade_Pro[] = "/Users/ben/Documents/Cascade Project/criminal_cascades/experiments/ml.pyx";
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_5000;
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/1.
+ * result = log(structural) + temporal
*/
- __pyx_v_structural = (__pyx_v_dist * log(__pyx_v_delta));
+ __pyx_v_structural = pow(__pyx_v_delta, ((__pyx_t_2ml_DTYPE_t)__pyx_v_dist));
- /* "ml.pyx":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'
+ /* "ml.pyx":14
+ * cdef DTYPE_t structural, temporal, result
+ * structural = delta ** dist
+ * temporal = log(exp(alpha)-1.) - alpha*dt/1. # <<<<<<<<<<<<<<
+ * result = log(structural) + temporal
+ * return result
*/
- __pyx_v_temporal = (log((exp(__pyx_v_alpha) - 1.)) - (__pyx_v_alpha * __pyx_v_dt));
+ __pyx_v_temporal = (log((exp(__pyx_v_alpha) - 1.)) - ((__pyx_v_alpha * __pyx_v_dt) / 1.));
- /* "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
+ /* "ml.pyx":15
+ * structural = delta ** dist
+ * temporal = log(exp(alpha)-1.) - alpha*dt/1.
+ * 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/1.
+ * 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/1.)
+ * 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/1.) # <<<<<<<<<<<<<<
* 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) / 1.));
- /* "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/1.)
* 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/1.)
* 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,77 +1684,86 @@ 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) # <<<<<<<<<<<<<<
- * n_nodes = 148152
+ * n_nodes = 5000
* cdef:
*/
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 # <<<<<<<<<<<<<<
+ * n_nodes = 5000 # <<<<<<<<<<<<<<
* cdef:
* np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE)
*/
- __pyx_v_n_nodes = 148152;
+ __Pyx_INCREF(__pyx_int_5000);
+ __pyx_v_n_nodes = __pyx_int_5000;
- /* "ml.pyx":44
- * n_nodes = 148152
+ /* "ml.pyx":36
+ * n_nodes = 5000
* 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;
+ __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":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_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;
+ __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":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_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
+ * max_beta_add = float('-inf')
*/
- __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":77
+ * 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):
*/
- __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 = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_max_beta_add = __pyx_t_29;
- /* "ml.pyx":83
+ /* "ml.pyx":79
* max_beta_add = float('-inf')
* # iterate over all victim nodes to find the optimal threshold
- * for beta in np.arange(0.001, .2, .002): # <<<<<<<<<<<<<<
- * thresh = log(beta/(3012.*(1.-beta)))
- * # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh])
+ * for beta in np.arange(0.01, 1., .01): # <<<<<<<<<<<<<<
+ * thresh = log(beta/(1000.*(1.-beta)))
+ * seeds = probs<thresh
*/
- __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_arange); 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_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_arange); 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_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
- __pyx_t_4 = __pyx_t_5; __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0;
- __pyx_t_28 = NULL;
+ __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_2 = 0;
+ __pyx_t_36 = NULL;
} else {
- __pyx_t_2 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_5); 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_28 = Py_TYPE(__pyx_t_4)->tp_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 = 79; __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 = 79; __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 = 79; __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 = 79; __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 = 79; __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 = 79; __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 = 79; __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 = 79; __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":80
* # iterate over all victim nodes to find the optimal threshold
- * for beta in np.arange(0.001, .2, .002):
- * thresh = log(beta/(3012.*(1.-beta))) # <<<<<<<<<<<<<<
- * # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh])
- * roots = n_roots + len(probs[probs<thresh])
+ * for beta in np.arange(0.01, 1., .01):
+ * thresh = log(beta/(1000.*(1.-beta))) # <<<<<<<<<<<<<<
+ * seeds = probs<thresh
+ * non_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":86
- * thresh = log(beta/(3012.*(1.-beta)))
- * # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh])
- * roots = n_roots + len(probs[probs<thresh]) # <<<<<<<<<<<<<<
+ /* "ml.pyx":81
+ * for beta in np.arange(0.01, 1., .01):
+ * thresh = log(beta/(1000.*(1.-beta)))
+ * seeds = probs<thresh # <<<<<<<<<<<<<<
+ * non_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 = 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 = 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":82
+ * thresh = log(beta/(1000.*(1.-beta)))
+ * seeds = probs<thresh
+ * non_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 = 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 = 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":83
+ * seeds = probs<thresh
+ * non_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 = 83; __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 = 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 = 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 = 83; __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 = 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":88
- * roots = n_roots + len(probs[probs<thresh])
+ /* "ml.pyx":85
+ * 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()
*/
__pyx_v_beta_add = 0.;
- /* "ml.pyx":90
+ /* "ml.pyx":87
* 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)
+ * beta_add += roots * log(beta/1000.) + (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 = 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 = 87; __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 = 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;
+ 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 = 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_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 = 87; __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_5); __pyx_t_5 = 0;
+ __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 = 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_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_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":92
- * beta_add += (probs[probs>=thresh]).sum()
+ /* "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_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)))));
+ __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 / 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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":94
- * 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
* 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":92
*
* 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":93
* 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":94
* 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":79
* max_beta_add = float('-inf')
* # iterate over all victim nodes to find the optimal threshold
- * for beta in np.arange(0.001, .2, .002): # <<<<<<<<<<<<<<
- * thresh = log(beta/(3012.*(1.-beta)))
- * # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh])
+ * for beta in np.arange(0.01, 1., .01): # <<<<<<<<<<<<<<
+ * thresh = log(beta/(1000.*(1.-beta)))
+ * seeds = probs<thresh
*/
}
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- /* "ml.pyx":100
+ /* "ml.pyx":97
* # print 'beta:', max_beta, 'add:', max_beta_add, 'roots:', max_roots
*
* ll += max_beta_add # <<<<<<<<<<<<<<
@@ -2872,7 +3161,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
*/
__pyx_v_ll = (__pyx_v_ll + __pyx_v_max_beta_add);
- /* "ml.pyx":101
+ /* "ml.pyx":98
*
* ll += max_beta_add
* roots = max_roots # <<<<<<<<<<<<<<
@@ -2881,7 +3170,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
*/
__pyx_v_roots = __pyx_v_max_roots;
- /* "ml.pyx":102
+ /* "ml.pyx":99
* ll += max_beta_add
* roots = max_roots
* beta = max_beta # <<<<<<<<<<<<<<
@@ -2890,34 +3179,34 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
*/
__pyx_v_beta = __pyx_v_max_beta;
- /* "ml.pyx":104
+ /* "ml.pyx":101
* beta = max_beta
* # print n_nodes, n_roots, n_victims, max_i, roots
* return (beta, roots, ll) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_4 = PyFloat_FromDouble(__pyx_v_beta); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyFloat_FromDouble(__pyx_v_beta); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __pyx_t_20 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_20);
+ __pyx_t_4 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_18 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_18);
- __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
+ __pyx_t_21 = PyTuple_New(3); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_21);
+ PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_6);
+ __Pyx_GIVEREF(__pyx_t_6);
+ PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_t_20);
+ __Pyx_GIVEREF(__pyx_t_20);
+ PyTuple_SET_ITEM(__pyx_t_21, 2, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_18);
- __Pyx_GIVEREF(__pyx_t_18);
- PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_3);
+ __pyx_t_6 = 0;
+ __pyx_t_20 = 0;
__pyx_t_4 = 0;
- __pyx_t_18 = 0;
- __pyx_t_3 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
+ __pyx_r = __pyx_t_21;
+ __pyx_t_21 = 0;
goto __pyx_L0;
- /* "ml.pyx":35
+ /* "ml.pyx":27
* return result
*
* def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<<
@@ -2931,14 +3220,17 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_14);
- __Pyx_XDECREF(__pyx_t_15);
__Pyx_XDECREF(__pyx_t_16);
__Pyx_XDECREF(__pyx_t_17);
__Pyx_XDECREF(__pyx_t_18);
__Pyx_XDECREF(__pyx_t_19);
+ __Pyx_XDECREF(__pyx_t_20);
+ __Pyx_XDECREF(__pyx_t_21);
+ __Pyx_XDECREF(__pyx_t_22);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
+ __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);
@@ -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":79
* max_beta_add = float('-inf')
* # iterate over all victim nodes to find the optimal threshold
- * for beta in np.arange(0.001, .2, .002): # <<<<<<<<<<<<<<
- * thresh = log(beta/(3012.*(1.-beta)))
- * # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh])
+ * for beta in np.arange(0.01, 1., .01): # <<<<<<<<<<<<<<
+ * thresh = log(beta/(1000.*(1.-beta)))
+ * seeds = probs<thresh
*/
- __pyx_tuple_ = PyTuple_Pack(3, __pyx_float_0_001, __pyx_float__2, __pyx_float__002); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_tuple_ = PyTuple_Pack(3, __pyx_float_0_01, __pyx_float_1_, __pyx_float__01); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple_);
__Pyx_GIVEREF(__pyx_tuple_);
@@ -5374,17 +5453,17 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_GOTREF(__pyx_tuple__7);
__Pyx_GIVEREF(__pyx_tuple__7);
- /* "ml.pyx":35
+ /* "ml.pyx":27
* return result
*
* def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<<
* DTYPE_t alpha, DTYPE_t delta):
* cdef:
*/
- __pyx_tuple__8 = PyTuple_Pack(33, __pyx_n_s_root_victims, __pyx_n_s_victims, __pyx_n_s_non_victims, __pyx_n_s_age, __pyx_n_s_alpha, __pyx_n_s_delta, __pyx_n_s_n_roots, __pyx_n_s_n_victims, __pyx_n_s_n_nodes, __pyx_n_s_roots, __pyx_n_s_i, __pyx_n_s_dist, __pyx_n_s_dt, __pyx_n_s_t, __pyx_n_s_l, __pyx_n_s_beta, __pyx_n_s_ll, __pyx_n_s_beta_add, __pyx_n_s_max_beta, __pyx_n_s_max_beta_add, __pyx_n_s_parents, __pyx_n_s_failures, __pyx_n_s_successes, __pyx_n_s_probs, __pyx_n_s_probs_fail, __pyx_n_s_probs_nv, __pyx_n_s_thresh, __pyx_n_s_max_roots, __pyx_n_s_w1, __pyx_n_s_w2, __pyx_n_s_w3, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_tuple__8 = PyTuple_Pack(40, __pyx_n_s_root_victims, __pyx_n_s_victims, __pyx_n_s_non_victims, __pyx_n_s_age, __pyx_n_s_alpha, __pyx_n_s_delta, __pyx_n_s_n_roots, __pyx_n_s_n_victims, __pyx_n_s_roots, __pyx_n_s_i, __pyx_n_s_dist, __pyx_n_s_dt, __pyx_n_s_t, __pyx_n_s_l, __pyx_n_s_beta, __pyx_n_s_ll, __pyx_n_s_beta_add, __pyx_n_s_max_beta, __pyx_n_s_max_beta_add, __pyx_n_s_parents, __pyx_n_s_failures, __pyx_n_s_successes, __pyx_n_s_n_nodes, __pyx_n_s_probs, __pyx_n_s_probs_fail, __pyx_n_s_parent_dists, __pyx_n_s_parent_dts, __pyx_n_s_probs_nv, __pyx_n_s_dists, __pyx_n_s_dts, __pyx_n_s_s, __pyx_n_s_prob, __pyx_n_s_thresh, __pyx_n_s_seeds, __pyx_n_s_non_seeds, __pyx_n_s_max_roots, __pyx_n_s_prnt, __pyx_n_s_w1, __pyx_n_s_w2, __pyx_n_s_w3); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__8);
__Pyx_GIVEREF(__pyx_tuple__8);
- __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(6, 0, 33, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ben_Documents_Cascade_Pro, __pyx_n_s_ml, 35, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(6, 0, 40, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ben_Documents_Cascade_Pro, __pyx_n_s_ml, 27, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
@@ -5394,9 +5473,10 @@ static int __Pyx_InitCachedConstants(void) {
static int __Pyx_InitGlobals(void) {
if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
- __pyx_float__2 = PyFloat_FromDouble(.2); if (unlikely(!__pyx_float__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_float__002 = PyFloat_FromDouble(.002); if (unlikely(!__pyx_float__002)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_float_0_001 = PyFloat_FromDouble(0.001); if (unlikely(!__pyx_float_0_001)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_float_1_ = PyFloat_FromDouble(1.); if (unlikely(!__pyx_float_1_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_float__01 = PyFloat_FromDouble(.01); if (unlikely(!__pyx_float__01)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_float_0_01 = PyFloat_FromDouble(0.01); if (unlikely(!__pyx_float_0_01)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_int_5000 = PyInt_FromLong(5000); if (unlikely(!__pyx_int_5000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;
__pyx_L1_error:;
return -1;
@@ -5483,12 +5563,6 @@ PyMODINIT_FUNC PyInit_ml(void)
/*--- Variable export code ---*/
/*--- Function export code ---*/
/*--- Type init code ---*/
- if (PyType_Ready(&__pyx_type_2ml___pyx_scope_struct__ml) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_type_2ml___pyx_scope_struct__ml.tp_print = 0;
- __pyx_ptype_2ml___pyx_scope_struct__ml = &__pyx_type_2ml___pyx_scope_struct__ml;
- if (PyType_Ready(&__pyx_type_2ml___pyx_scope_struct_1_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_type_2ml___pyx_scope_struct_1_genexpr.tp_print = 0;
- __pyx_ptype_2ml___pyx_scope_struct_1_genexpr = &__pyx_type_2ml___pyx_scope_struct_1_genexpr;
/*--- Type import code ---*/
__pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
#if CYTHON_COMPILING_IN_PYPY
@@ -5532,16 +5606,16 @@ PyMODINIT_FUNC PyInit_ml(void)
if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- /* "ml.pyx":35
+ /* "ml.pyx":27
* return result
*
* def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<<
* DTYPE_t alpha, DTYPE_t delta):
* cdef:
*/
- __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_2ml_1ml, NULL, __pyx_n_s_ml); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_2ml_1ml, NULL, __pyx_n_s_ml); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ml, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_d, __pyx_n_s_ml, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "ml.pyx":1
@@ -5780,88 +5854,6 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in
return 0;
}
-static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
- PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
-}
-
-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 {
- 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
@@ -6793,6 +6785,84 @@ 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 {
+ 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 void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
PyObject *tmp_type, *tmp_value, *tmp_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..0d72c44 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/1.
+ result = log(structural) + temporal
return result
cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta,
@@ -25,24 +20,23 @@ 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/1.)
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)
- n_nodes = 148152
+ n_nodes = 5000
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,45 +45,48 @@ 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):
- thresh = log(beta/(3012.*(1.-beta)))
- # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh])
- roots = n_roots + len(probs[probs<thresh])
+ for beta in np.arange(0.01, 1., .01):
+ thresh = log(beta/(1000.*(1.-beta)))
+ seeds = probs<thresh
+ non_seeds = 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)
+ 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 7832e67..d4cd7b4 100755
--- a/experiments/ml.so
+++ b/experiments/ml.so
Binary files differ
diff --git a/experiments/ml2.so b/experiments/ml2.so
index 515e455..37ff3ea 100755
--- a/experiments/ml2.so
+++ b/experiments/ml2.so
Binary files 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]
+ * 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 = 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;
+ __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 = probs<thresh
*/
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __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 = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
- __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0;
+ if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
+ __pyx_t_5 = __pyx_t_6; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0;
__pyx_t_34 = NULL;
} else {
- __pyx_t_1 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __pyx_t_34 = Py_TYPE(__pyx_t_5)->tp_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
+ * non_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 # <<<<<<<<<<<<<<
+ * non_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
+ * non_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
+ * non_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 = probs<thresh
*/
}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- /* "ml3.pyx":88
+ /* "ml3.pyx":87
* # print 'beta:', max_beta, 'add:', max_beta_add, 'roots:', max_roots
*
* ll += max_beta_add # <<<<<<<<<<<<<<
@@ -2888,7 +2861,7 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject
*/
__pyx_v_ll = (__pyx_v_ll + __pyx_v_max_beta_add);
- /* "ml3.pyx":89
+ /* "ml3.pyx":88
*
* ll += max_beta_add
* roots = max_roots # <<<<<<<<<<<<<<
@@ -2897,7 +2870,7 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject
*/
__pyx_v_roots = __pyx_v_max_roots;
- /* "ml3.pyx":90
+ /* "ml3.pyx":89
* ll += max_beta_add
* roots = max_roots
* beta = max_beta # <<<<<<<<<<<<<<
@@ -2906,31 +2879,31 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject
*/
__pyx_v_beta = __pyx_v_max_beta;
- /* "ml3.pyx":92
+ /* "ml3.pyx":91
* beta = max_beta
* # print n_nodes, n_roots, n_victims, max_i, roots
* return (beta, roots, ll) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_5 = PyFloat_FromDouble(__pyx_v_beta); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyFloat_FromDouble(__pyx_v_beta); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __pyx_t_17 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_17);
- __pyx_t_6 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_16 = PyTuple_New(3); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_16);
- PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_5);
+ __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_15);
+ PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_17);
- __Pyx_GIVEREF(__pyx_t_17);
- PyTuple_SET_ITEM(__pyx_t_16, 2, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_6);
+ PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_16);
+ __Pyx_GIVEREF(__pyx_t_16);
+ PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_3);
+ __Pyx_GIVEREF(__pyx_t_3);
__pyx_t_5 = 0;
- __pyx_t_17 = 0;
- __pyx_t_6 = 0;
- __pyx_r = __pyx_t_16;
__pyx_t_16 = 0;
+ __pyx_t_3 = 0;
+ __pyx_r = __pyx_t_15;
+ __pyx_t_15 = 0;
goto __pyx_L0;
/* "ml3.pyx":27
@@ -2947,6 +2920,7 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
+ __Pyx_XDECREF(__pyx_t_15);
__Pyx_XDECREF(__pyx_t_16);
__Pyx_XDECREF(__pyx_t_17);
__Pyx_XDECREF(__pyx_t_18);
@@ -2955,7 +2929,6 @@ static PyObject *__pyx_pf_3ml3_ml3(CYTHON_UNUSED PyObject *__pyx_self, PyObject
__Pyx_XDECREF(__pyx_t_21);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
- __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);
@@ -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
*/
- __pyx_tuple_ = PyTuple_Pack(3, __pyx_float_0_00001, __pyx_float_1_, __pyx_float_1_); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_tuple_ = PyTuple_Pack(3, __pyx_float_0_01, __pyx_int_1, __pyx_float__01); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple_);
__Pyx_GIVEREF(__pyx_tuple_);
@@ -5183,7 +5154,7 @@ static int __Pyx_InitCachedConstants(void) {
* DTYPE_t alpha, DTYPE_t delta):
* cdef:
*/
- __pyx_tuple__8 = PyTuple_Pack(38, __pyx_n_s_root_victims, __pyx_n_s_victims, __pyx_n_s_non_victims, __pyx_n_s_age, __pyx_n_s_alpha, __pyx_n_s_delta, __pyx_n_s_n_roots, __pyx_n_s_n_victims, __pyx_n_s_roots, __pyx_n_s_i, __pyx_n_s_dist, __pyx_n_s_dt, __pyx_n_s_t, __pyx_n_s_l, __pyx_n_s_beta, __pyx_n_s_ll, __pyx_n_s_beta_add, __pyx_n_s_max_beta, __pyx_n_s_max_beta_add, __pyx_n_s_parents, __pyx_n_s_failures, __pyx_n_s_successes, __pyx_n_s_probs, __pyx_n_s_probs_fail, __pyx_n_s_parent_dists, __pyx_n_s_parent_dts, __pyx_n_s_isSeed, __pyx_n_s_dists, __pyx_n_s_dts, __pyx_n_s_s, __pyx_n_s_prob, __pyx_n_s_thresh, __pyx_n_s_seeds, __pyx_n_s_non_seeds, __pyx_n_s_max_roots, __pyx_n_s_w1, __pyx_n_s_w2, __pyx_n_s_w3); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_tuple__8 = PyTuple_Pack(38, __pyx_n_s_root_victims, __pyx_n_s_victims, __pyx_n_s_non_victims, __pyx_n_s_age, __pyx_n_s_alpha, __pyx_n_s_delta, __pyx_n_s_n_roots, __pyx_n_s_n_victims, __pyx_n_s_roots, __pyx_n_s_i, __pyx_n_s_dist, __pyx_n_s_dt, __pyx_n_s_t, __pyx_n_s_l, __pyx_n_s_beta, __pyx_n_s_ll, __pyx_n_s_beta_add, __pyx_n_s_max_beta, __pyx_n_s_max_beta_add, __pyx_n_s_parents, __pyx_n_s_failures, __pyx_n_s_successes, __pyx_n_s_probs, __pyx_n_s_probs_fail, __pyx_n_s_parent_dists, __pyx_n_s_parent_dts, __pyx_n_s_dists, __pyx_n_s_dts, __pyx_n_s_s, __pyx_n_s_prob, __pyx_n_s_thresh, __pyx_n_s_seeds, __pyx_n_s_non_seeds, __pyx_n_s_max_roots, __pyx_n_s_prnt, __pyx_n_s_w1, __pyx_n_s_w2, __pyx_n_s_w3); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__8);
__Pyx_GIVEREF(__pyx_tuple__8);
__pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(6, 0, 38, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ben_Documents_Cascade_Pro, __pyx_n_s_ml3, 27, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -5196,9 +5167,8 @@ static int __Pyx_InitCachedConstants(void) {
static int __Pyx_InitGlobals(void) {
if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
- __pyx_float_1_ = PyFloat_FromDouble(1.); if (unlikely(!__pyx_float_1_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_float_0_00001 = PyFloat_FromDouble(0.00001); if (unlikely(!__pyx_float_0_00001)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_float__01 = PyFloat_FromDouble(.01); if (unlikely(!__pyx_float__01)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_float_0_01 = PyFloat_FromDouble(0.01); if (unlikely(!__pyx_float_0_01)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;
__pyx_L1_error:;
diff --git a/experiments/ml3.pyx b/experiments/ml3.pyx
index da993bc..6e031ef 100644
--- a/experiments/ml3.pyx
+++ b/experiments/ml3.pyx
@@ -6,7 +6,7 @@ from libc.math cimport log, exp
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,
DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
"""weight for successful infection, exponential time model"""
cdef DTYPE_t structural, temporal, result
@@ -15,7 +15,7 @@ cdef DTYPE_t weight_success(int dist, DTYPE_t dt, DTYPE_t alpha, DTYPE_t delta,
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,
DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
"""weight for failed infection, exponential time model"""
cdef DTYPE_t structural, temporal, result
@@ -36,20 +36,19 @@ def ml3(dict root_victims, dict victims, dict non_victims, DTYPE_t age,
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
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
# 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)
- 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]
# 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")
@@ -62,15 +61,15 @@ def ml3(dict root_victims, dict victims, dict non_victims, DTYPE_t age,
# probs_fail[i] = failures[l]
# 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
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
- non_seeds = isSeed==0
+ seeds = probs<thresh
+ non_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
--- a/experiments/ml3.so
+++ b/experiments/ml3.so
Binary files differ
diff --git a/experiments/out.log b/experiments/out.log
index 6ac961e..895f69f 100644
--- a/experiments/out.log
+++ b/experiments/out.log
@@ -1,225 +1,100 @@
-0.0001 0.0001 1e-05 11270 -220027.423471
-0.0001 0.000145977430289 1e-05 11270 -220027.423892
-0.0001 0.000213094101537 1e-05 11270 -220027.424507
-0.0001 0.00031106929352 1e-05 11270 -220027.425405
-0.0001 0.000454090961097 1e-05 11270 -220027.426718
-0.0001 0.000662870316183 1e-05 11270 -220027.42864
-0.0001 0.000967641053709 1e-05 11270 -220027.431456
-0.0001 0.00141253754462 1e-05 11270 -220027.43559
-0.0001 0.0020619860095 1e-05 11270 -220027.441671
-0.0001 0.00301003418958 1e-05 11270 -220027.450652
-0.0001 0.00439397056076 1e-05 11270 -220027.463985
-0.0001 0.00641420531224 1e-05 11270 -220027.483937
-0.0001 0.00936329208824 1e-05 11270 -220027.51414
-0.0001 0.0136682931808 1e-05 11270 -220027.560644
-0.0001 0.0199526231497 1e-05 11270 -220027.63404
-0.000163789370695 0.0001 1e-05 11270 -220027.424054
-0.000163789370695 0.000145977430289 1e-05 11270 -220027.424742
-0.000163789370695 0.000213094101537 1e-05 11270 -220027.425749
-0.000163789370695 0.00031106929352 1e-05 11270 -220027.427219
-0.000163789370695 0.000454090961097 1e-05 11270 -220027.42937
-0.000163789370695 0.000662870316183 1e-05 11270 -220027.432517
-0.000163789370695 0.000967641053709 1e-05 11270 -220027.437127
-0.000163789370695 0.00141253754462 1e-05 11270 -220027.443895
-0.000163789370695 0.0020619860095 1e-05 11270 -220027.453852
-0.000163789370695 0.00301003418958 1e-05 11270 -220027.468555
-0.000163789370695 0.00439397056076 1e-05 11270 -220027.490385
-0.000163789370695 0.00641420531224 1e-05 11270 -220027.523051
-0.000163789370695 0.00936329208824 1e-05 11270 -220027.572501
-0.000163789370695 0.0136682931808 1e-05 11270 -220027.648641
-0.000163789370695 0.0199526231497 1e-05 11270 -220027.76881
-0.000268269579528 0.0001 1e-05 11270 -220027.425007
-0.000268269579528 0.000145977430289 1e-05 11270 -220027.426134
-0.000268269579528 0.000213094101537 1e-05 11270 -220027.427781
-0.000268269579528 0.00031106929352 1e-05 11270 -220027.430188
-0.000268269579528 0.000454090961097 1e-05 11270 -220027.433708
-0.000268269579528 0.000662870316183 1e-05 11270 -220027.438859
-0.000268269579528 0.000967641053709 1e-05 11270 -220027.446406
-0.000268269579528 0.00141253754462 1e-05 11270 -220027.457483
-0.000268269579528 0.0020619860095 1e-05 11270 -220027.473781
-0.000268269579528 0.00301003418958 1e-05 11270 -220027.497849
-0.000268269579528 0.00439397056076 1e-05 11270 -220027.533581
-0.000268269579528 0.00641420531224 1e-05 11270 -220027.58705
-0.000268269579528 0.00936329208824 1e-05 11270 -220027.667993
-0.000268269579528 0.0136682931808 1e-05 11270 -220027.792624
-0.000268269579528 0.0199526231497 1e-05 11270 -220027.989325
-0.000439397056076 0.0001 1e-05 11270 -220027.426565
-0.000439397056076 0.000145977430289 1e-05 11270 -220027.428409
-0.000439397056076 0.000213094101537 1e-05 11270 -220027.431104
-0.000439397056076 0.00031106929352 1e-05 11270 -220027.435043
-0.000439397056076 0.000454090961097 1e-05 11270 -220027.440802
-0.000439397056076 0.000662870316183 1e-05 11270 -220027.44923
-0.000439397056076 0.000967641053709 1e-05 11270 -220027.461579
-0.000439397056076 0.00141253754462 1e-05 11270 -220027.479703
-0.000439397056076 0.0020619860095 1e-05 11270 -220027.506369
-0.000439397056076 0.00301003418958 1e-05 11270 -220027.545748
-0.000439397056076 0.00439397056076 1e-05 11270 -220027.604212
-0.000439397056076 0.00641420531224 1e-05 11270 -220027.691699
-0.000439397056076 0.00936329208824 1e-05 11270 -220027.824138
-0.000439397056076 0.0136682931808 1e-05 11270 -220028.028059
-0.000439397056076 0.0199526231497 1e-05 11270 -220028.349903
-0.000719685673001 0.0001 1e-05 11270 -220027.42911
-0.000719685673001 0.000145977430289 1e-05 11270 -220027.432126
-0.000719685673001 0.000213094101537 1e-05 11270 -220027.436532
-0.000719685673001 0.00031106929352 1e-05 11270 -220027.442972
-0.000719685673001 0.000454090961097 1e-05 11270 -220027.452389
-0.000719685673001 0.000662870316183 1e-05 11270 -220027.46617
-0.000719685673001 0.000967641053709 1e-05 11270 -220027.486361
-0.000719685673001 0.00141253754462 1e-05 11270 -220027.515996
-0.000719685673001 0.0020619860095 1e-05 11270 -220027.559598
-0.000719685673001 0.00301003418958 1e-05 11270 -220027.623986
-0.000719685673001 0.00439397056076 1e-05 11270 -220027.719582
-0.000719685673001 0.00641420531224 1e-05 11270 -220027.862631
-0.000719685673001 0.00936329208824 1e-05 11270 -220028.079185
-0.000719685673001 0.0136682931808 1e-05 11270 -220028.412622
-0.000719685673001 0.0199526231497 1e-05 11270 -220028.938883
-0.00117876863479 0.0001 1e-05 11270 -220027.43326
-0.00117876863479 0.000145977430289 1e-05 11270 -220027.438186
-0.00117876863479 0.000213094101537 1e-05 11270 -220027.445383
-0.00117876863479 0.00031106929352 1e-05 11270 -220027.455901
-0.00117876863479 0.000454090961097 1e-05 11270 -220027.471281
-0.00117876863479 0.000662870316183 1e-05 11270 -220027.49379
-0.00117876863479 0.000967641053709 1e-05 11270 -220027.526769
-0.00117876863479 0.00141253754462 1e-05 11270 -220027.575172
-0.00117876863479 0.0020619860095 1e-05 11270 -220027.646388
-0.00117876863479 0.00301003418958 1e-05 11270 -220027.751556
-0.00117876863479 0.00439397056076 1e-05 11270 -220027.907695
-0.00117876863479 0.00641420531224 1e-05 11270 -220028.141345
-0.00117876863479 0.00936329208824 1e-05 11270 -220028.495054
-0.00117876863479 0.0136682931808 1e-05 11270 -220029.039683
-0.00117876863479 0.0199526231497 1e-05 11270 -220029.899275
-0.00193069772888 0.0001 1e-05 11270 -220027.440007
-0.00193069772888 0.000145977430289 1e-05 11270 -220027.448039
-0.00193069772888 0.000213094101537 1e-05 11270 -220027.459772
-0.00193069772888 0.00031106929352 1e-05 11270 -220027.476921
-0.00193069772888 0.000454090961097 1e-05 11270 -220027.501997
-0.00193069772888 0.000662870316183 1e-05 11270 -220027.538696
-0.00193069772888 0.000967641053709 1e-05 11270 -220027.592466
-0.00193069772888 0.00141253754462 1e-05 11270 -220027.671383
-0.00193069772888 0.0020619860095 1e-05 11270 -220027.787497
-0.00193069772888 0.00301003418958 1e-05 11270 -220027.958967
-0.00193069772888 0.00439397056076 1e-05 11270 -220028.213545
-0.00193069772888 0.00641420531224 1e-05 11270 -220028.594504
-0.00193069772888 0.00936329208824 1e-05 11270 -220029.171224
-0.00193069772888 0.0136682931808 1e-05 11270 -220030.059251
-0.00193069772888 0.0199526231497 1e-05 11270 -220031.46086
-0.00316227766017 0.0001 1e-05 11270 -220027.450926
-0.00316227766017 0.000145977430289 1e-05 11270 -220027.463983
-0.00316227766017 0.000213094101537 1e-05 11270 -220027.483058
-0.00316227766017 0.00031106929352 1e-05 11270 -220027.510937
-0.00316227766017 0.000454090961097 1e-05 11270 -220027.551705
-0.00316227766017 0.000662870316183 1e-05 11270 -220027.611367
-0.00316227766017 0.000967641053709 1e-05 11270 -220027.698782
-0.00316227766017 0.00141253754462 1e-05 11270 -220027.82708
-0.00316227766017 0.0020619860095 1e-05 11270 -220028.015852
-0.00316227766017 0.00301003418958 1e-05 11270 -220028.29462
-0.00316227766017 0.00439397056076 1e-05 11270 -220028.708507
-0.00316227766017 0.00641420531224 1e-05 11270 -220029.32787
-0.00316227766017 0.00936329208824 1e-05 11270 -220030.26552
-0.00316227766017 0.0136682931808 1e-05 11270 -220031.709342
-0.00316227766017 0.0199526231497 1e-05 11270 -220033.988259
-0.00517947467923 0.0001 1e-05 11270 -220027.468461
-0.00517947467923 0.000145977430289 1e-05 11270 -220027.489589
-0.00517947467923 0.000213094101537 1e-05 11270 -220027.520455
-0.00517947467923 0.00031106929352 1e-05 11270 -220027.565567
-0.00517947467923 0.000454090961097 1e-05 11270 -220027.631535
-0.00517947467923 0.000662870316183 1e-05 11270 -220027.728076
-0.00517947467923 0.000967641053709 1e-05 11270 -220027.869527
-0.00517947467923 0.00141253754462 1e-05 11270 -220028.077134
-0.00517947467923 0.0020619860095 1e-05 11270 -220028.382599
-0.00517947467923 0.00301003418958 1e-05 11270 -220028.8337
-0.00517947467923 0.00439397056076 1e-05 11270 -220029.50346
-0.00517947467923 0.00641420531224 1e-05 11270 -220030.50575
-0.00517947467923 0.00936329208824 1e-05 11270 -220032.023162
-0.00517947467923 0.0136682931808 1e-05 11270 -220034.359815
-0.00517947467923 0.0199526231497 1e-05 11270 -220038.048153
-0.00848342898244 0.0001 1e-05 11270 -220027.496279
-0.00848342898244 0.000145977430289 1e-05 11270 -220027.53021
-0.00848342898244 0.000213094101537 1e-05 11270 -220027.579781
-0.00848342898244 0.00031106929352 1e-05 11270 -220027.652231
-0.00848342898244 0.000454090961097 1e-05 11270 -220027.758175
-0.00848342898244 0.000662870316183 1e-05 11270 -220027.913222
-0.00848342898244 0.000967641053709 1e-05 11270 -220028.140396
-0.00848342898244 0.00141253754462 1e-05 11270 -220028.473821
-0.00848342898244 0.0020619860095 1e-05 11270 -220028.964417
-0.00848342898244 0.00301003418958 1e-05 11270 -220029.688926
-0.00848342898244 0.00439397056076 1e-05 11270 -220030.764653
-0.00848342898244 0.00641420531224 1e-05 11270 -220032.374528
-0.00848342898244 0.00936329208824 1e-05 11270 -220034.81191
-0.00848342898244 0.0136682931808 1e-05 11270 -220038.565459
-0.00848342898244 0.0199526231497 1e-05 11270 -220044.490781
-0.0138949549437 0.0001 1e-05 11270 -220027.539544
-0.0138949549437 0.000145977430289 1e-05 11270 -220027.593389
-0.0138949549437 0.000213094101537 1e-05 11270 -220027.672054
-0.0138949549437 0.00031106929352 1e-05 11270 -220027.787023
-0.0138949549437 0.000454090961097 1e-05 11270 -220027.955146
-0.0138949549437 0.000662870316183 1e-05 11270 -220028.201192
-0.0138949549437 0.000967641053709 1e-05 11270 -220028.561701
-0.0138949549437 0.00141253754462 1e-05 11270 -220029.090829
-0.0138949549437 0.0020619860095 1e-05 11270 -220029.869396
-0.0138949549437 0.00301003418958 1e-05 11270 -220031.019211
-0.0138949549437 0.00439397056076 1e-05 11270 -220032.726484
-0.0138949549437 0.00641420531224 1e-05 11270 -220035.28164
-0.0138949549437 0.00936329208824 1e-05 11270 -220039.150477
-0.0138949549437 0.0136682931808 1e-05 11270 -220045.109014
-0.0138949549437 0.0199526231497 1e-05 11270 -220054.516158
-0.0227584592607 0.0001 1e-05 11270 -220027.604764
-0.0227584592607 0.000145977430289 1e-05 11270 -220027.688627
-0.0227584592607 0.000213094101537 1e-05 11270 -220027.811148
-0.0227584592607 0.00031106929352 1e-05 11270 -220027.990215
-0.0227584592607 0.000454090961097 1e-05 11270 -220028.252069
-0.0227584592607 0.000662870316183 1e-05 11270 -220028.635295
-0.0227584592607 0.000967641053709 1e-05 11270 -220029.196809
-0.0227584592607 0.00141253754462 1e-05 11270 -220030.020972
-0.0227584592607 0.0020619860095 1e-05 11270 -220031.233691
-0.0227584592607 0.00301003418958 1e-05 11270 -220033.024747
-0.0227584592607 0.00439397056076 1e-05 11270 -220035.684297
-0.0227584592607 0.00641420531224 1e-05 11270 -220039.664958
-0.0227584592607 0.00936329208824 1e-05 11270 -220045.692799
-0.0227584592607 0.0136682931808 1e-05 11270 -220054.977676
-0.0227584592607 0.0199526231497 1e-05 11270 -220069.638543
-0.0372759372031 0.0001 1e-05 11270 -220027.698422
-0.0372759372031 0.000145977430289 1e-05 11270 -220027.825392
-0.0372759372031 0.000213094101537 1e-05 11270 -220028.010892
-0.0372759372031 0.00031106929352 1e-05 11270 -220028.282006
-0.0372759372031 0.000454090961097 1e-05 11270 -220028.678468
-0.0372759372031 0.000662870316183 1e-05 11270 -220029.258698
-0.0372759372031 0.000967641053709 1e-05 11270 -220030.108881
-0.0372759372031 0.00141253754462 1e-05 11270 -220031.35677
-0.0372759372031 0.0020619860095 1e-05 11270 -220033.193044
-0.0372759372031 0.00301003418958 1e-05 11270 -220035.905157
-0.0372759372031 0.00439397056076 1e-05 11270 -220039.932658
-0.0372759372031 0.00641420531224 1e-05 11270 -220045.961343
-0.0372759372031 0.00936329208824 1e-05 11270 -220055.091575
-0.0372759372031 0.0136682931808 1e-05 11270 -220069.157308
-0.0372759372031 0.0199526231497 1e-05 11270 -220091.371085
-0.0610540229659 0.0001 1e-05 11270 -220027.823505
-0.0610540229659 0.000145977430289 1e-05 11270 -220028.008048
-0.0610540229659 0.000213094101537 1e-05 11270 -220028.277661
-0.0610540229659 0.00031106929352 1e-05 11270 -220028.671711
-0.0610540229659 0.000454090961097 1e-05 11270 -220029.247951
-0.0610540229659 0.000662870316183 1e-05 11270 -220030.091301
-0.0610540229659 0.000967641053709 1e-05 11270 -220031.327042
-0.0610540229659 0.00141253754462 1e-05 11270 -220033.140891
-0.0610540229659 0.0020619860095 1e-05 11270 -220035.810071
-0.0610540229659 0.00301003418958 1e-05 11270 -220039.752546
-0.0610540229659 0.00439397056076 1e-05 11270 -220045.607535
-0.0610540229659 0.00641420531224 1e-05 11270 -220054.372543
-0.0610540229659 0.00936329208824 1e-05 11270 -220067.648403
-0.0610540229659 0.0136682931808 1e-05 11270 -220088.103672
-0.0610540229659 0.0199526231497 1e-05 11270 -220120.413364
-0.1 0.0001 1e-05 11270 -220027.97435
-0.1 0.000145977430289 1e-05 11270 -220028.228322
-0.1 0.000213094101537 1e-05 11270 -220028.599372
-0.1 0.00031106929352 1e-05 11270 -220029.141677
-0.1 0.000454090961097 1e-05 11270 -220029.934723
-0.1 0.000662870316183 1e-05 11270 -220031.095385
-0.1 0.000967641053709 1e-05 11270 -220032.796098
-0.1 0.00141253754462 1e-05 11270 -220035.292484
-0.1 0.0020619860095 1e-05 11270 -220038.966138
-0.1 0.00301003418958 1e-05 11270 -220044.392434
-0.1 0.00439397056076 1e-05 11270 -220052.451402
-0.1 0.00641420531224 1e-05 11270 -220064.51647
-0.1 0.00936329208824 1e-05 11270 -220082.791961
-0.1 0.0136682931808 1e-05 11270 -220110.952545
-0.1 0.0199526231497 1e-05 11270 -220155.435246
+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 f31e0d4..6c71934 100644
--- a/experiments/process.py
+++ b/experiments/process.py
@@ -15,21 +15,21 @@ if __name__ == "__main__":
sys.exit("usage: {0} <file>".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)
+ # alphas = np.arange(.02, .1, .01) # parameter of the time component
+ alphas = np.logspace(-1,-.5,num=10)
+ # deltas = np.arange(.02, .1, .01) # parameter of the structural component
+ deltas = np.logspace(-2,-1,num=10)
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)
+ 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(.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)
+ # 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):
@@ -38,7 +38,7 @@ if __name__ == "__main__":
# fh.write("\t".join(map(str, [alpha, delta, lmbda, roots, ll])) + "\n")
# fh.flush()
- # alpha = 0.061
- # delta = 0.082
+ # 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