def yaml_read_irred_perts(filename, doc_tag="!IrredPerts"): """Read the list of irreducible perturbations from file.""" with YamlTokenizer(filename) as r: doc = r.next_doc_with_tag(doc_tag) d = yaml.safe_load(doc.text_notag) return [AttrDict(**pert) for pert in d["irred_perts"]]
def yaml_read_kpoints(filename, doc_tag="!Kpoints"): """Read the K-points from file.""" with YamlTokenizer(filename) as r: doc = r.next_doc_with_tag(doc_tag) d = yaml.safe_load(doc.text_notag) return np.array(d["reduced_coordinates_of_qpoints"])
def test_database_version(self): with MPRester(notify_db_version=True) as mpr: db_version = mpr.get_database_version() self.assertIsInstance(db_version, str) with open(SETTINGS_FILE, "rt") as f: d = yaml.safe_load(f) self.assertEqual(d["MAPI_DB_VERSION"]["LAST_ACCESSED"], db_version) self.assertIsInstance(d["MAPI_DB_VERSION"]["LOG"][db_version], int)
def as_dict(self): """Use Yaml to parse the text (without the tag) and returns a dictionary.""" return yaml.safe_load(self.text_notag)