本文整理汇总了Python中param.parameterized.ParamOverrides.analysis_fn方法的典型用法代码示例。如果您正苦于以下问题:Python ParamOverrides.analysis_fn方法的具体用法?Python ParamOverrides.analysis_fn怎么用?Python ParamOverrides.analysis_fn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类param.parameterized.ParamOverrides
的用法示例。
在下文中一共展示了ParamOverrides.analysis_fn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from param.parameterized import ParamOverrides [as 别名]
# 或者: from param.parameterized.ParamOverrides import analysis_fn [as 别名]
#.........这里部分代码省略.........
print startnote
from topo.misc.commandline import auto_import_commands
auto_import_commands()
# Ensure that saved state includes all parameter values
from topo.command import save_script_repr
param.parameterized.script_repr_suppress_defaults=False
# Save a copy of the script file for reference
shutil.copy2(script_file, normalize_path.prefix)
shutil.move(normalize_path(scriptbase+".ty"),
normalize_path(simpath+".ty"))
# Default case: times is just a number that scales a standard list of times
times=p.times
if not isinstance(times,list):
times=[t*times for t in [0,50,100,500,1000,2000,3000,4000,5000,10000]]
# Run script in main
error_count = 0
initial_warning_count = param.parameterized.warning_count
try:
execfile(script_file,__main__.__dict__) #global_params.context
global_params.check_for_unused_names()
if p.save_global_params:
_save_parameters(p.extra_keywords(), simpath+".global_params.pickle")
print_sizes()
topo.sim.name=simname
from holoviews.ipython.widgets import ProgressBar, RunProgress
import numpy as np
ProgressBar.display = p.progress_bar
progress_bar = RunProgress(run_hook = topo.sim.run,
display = p.progress_bar,
interval = p.progress_interval)
if len(set(times)) == 1:
completion = [0, 100]
else:
times = np.array(times)
completion = 100 * (times - times.min()) / (times.max() - times.min())
completion = np.array([0] + list(completion))
# Run each segment, doing the analysis and saving the script state each time
for i, run_to in enumerate(times):
progress_bar.percent_range = (completion[i], completion[i+1])
progress_bar(run_to - topo.sim.time())
p.analysis_fn()
normalize_path.prefix = metadata_dir
if p.save_script_repr == 'first' and run_to == times[0]:
save_script_repr()
elif p.save_script_repr == 'last' and (run_to == times[-1]):
save_script_repr()
elif p.save_script_repr == 'all':
save_script_repr()
normalize_path.prefix = dirpath
elapsedtime=time.time()-starttime
param.Parameterized(name="run_batch").message(
"Elapsed real time %02d:%02d." % (int(elapsedtime/60),int(elapsedtime%60)))
if p.snapshot:
save_snapshot()
except:
error_count+=1
import traceback
traceback.print_exc(file=sys.stdout)
sys.stderr.write("Warning -- Error detected: execution halted.\n")
if p.metadata_dir != '' and p.compress_metadata == 'tar.gz':
_, name = os.path.split(metadata_dir)
tar = tarfile.open(normalize_path("%s.tar.gz" % name), "w:gz")
tar.add(metadata_dir, arcname=name)
tar.close()
shutil.rmtree(metadata_dir)
elif p.metadata_dir != '' and p.compress_metadata == 'zip':
_, name = os.path.split(metadata_dir)
zipf = zipfile.ZipFile(normalize_path("%s.zip" % name), 'w')
zipf.write(metadata_dir, arcname=name)
for f in os.listdir(metadata_dir):
zipf.write(os.path.join(metadata_dir, f),
os.path.join(p.metadata_dir,f))
zipf.close()
shutil.rmtree(metadata_dir)
print "\nBatch run completed at %s." % time.strftime("%a %d %b %Y %H:%M:%S +0000",
time.gmtime())
print "There were %d error(s) and %d warning(s)%s." % \
(error_count,(param.parameterized.warning_count-initial_warning_count),
((" (plus %d warning(s) prior to entering run_batch)"%initial_warning_count
if initial_warning_count>0 else "")))
# restore stdout
sys.stdout = sys.__stdout__
batch_output.close()