当前位置: 首页>>代码示例>>Python>>正文


Python Simulation.from_yaml方法代码示例

本文整理汇总了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()
开发者ID:TaxIPP-Life,项目名称:liam2,代码行数:34,代码来源:main.py

示例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()
开发者ID:antoinearnoud,项目名称:liam2,代码行数:36,代码来源:main.py

示例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)
开发者ID:johnnam,项目名称:liam2,代码行数:10,代码来源:main.py

示例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)
开发者ID:TaxIPP-Life,项目名称:liam2,代码行数:12,代码来源:main.py

示例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)
开发者ID:antoinearnoud,项目名称:liam2,代码行数:16,代码来源:main.py

示例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)
开发者ID:antoinearnoud,项目名称:liam2,代码行数:20,代码来源:main.py

示例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()
开发者ID:jonathangoupille,项目名称:Myliam2,代码行数:23,代码来源:main.py

示例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()
开发者ID:johnnam,项目名称:liam2,代码行数:26,代码来源:main.py

示例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,
开发者ID:AlexisEidelman,项目名称:Til_old,代码行数:33,代码来源:run_patrimoine.py


注:本文中的simulation.Simulation.from_yaml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。