Python oyaml.load() Examples
The following are 23
code examples of oyaml.load().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
oyaml
, or try the search function
.
Example #1
Source File: classify.py From dcase2019-task5-urban-sound-tagging with MIT License | 6 votes |
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
Example #2
Source File: input_fn_tuning_job.py From cloudml-samples with Apache License 2.0 | 6 votes |
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
Example #3
Source File: zynthian_engine_csound.py From zynthian-ui with GNU General Public License v3.0 | 5 votes |
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
Example #4
Source File: file_operations.py From citrix-adc-ansible-modules with GNU General Public License v3.0 | 5 votes |
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)
Example #5
Source File: serialization.py From AttGAN-Tensorflow with MIT License | 5 votes |
def load_pickle(path, **kwargs): # wrap pickle.load with open(path, 'rb') as f: return pickle.load(f, **kwargs)
Example #6
Source File: serialization.py From AttGAN-Tensorflow with MIT License | 5 votes |
def load_yaml(path, **kwargs): import oyaml as yaml with open(path) as f: return yaml.load(f, **kwargs)
Example #7
Source File: serialization.py From AttGAN-Tensorflow with MIT License | 5 votes |
def load_json(path, **kwargs): # wrap json.load with open(path) as f: return json.load(f, **kwargs)
Example #8
Source File: serialization.py From DCGAN-LSGAN-WGAN-GP-DRAGAN-Pytorch with MIT License | 5 votes |
def load_pickle(path, **kwargs): # wrap pickle.load with open(path, 'rb') as f: return pickle.load(f, **kwargs)
Example #9
Source File: serialization.py From DCGAN-LSGAN-WGAN-GP-DRAGAN-Pytorch with MIT License | 5 votes |
def load_yaml(path, **kwargs): import oyaml as yaml with open(path) as f: return yaml.load(f, **kwargs)
Example #10
Source File: serialization.py From DCGAN-LSGAN-WGAN-GP-DRAGAN-Pytorch with MIT License | 5 votes |
def load_json(path, **kwargs): # wrap json.load with open(path) as f: return json.load(f, **kwargs)
Example #11
Source File: test_config.py From mapchete with MIT License | 5 votes |
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()
Example #12
Source File: zynthian_gui_keybinding.py From zynthian-ui with GNU General Public License v3.0 | 5 votes |
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
Example #13
Source File: zynthian_engine_puredata.py From zynthian-ui with GNU General Public License v3.0 | 5 votes |
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
Example #14
Source File: __init__.py From pentagon with Apache License 2.0 | 5 votes |
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")
Example #15
Source File: test_fortiosapi_virsh.py From fortiosapi with Apache License 2.0 | 5 votes |
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)
Example #16
Source File: serialization.py From CycleGAN-Tensorflow-2 with MIT License | 5 votes |
def load_pickle(path, **kwargs): # wrap pickle.load with open(path, 'rb') as f: return pickle.load(f, **kwargs)
Example #17
Source File: serialization.py From CycleGAN-Tensorflow-2 with MIT License | 5 votes |
def load_yaml(path, **kwargs): import oyaml as yaml with open(path) as f: return yaml.load(f, **kwargs)
Example #18
Source File: serialization.py From CycleGAN-Tensorflow-2 with MIT License | 5 votes |
def load_json(path, **kwargs): # wrap json.load with open(path) as f: return json.load(f, **kwargs)
Example #19
Source File: serialization.py From DCGAN-LSGAN-WGAN-GP-DRAGAN-Tensorflow-2 with MIT License | 5 votes |
def load_pickle(path, **kwargs): # wrap pickle.load with open(path, 'rb') as f: return pickle.load(f, **kwargs)
Example #20
Source File: serialization.py From DCGAN-LSGAN-WGAN-GP-DRAGAN-Tensorflow-2 with MIT License | 5 votes |
def load_yaml(path, **kwargs): import oyaml as yaml with open(path) as f: return yaml.load(f, **kwargs)
Example #21
Source File: serialization.py From DCGAN-LSGAN-WGAN-GP-DRAGAN-Tensorflow-2 with MIT License | 5 votes |
def load_json(path, **kwargs): # wrap json.load with open(path) as f: return json.load(f, **kwargs)
Example #22
Source File: course.py From autohelm with Apache License 2.0 | 5 votes |
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()
Example #23
Source File: metrics.py From dcase2019-task5-urban-sound-tagging with MIT License | 4 votes |
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')