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


Python oyaml.load方法代码示例

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


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

示例1: load_previous_trials

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def load_previous_trials(output_name):
    print('>>>>> Loading previous results')
    with tf.gfile.GFile(output_name, 'r') as f:
        yaml_str = f.read()

    results_dict = yaml.load(yaml_str)
    x0 = []
    y0 = []

    if results_dict:
        for timestamp, scores_dict in results_dict.items():
            score = scores_dict['score']
            params_dict = scores_dict['input_fn_params']
            params = [params_dict[d.name] for d in space]

            x0.append(params)
            y0.append(score)
    else:
        x0 = None
        y0 = None

    return x0, y0 
开发者ID:GoogleCloudPlatform,项目名称:cloudml-samples,代码行数:24,代码来源:input_fn_tuning_job.py

示例2: load_embeddings

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def load_embeddings(file_list, emb_dir):
    """
    Load saved embeddings from an embedding directory

    Parameters
    ----------
    file_list
    emb_dir

    Returns
    -------
    embeddings
    ignore_idxs

    """
    embeddings = []
    for idx, filename in enumerate(file_list):
        emb_path = os.path.join(emb_dir, os.path.splitext(filename)[0] + '.npy.gz')
        with gzip.open(emb_path, 'rb') as f:
            embeddings.append(np.load(f))

    return embeddings 
开发者ID:sainathadapa,项目名称:dcase2019-task5-urban-sound-tagging,代码行数:24,代码来源:classify.py

示例3: __init__

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def __init__(self, file):
        """
        Parse course.yml contents into instances.
        """
        self.config = Config()
        self.helm = Helm()
        self._dict = yaml.load(file)
        self._repositories = []
        self._charts = []
        for name, repository in self._dict.get('repositories', {}).iteritems():
            repository['name'] = name
            self._repositories.append(Repository(repository))

        for name, chart in self._dict.get('charts', {}).iteritems():
            self._charts.append(Chart({name: chart}))

        for repo in self._repositories:
            type(repo)
            if not self.config.local_development:
                logging.debug("Installing repository: {}".format(repo))
                repo.install()

        self.helm.repo_update()

        if not self.config.local_development:
            self._compare_required_versions() 
开发者ID:FairwindsOps,项目名称:autohelm,代码行数:28,代码来源:course.py

示例4: load_json

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def load_json(path, **kwargs):
    # wrap json.load
    with open(path) as f:
        return json.load(f, **kwargs) 
开发者ID:LynnHo,项目名称:DCGAN-LSGAN-WGAN-GP-DRAGAN-Tensorflow-2,代码行数:6,代码来源:serialization.py

示例5: load_yaml

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def load_yaml(path, **kwargs):
    import oyaml as yaml
    with open(path) as f:
        return yaml.load(f, **kwargs) 
开发者ID:LynnHo,项目名称:DCGAN-LSGAN-WGAN-GP-DRAGAN-Tensorflow-2,代码行数:6,代码来源:serialization.py

示例6: load_pickle

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def load_pickle(path, **kwargs):
    # wrap pickle.load
    with open(path, 'rb') as f:
        return pickle.load(f, **kwargs) 
开发者ID:LynnHo,项目名称:DCGAN-LSGAN-WGAN-GP-DRAGAN-Tensorflow-2,代码行数:6,代码来源:serialization.py

示例7: test_setoverlayconfig

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def test_setoverlayconfig(self):
        yamldata = '''
            antivirus:
              profile:
                apisettree:
                  "scan-mode": "quick"
                  'http': {"options": "scan avmonitor",}
                  "emulator": "enable"
            firewall:
              policy:
                67:
                  'name': "Testfortiosapi"
                  'action': "accept"
                  'srcaddr': [{"name": "all"}]
                  'dstaddr': [{"name": "all"}]
                  'schedule': "always"
                  'service': [{"name": "HTTPS"}]
                  "utm-status": "enable"
                  "profile-type": "single"
                  'av-profile': "apisettree"
                  'profile-protocol-options': "default"
                  'ssl-ssh-profile': "certificate-inspection"
                  'logtraffic': "all"
                    '''

        yamltree = yaml.load(yamldata, Loader=yaml.SafeLoader)
        yamltree['firewall']['policy'][67]['srcintf'] = [{'name': conf["sut"]["porta"]}]
        yamltree['firewall']['policy'][67]['dstintf'] = [{'name': conf["sut"]["portb"]}]


        self.assertTrue(fgt.setoverlayconfig(yamltree, vdom=conf['sut']['vdom']), True) 
开发者ID:fortinet-solutions-cse,项目名称:fortiosapi,代码行数:33,代码来源:test_fortiosapi_virsh.py

示例8: __init__

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def __init__(self, file=None):
            # Fetch yaml file as ordered dict
            self.file = file 
            self.data = {}
            if self.file:
                with open(self.file) as yf:
                    self.data = yaml.load(yf.read())
                logging.debug(self.data)
            else:
                logging.debug("YamlEditor initialized with no file") 
开发者ID:FairwindsOps,项目名称:pentagon,代码行数:12,代码来源:__init__.py

示例9: load_preset_config

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def load_preset_config(self, preset):
		config_fpath = preset[0] + "/zynconfig.yml"
		try:
			with open(config_fpath,"r") as fh:
				yml = fh.read()
				logging.info("Loading preset config file %s => \n%s" % (config_fpath,yml))
				self.preset_config = yaml.load(yml, Loader=yaml.SafeLoader)
				return True
		except Exception as e:
			logging.error("Can't load preset config file '%s': %s" % (config_fpath,e))
			return False 
