def test_potcar_map(self): fe_potcar = zopen(os.path.join(test_dir, "POT_GGA_PAW_PBE", "POTCAR.Fe_pv.gz")).read() # specify V instead of Fe - this makes sure the test won't pass if the # code just grabs the POTCAR from the config file (the config file would # grab the V POTCAR) potcar = Potcar(["V"], sym_potcar_map={"V": fe_potcar}) self.assertEqual(potcar.symbols, ["Fe_pv"], "Wrong symbols read in " "for POTCAR")
def test_potcar_map(self): fe_potcar = zopen(os.path.join(test_dir, "POT_GGA_PAW_PBE", "POTCAR.Fe_pv.gz")).read() #specify V instead of Fe - this makes sure the test won't pass if the #code just grabs the POTCAR from the config file (the config file would #grab the V POTCAR) potcar = Potcar(["V"], sym_potcar_map={"V": fe_potcar}) self.assertEqual(potcar.symbols, ["Fe_pv"], "Wrong symbols read in " "for POTCAR")
def string_list_in_file(s_list, filename, ignore_case=True): #based on Michael's code """ args -> s_list (str) : a list of strings in the file filename (str) : is the absolute path of the file that is analyzed Returns the strings that matched... Note: this is going to be slow as mud for huge files (e.g., OUTCAR) Using grep via subprocess might be better, but has dependency of shell (i.e., non-windows) """ matches = set() with zopen(filename, 'r') as f: for line in f: for s in s_list: if (ignore_case and s.lower() in line.lower()) or s in line: matches.add(s) if len(matches) == len(s_list): return s_list return list(matches)
def setUp(self): with zopen(os.path.join(test_dir, "POT_GGA_PAW_PBE", "POTCAR.Mn_pv.gz"), "r") as f: self.psingle = PotcarSingle(f.read())
def setUp(self): with zopen( os.path.join(test_dir, "POT_GGA_PAW_PBE", "POTCAR.Mn_pv.gz"), 'r') as f: self.psingle = PotcarSingle(f.read())