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


Python Experiment.load_from_config方法代码示例

本文整理汇总了Python中experiment.Experiment.load_from_config方法的典型用法代码示例。如果您正苦于以下问题:Python Experiment.load_from_config方法的具体用法?Python Experiment.load_from_config怎么用?Python Experiment.load_from_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在experiment.Experiment的用法示例。


在下文中一共展示了Experiment.load_from_config方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from experiment import Experiment [as 别名]
# 或者: from experiment.Experiment import load_from_config [as 别名]
    def load(self, dirname):
        """ Loads the project from the given directory.  The existing state
        of the project is completely modified.
        """
        # TODO: We should formalize this dependency at some point and move
        # this import to the top level
        from configobj import ConfigObj

        if dirname == "":
            raise IOError("Cannot load project from empty path.")
        elif not os.path.isdir(dirname):
            raise IOError("Cannot find directory: " + dirname)

        filename = abspath(join(dirname, self.PROJECT_FILE_NAME))
        if not os.path.isfile(filename):
            raise IOError('Cannot load %s from project directory "%s".' % \
                        (self.PROJECT_FILE_NAME, dirname))

        # Every project is saved as a text ConfigObj file that describes
        # the name and location of the real data files.
        configspec = ConfigObj(self.CONFIG_SPEC, list_values=False)
        config = ConfigObj(filename, configspec=configspec)

        contexts = []
        for context_config in config["Contexts"].values():
            ctx = DataContext.load(join(dirname, context_config["file"]))
            ctx.name = context_config["name"]
            contexts.append(ctx)
        self.contexts = contexts

        experiments = []
        if hasattr(scripting, "app"):
            app = scripting.app
        else:
            app = None
        for exp_config in config["Experiments"].values():
            experiment = Experiment()
            exp_dir = join(dirname, exp_config["save_dir"])
            experiment.load_from_config(exp_config, exp_dir, project=self)
            experiments.append(experiment)
        self.experiments = experiments

        proj_config = config["Project"]
        if proj_config.has_key("active_experiment"):
            self.active_experiment = self.find_experiment(proj_config["active_experiment"])
            
        # Update Project Save Path 
        self.project_save_path = dirname
        
        return
开发者ID:enthought,项目名称:blockcanvas,代码行数:52,代码来源:project.py


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