开发者ID:zynthian,项目名称:zynthian-ui,代码行数:13,代码来源:zynthian_engine_puredata.py

示例10: load_preset_config

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def load_preset_config(self, preset_dir):
		config_fpath = preset_dir + "/zynconfig.yml"
		try:
			with open(config_fpath,"r") as fh:
				yml = fh.read()
				logging.info("Loading preset config file %s => \n%s" % (config_fpath,yml))
				self.preset_config = yaml.load(yml, Loader=yaml.SafeLoader)
				return True
		except Exception as e:
			logging.error("Can't load preset config file '%s': %s" % (config_fpath,e))
			return False 
开发者ID:zynthian,项目名称:zynthian-ui,代码行数:13,代码来源:zynthian_engine_csound.py

示例11: load

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def load(self, config="keybinding"):
		"""
		Load key binding map from file
		
		Parameters
		----------
		config : str,optional
			Name of configuration to load - the file <config>.yaml will be loaded from the Zynthian config directory
			Default: 'keybinding'
		
		Returns
		-------
		bool
			True on success		
		"""

		logging.info("Loading key binding from {}.yaml".format(config))
		config_dir = environ.get('ZYNTHIAN_CONFIG_DIR',"/zynthian/config")
		config_fpath = config_dir + "/" + config + ".yaml"
		try:
			with open(config_fpath, "r") as fh:
				yml = fh.read()
				logging.debug("Loading keyboard binding config file '{}' =>\n{}".format(config_fpath,yml))
				self.config = yaml.load(yml, Loader=yaml.SafeLoader)
				self.parse_map()
				return True

		except Exception as e:
			logging.debug("Loading default keyboard bindings.")
			self.reset_config()
			return False 
开发者ID:zynthian,项目名称:zynthian-ui,代码行数:33,代码来源:zynthian_gui_keybinding.py

示例12: test_read_input_order

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def test_read_input_order(file_groups):
    """Assert input objects are represented in the same order as configured."""
    with mapchete.open(file_groups.path) as mp:
        inputs = yaml.load(open(file_groups.path).read())["input"]
        tile = mp.config.process_pyramid.tile(0, 0, 0)
        # read written data from within MapcheteProcess object
        user_process = mapchete.MapcheteProcess(
            tile=tile,
            params=mp.config.params_at_zoom(tile.zoom),
            input=mp.config.get_inputs_for_tile(tile),
        )
        assert inputs.keys() == user_process.input.keys() 
开发者ID:ungarj,项目名称:mapchete,代码行数:14,代码来源:test_config.py

示例13: yamlstr_to_yaml

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def yamlstr_to_yaml(output_yamlfile, yamlstr):
    with open(output_yamlfile, 'w') as fw:
        load_data = yaml.load(yamlstr)
        yaml_data = pyaml.dump(load_data)
        fw.write(yaml_data) 
开发者ID:citrix,项目名称:citrix-adc-ansible-modules,代码行数:7,代码来源:file_operations.py

示例14: parse_coarse_prediction

# 需要导入模块: import oyaml [as 别名]
# 或者: from oyaml import load [as 别名]
def parse_coarse_prediction(pred_csv_path, yaml_path):
    """
    Parse coarse-level predictions from a CSV file containing both fine-level
    and coarse-level predictions (and possibly additional metadata).
    Returns a Pandas DataFrame in which the column names are coarse
    IDs of the form 1, 2, 3 etc.


    Parameters
    ----------
    pred_csv_path: string
        Path to the CSV file containing predictions.

    yaml_path: string
        Path to the YAML file containing coarse taxonomy.


    Returns
    -------
    pred_coarse_df: DataFrame
        Coarse-level complete predictions.
    """

    # Create dictionary to parse tags
    with open(yaml_path, 'r') as stream:
        yaml_dict = yaml.load(stream, Loader=yaml.Loader)

    # Collect tag names as strings and map them to coarse ID pairs.
    rev_coarse_dict = {"_".join([str(k), yaml_dict["coarse"][k]]): k
        for k in yaml_dict["coarse"]}

    # Read comma-separated values with the Pandas library
    pred_df = pd.read_csv(pred_csv_path)

    # Assign a predicted column to each coarse key, by using the tag as an
    # intermediate hashing step.
    pred_coarse_dict = {}
    for c in rev_coarse_dict:
        if c in pred_df:
            pred_coarse_dict[str(rev_coarse_dict[c])] = pred_df[c]
        else:
            pred_coarse_dict[str(rev_coarse_dict[c])] = np.zeros((len(pred_df),))
            warnings.warn("Column not found: " + c)

    # Copy over the audio filename strings corresponding to each sample.
    pred_coarse_dict["audio_filename"] = pred_df["audio_filename"]

    # Build a new Pandas DataFrame with coarse keys as column names.
    pred_coarse_df = pd.DataFrame.from_dict(pred_coarse_dict)

    # Return output in DataFrame format.
    # The column names are of the form 1, 2, 3, etc.
    return pred_coarse_df.sort_values('audio_filename') 
开发者ID:sainathadapa,项目名称:dcase2019-task5-urban-sound-tagging,代码行数:55,代码来源:metrics.py


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