本文整理汇总了Python中simulation.Simulation.from_yaml方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.from_yaml方法的具体用法?Python Simulation.from_yaml怎么用?Python Simulation.from_yaml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.from_yaml方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: explore
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import from_yaml [as 别名]
def explore(fpath):
_, ext = splitext(fpath)
ftype = 'data' if ext in ('.h5', '.hdf5') else 'simulation'
print("Using %s file: '%s'" % (ftype, fpath))
if ftype == 'data':
globals_def, entities = entities_from_h5(fpath)
data_source = H5Data(None, fpath)
h5in, _, globals_data = data_source.load(globals_def, entities)
h5out = None
simulation = Simulation(globals_def, None, None, None, None,
entities.values(), None)
period, entity_name = None, None
else:
simulation = Simulation.from_yaml(fpath)
h5in, h5out, globals_data = simulation.load()
period = simulation.start_period + simulation.periods - 1
entity_name = simulation.default_entity
entities = simulation.entities_map
if entity_name is None and len(entities) == 1:
entity_name = entities.keys()[0]
if period is None and entity_name is not None:
entity = entities[entity_name]
period = max(entity.output_index.keys())
eval_ctx = EvaluationContext(simulation, entities, globals_data, period,
entity_name)
try:
c = Console(eval_ctx)
c.run()
finally:
h5in.close()
if h5out is not None:
h5out.close()
示例2: explore
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import from_yaml [as 别名]
def explore(fpath):
_, ext = splitext(fpath)
ftype = 'data' if ext in ('.h5', '.hdf5') else 'simulation'
print("Using {} file: '{}'".format(ftype, fpath))
if ftype == 'data':
globals_def, entities = entities_from_h5(fpath)
simulation = Simulation(globals_def, None, None, None, None,
entities.values(), 'h5', fpath, None)
period, entity_name = None, None
else:
simulation = Simulation.from_yaml(fpath)
# use output as input
simulation.data_source = H5Source(simulation.data_sink.output_path)
period = simulation.start_period + simulation.periods - 1
entity_name = simulation.default_entity
dataset = simulation.load()
data_source = simulation.data_source
data_source.as_fake_output(dataset, simulation.entities_map)
data_sink = simulation.data_sink
entities = simulation.entities_map
if entity_name is None and len(entities) == 1:
entity_name = entities.keys()[0]
if period is None and entity_name is not None:
entity = entities[entity_name]
period = max(entity.output_index.keys())
eval_ctx = EvaluationContext(simulation, entities, dataset['globals'],
period, entity_name)
try:
c = Console(eval_ctx)
c.run()
finally:
data_source.close()
if data_sink is not None:
data_sink.close()
示例3: simulate
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import from_yaml [as 别名]
def simulate(args):
print("Using simulation file: '%s'" % args.file)
simulation = Simulation.from_yaml(args.file, input_dir=args.input_path,
input_file=args.input_file,
output_dir=args.output_path,
output_file=args.output_file)
simulation.run(args.interactive)
示例4: display
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import from_yaml [as 别名]
def display(fpath):
print("Launching ViTables...")
_, ext = splitext(fpath)
if ext in ('.h5', '.hdf5'):
files = [fpath]
else:
ds = Simulation.from_yaml(fpath).data_source
files = [ds.input_path, ds.output_path]
print("Trying to open:", " and ".join(str(f) for f in files))
viewhdf(files)
示例5: display
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import from_yaml [as 别名]
def display(fpath):
print("Launching ViTables...")
if fpath:
_, ext = splitext(fpath)
if ext in ('.h5', '.hdf5'):
files = [fpath]
else:
simulation = Simulation.from_yaml(fpath)
files = [simulation.data_source.input_path,
simulation.data_sink.output_path]
print("Trying to open:", " and ".join(str(f) for f in files))
else:
files = []
viewhdf(files)
示例6: simulate
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import from_yaml [as 别名]
def simulate(args):
print("Using simulation file: '{}'".format(args.fpath))
simulation = Simulation.from_yaml(args.fpath,
input_dir=args.input_path,
input_file=args.input_file,
output_dir=args.output_path,
output_file=args.output_file,
start_period=args.startperiod,
periods=args.periods, seed=args.seed,
skip_shows=args.skipshows,
skip_timings=args.skiptimings,
log_level=args.loglevel,
assertions=args.assertions,
autodump=args.autodump,
autodiff=args.autodiff)
simulation.run(args.interactive)
示例7: explore
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import from_yaml [as 别名]
def explore(fpath):
_, ext = splitext(fpath)
ftype = 'data' if ext in ('.h5', '.hdf5') else 'simulation'
print "Using %s file: '%s'" % (ftype, fpath)
if ftype == 'data':
h5in = populate_registry(fpath)
h5out = None
entity, period = None, None
else:
simulation = Simulation.from_yaml(fpath)
h5in, h5out, periodic_globals = simulation.load()
ent_name = simulation.default_entity
entity = entity_registry[ent_name] if ent_name is not None else None
period = simulation.start_period + simulation.periods - 1
try:
c = Console(entity, period)
c.run()
finally:
h5in.close()
if h5out is not None:
h5out.close()
示例8: explore
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import from_yaml [as 别名]
def explore(fpath):
_, ext = splitext(fpath)
ftype = 'data' if ext in ('.h5', '.hdf5') else 'simulation'
print("Using %s file: '%s'" % (ftype, fpath))
if ftype == 'data':
globals_def = populate_registry(fpath)
data_source = H5Data(None, fpath)
h5in, _, globals_data = data_source.load(globals_def,
registry.entity_registry)
h5out = None
entity, period = None, None
else:
simulation = Simulation.from_yaml(fpath)
h5in, h5out, globals_data = simulation.load()
entity = simulation.console_entity
period = simulation.start_period + simulation.periods - 1
globals_def = simulation.globals_def
try:
c = Console(entity, period, globals_def, globals_data)
c.run()
finally:
h5in.close()
if h5out is not None:
h5out.close()
示例9:
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import from_yaml [as 别名]
########### RETRO ############
fichier = chemin+'Patrimoine\\Past\\import.yml'
sys.argv.append('import')
sys.argv.append(fichier)
main.main()
sys.argv.remove(fichier)
fichier = chemin+'Patrimoine\\Past\\retro.yml'
simulation= Simulation.from_yaml(
fichier,
input_dir=None,
input_file=None,
output_dir=None,
output_file=None)
simulation.run(False)
fichier = chemin+'Patrimoine\\lien_parent_enfant\\match_par_enf.yml'
fichier = chemin+'Patrimoine\\lien_parent_enfant\\expand.yml'
fichier = chemin+'Patrimoine\\lien_parent_enfant\\match_par_enf.yml'
fichier = chemin+'Patrimoine\\lien_parent_enfant\\match_score.yml'
#simulation= Simulation.from_yaml(
# fichier,
# input_dir=None,
# input_file=None,