Commit db7961be authored by Bedartha Goswami's avatar Bedartha Goswami
Browse files

remove 'save' flag & save-to-disk util functions

parent cc18ab05
......@@ -6,7 +6,7 @@ A few functions to assist in estimating the cumulative distributions
"""
# Created: Thu May 26, 2016 11:12PM
# Last modified: Tue Aug 15, 2017 01:28pm
# Last modified: Tue Jan 09, 2018 02:02PM
# Copyright: Bedartha Goswami <goswami@pik-potsdam.de>
......@@ -18,7 +18,7 @@ from utils import _progressbar_update
from utils import _progressbar_finish
def cumulative(pdfmat, var_span, verbose, save, pbar):
def cumulative(pdfmat, var_span, verbose, pbar):
"""
Estimates the cumulative distributions for the specified dataset.
"""
......
......@@ -6,7 +6,7 @@ A suite of functions that assist in carrying out the event-detection analysis
"""
# Created: Thu May 26, 2016 03:50PM
# Last modified: Tue Jan 09, 2018 01:53PM
# Last modified: Tue Jan 09, 2018 02:03PM
# Copyright: Bedartha Goswami <goswami@pik-potsdam.de>
import numpy as np
......@@ -72,8 +72,8 @@ def __divide_at_midpoint(G):
return G1, G2
def community_strength_data(G, time, ld, wsize, wstep,
verbose=False, save=True, pbar=False):
def community_strength_data(G, time, ld, wsize, wstep,
verbose=False, pbar=False):
"""
Saves intra-community link fraction for specified data set.
"""
......@@ -100,7 +100,7 @@ def community_strength_data(G, time, ld, wsize, wstep,
def community_strength_random_model(G, time, ld, wsize, wstep, nsurr,
verbose=False, save=True, pbar=False):
verbose=False, pbar=False):
"""
Saves intra-community link fraction for surrogates of specified data set.
"""
......@@ -142,7 +142,7 @@ def community_strength_random_model(G, time, ld, wsize, wstep, nsurr,
return Qsurr, LDsurr, tmid
def pvalues(Q, Qsurr, nwind, verbose=False, save=True, pbar=False):
def pvalues(Q, Qsurr, nwind, verbose=False, pbar=False):
"""
Returns the p-value of obtaining intra-community link density.
"""
......
......@@ -6,7 +6,7 @@ A suite of utility functions that assist in carrying out the analysis
"""
# Created: Thu May 26, 2016 03:50PM
# Last modified: Fri Jun 03, 2016 12:55AM
# Last modified: Tue Jan 09, 2018 02:01PM
# Copyright: Bedartha Goswami <goswami@pik-potsdam.de>
from progressbar import ProgressBar, Bar, Percentage, ETA
......@@ -14,48 +14,6 @@ import matplotlib.pyplot as pl
import numpy as np
def _savedat(path, filename, verbose=False, save=False, **kwargs):
"""
Saves the data in kwargs in filename under given path.
"""
if save:
_printmsg("Saving output...", verbose)
f = path + filename
locals().update(kwargs)
var_list = ["%s=%s, " % (key, key) for key in kwargs]
var_list = "".join(var_list)
save_cmd = "np.savez('%s', %s)" % (f, var_list)
exec(save_cmd)
_printmsg("Saved to: %s.npz" % f, verbose)
return None
def _savefig(path, filename, verbose=False, save=False):
"""
Saves the data in kwargs in filename under given path.
"""
if save:
_printmsg("Saving figure...", verbose)
f = path + filename
pl.savefig(f)
_printmsg("Saved to: %s" % f, verbose)
else:
pl.show()
return None
def _savegraph(path, filename, G, verbose=False, save=False):
"""
Saves igraph Graph object in filename under given path.
"""
if save:
_printmsg("Saving igraph Graph...", verbose)
f = path + filename
G.write_pickle(f)
_printmsg("Saved to: %s" % f, verbose)
return None
def _printmsg(msg, verbose):
"""
Prints given message according to specified varbosity level.
......
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