Commit 938e25e4 authored by Norbert Marwan's avatar Norbert Marwan
Browse files

Merge commit '2fc5fc49'

* commit '2fc5fc49':
  Update to python 3.8
parents b9d35494 2fc5fc49
...@@ -35,10 +35,10 @@ def cdf_matrix(pdfmat, var_span, verbose=False, pbar=False): ...@@ -35,10 +35,10 @@ def cdf_matrix(pdfmat, var_span, verbose=False, pbar=False):
""" """
nt = pdfmat.shape[0] nt = pdfmat.shape[0]
bj = 0.5 * np.r_[ bj = 0.5 * np.r_[
var_span[1] - var_span[0], var_span[1] - var_span[0],
var_span[2:] - var_span[:-2], var_span[2:] - var_span[:-2],
var_span[-1] - var_span[-2] var_span[-1] - var_span[-2]
] # Riemann sum width ] # Riemann sum width
_printmsg("Estimating CDFs...", verbose) _printmsg("Estimating CDFs...", verbose)
cdfmat = np.zeros(pdfmat.shape) cdfmat = np.zeros(pdfmat.shape)
prog_bar = _progressbar_start(nt, pbar) prog_bar = _progressbar_start(nt, pbar)
......
...@@ -71,7 +71,7 @@ def __divide_at_midpoint(G): ...@@ -71,7 +71,7 @@ def __divide_at_midpoint(G):
return G1, G2 return G1, G2
def community_strength_data(G, time, wsize, wstep, def community_strength_data(G, time, wsize, wstep,
verbose=False, pbar=False): verbose=False, pbar=False):
""" """
Saves intra-community link fraction for specified data set. Saves intra-community link fraction for specified data set.
...@@ -111,7 +111,7 @@ def community_strength_random_model(G, time, wsize, wstep, nsurr, ...@@ -111,7 +111,7 @@ def community_strength_random_model(G, time, wsize, wstep, nsurr,
tmid = [] tmid = []
Qsurr, LDsurr = [np.zeros((int(nwind), int(nsurr)), "float") for i in range(2)] Qsurr, LDsurr = [np.zeros((int(nwind), int(nsurr)), "float") for i in range(2)]
_printmsg("Estimating intra-community link fraction...", verbose) _printmsg("Estimating intra-community link fraction...", verbose)
prog_bar = _progressbar_start(nwind*nsurr, pbar) prog_bar = _progressbar_start(nwind * nsurr, pbar)
count = 0 count = 0
for i in range(int(nwind)): for i in range(int(nwind)):
k = i * wstep k = i * wstep
...@@ -165,7 +165,7 @@ def holm(pvals, alpha=0.05, corr_type="dunn"): ...@@ -165,7 +165,7 @@ def holm(pvals, alpha=0.05, corr_type="dunn"):
p_ = pvals[sortidx] p_ = pvals[sortidx]
j = np.arange(1, n + 1) j = np.arange(1, n + 1)
if corr_type == "bonf": if corr_type == "bonf":
corr_factor = alpha / (n - j + 1) corr_factor = alpha / (n - j + 1)
elif corr_type == "dunn": elif corr_type == "dunn":
corr_factor = 1. - (1. - alpha) ** (1. / (n - j + 1)) corr_factor = 1. - (1. - alpha) ** (1. / (n - j + 1))
try: try:
...@@ -174,4 +174,3 @@ def holm(pvals, alpha=0.05, corr_type="dunn"): ...@@ -174,4 +174,3 @@ def holm(pvals, alpha=0.05, corr_type="dunn"):
except IndexError: except IndexError:
idx = [] idx = []
return idx return idx
...@@ -132,7 +132,7 @@ def _precnet_check_limits(dist_list, var_span, ld, iqr, ...@@ -132,7 +132,7 @@ def _precnet_check_limits(dist_list, var_span, ld, iqr,
if not cond: if not cond:
str0 = "Target link density could not be bracketed!" str0 = "Target link density could not be bracketed!"
str1 = "Increase initial THR bracket or change target LD." str1 = "Increase initial THR bracket or change target LD."
str2 = "LD = %.3f for THR = %.2E and %.3f for THR = %.2f"\ str2 = "LD = %.3f for THR = %.2E and %.3f for THR = %.2f" \
% (ld_lims[0], thr_lims[0], ld_lims[1], thr_lims[1]) % (ld_lims[0], thr_lims[0], ld_lims[1], thr_lims[1])
print(str0 + "\n" + str1 + "\n" + str2) print(str0 + "\n" + str1 + "\n" + str2)
return cond, ld_lims return cond, ld_lims
...@@ -175,7 +175,7 @@ def _precnet_igraph(dist_list, var_span, e, verbose=False, pbar=False): ...@@ -175,7 +175,7 @@ def _precnet_igraph(dist_list, var_span, e, verbose=False, pbar=False):
Returns weighted igraph object by estimating prob. of rec. mat. Returns weighted igraph object by estimating prob. of rec. mat.
""" """
P = prob_recurrence_matrix(dist_list, var_span, e, verbose, pbar) P = prob_recurrence_matrix(dist_list, var_span, e, verbose, pbar)
np.fill_diagonal(P, 0.) # remove self-loops np.fill_diagonal(P, 0.) # remove self-loops
G = _precmat_to_igraph(P) G = _precmat_to_igraph(P)
return G return G
...@@ -297,11 +297,11 @@ def prob_recurrence_matrix(dist_list, var_span, e=0.1, ...@@ -297,11 +297,11 @@ def prob_recurrence_matrix(dist_list, var_span, e=0.1,
_printmsg("\tPairwise recurrence probability bounds...", verbose) _printmsg("\tPairwise recurrence probability bounds...", verbose)
f1, f2 = np.zeros((n, len(u))), np.zeros((n, len(u))) f1, f2 = np.zeros((n, len(u))), np.zeros((n, len(u)))
for j in range(n): for j in range(n):
f1[j, :] = np.interp(u - e, u, dist_list[j]) # for z = e f1[j, :] = np.interp(u - e, u, dist_list[j]) # for z = e
f2[j, :] = np.interp(u + e, u, dist_list[j]) # for z = -e f2[j, :] = np.interp(u + e, u, dist_list[j]) # for z = -e
prog_bar = _progressbar_start(n, pbar) prog_bar = _progressbar_start(n, pbar)
for i in range(n): for i in range(n):
fi = np.interp(u, u, dist_list[i]) # Xi.cdf(u) fi = np.interp(u, u, dist_list[i]) # Xi.cdf(u)
plus_lo, plus_hi = _bounds_williamson(fi, f1) plus_lo, plus_hi = _bounds_williamson(fi, f1)
mnus_lo, mnus_hi = _bounds_williamson(fi, f2) mnus_lo, mnus_hi = _bounds_williamson(fi, f2)
diff = plus_lo - mnus_hi diff = plus_lo - mnus_hi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment