當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。