Skip to content

Commit dedcadd

Browse files
committed
final batch of f-str conversion
1 parent ba4bd61 commit dedcadd

File tree

14 files changed

+42
-74
lines changed

14 files changed

+42
-74
lines changed

atomate/feff/workflows/core.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ def get_wf_xas(
8787

8888
wf_metadata = dict(metadata) if metadata else {}
8989
wf_metadata["absorbing_atom_indices"] = list(ab_atom_indices)
90-
wfname = "{}:{}:{} edge".format(
91-
structure.composition.reduced_formula, f"{spectrum_type} spectroscopy", edge
92-
)
90+
formula = structure.composition.reduced_formula
91+
wfname = f"{formula}:{spectrum_type} spectroscopy:{edge} edge"
9392

9493
return Workflow(fws, name=wfname, metadata=wf_metadata)
9594

@@ -257,9 +256,8 @@ def get_wf_eels(
257256
)
258257
)
259258

260-
wfname = "{}:{}:{} edge".format(
261-
structure.composition.reduced_formula, f"{spectrum_type} spectroscopy", edge
262-
)
259+
formula = structure.composition.reduced_formula
260+
wfname = f"{formula}:{spectrum_type} spectroscopy:{edge} edge"
263261
wf_metadata = dict(metadata) if metadata else {}
264262
wf_metadata["absorbing_atom_indices"] = list(ab_atom_indices)
265263

atomate/qchem/workflows/base/torsion_potential.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,8 @@ def get_wf_torsion_potential(
9898
rot_task = RotateTorsion(atom_indexes=atom_indexes, angle=angle)
9999
rot_opt_fw.tasks.insert(0, rot_task)
100100
# define opt section
101-
opt_line = "tors {a} {b} {c} {d} {ang}".format(
102-
a=atom_indexes[0],
103-
b=atom_indexes[1],
104-
c=atom_indexes[2],
105-
d=atom_indexes[3],
106-
ang=angle,
107-
)
101+
a, b, c, d = atom_indexes
102+
opt_line = f"tors {a} {b} {c} {d} {angle}"
108103
opt = {"CONSTRAINT": [opt_line]}
109104
for idx_t, t in enumerate(rot_opt_fw.tasks):
110105
if "WriteInputFromIOSet" in str(t):

atomate/vasp/drones.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,8 @@ def set_analysis(d, max_force_threshold=0.5, volume_change_threshold=0.2):
699699
desired_force_convergence = np.inf
700700
if max_drift > desired_force_convergence:
701701
warning_msgs.append(
702-
"Drift ({}) > desired force convergence ({}), "
703-
"structure likely not converged to desired accuracy.".format(
704-
drift, desired_force_convergence
705-
)
702+
f"Drift ({drift}) > desired force convergence ({desired_force_convergence}), "
703+
"structure likely not converged to desired accuracy."
706704
)
707705

708706
s = Structure.from_dict(d["output"]["structure"])

atomate/vasp/firetasks/approx_neb_tasks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,7 @@ def add_fix_two_atom_selective_dynamics(self, structure, fixed_index, fixed_spec
733733

734734
if structure[fixed_index].specie != Element(fixed_specie):
735735
raise ValueError(
736-
"The chosen fixed atom at index {} is not a {} atom".format(
737-
fixed_index, fixed_specie
738-
)
736+
f"The chosen fixed atom at index {fixed_index} is not a {fixed_specie} atom"
739737
)
740738

741739
# removes site properties to avoid error

atomate/vasp/firetasks/neb_tasks.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ def _get_params(self):
195195
# Check sub-folders consistence.
196196
if len(user_sdir) != len(ref_sdir_input):
197197
raise ValueError(
198-
"Sub-folder numbers are inconsistent! "
199-
"Paths are:\n{}\n{}".format(self.user_dir, self.ref_dir_input)
198+
f"Sub-folder numbers are inconsistent! Paths are:\n{self.user_dir}\n{self.ref_dir_input}"
200199
)
201200
self.user_sdir = user_sdir
202201
self.ref_sdir_input = ref_sdir_input
@@ -223,9 +222,7 @@ def _verify_inputs(self):
223222
):
224223
raise ValueError(
225224
"KPOINT files are inconsistent! "
226-
"Paths are:\n{}\n{} with kpts = {} {}".format(
227-
self.user_dir, self.ref_dir_input, user_kpoints, ref_kpoints
228-
)
225+
f"Paths are:\n{self.user_dir}\n{self.ref_dir_input} with kpts = {user_kpoints} {ref_kpoints}"
229226
)
230227

231228
# Check POTCAR
@@ -234,7 +231,7 @@ def _verify_inputs(self):
234231
if user_potcar.symbols != ref_potcar.symbols:
235232
raise ValueError(
236233
"POTCAR files are inconsistent! "
237-
"Paths are:\n{}\n{}".format(self.user_dir, self.ref_dir_input)
234+
f"Paths are:\n{self.user_dir}\n{self.ref_dir_input}"
238235
)
239236

240237
# Check POSCARs

atomate/vasp/firetasks/parse_outputs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,7 @@ def run_task(self, fw_spec):
13541354
ground_state_task_id = docs[idx]["task_id"]
13551355
if energies.count(ground_state_energy) > 1:
13561356
logger.warning(
1357-
"Multiple identical energies exist, "
1358-
"duplicate calculations for {}?".format(formula)
1357+
f"Multiple identical energies exist, duplicate calculations for {formula}?"
13591358
)
13601359

13611360
# get results for different orderings

atomate/vasp/firetasks/run_calc.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ def run_task(self, fw_spec):
386386
self._generate_outputs()
387387

388388
def _verify_inputs(self):
389-
user_incar = Incar.from_file(os.path.join(os.getcwd(), "INCAR"))
389+
cwd = os.getcwd()
390+
user_incar = Incar.from_file(os.path.join(cwd, "INCAR"))
391+
input_path = os.path.join(self["ref_dir"], "inputs")
390392

391393
# Carry out some BASIC tests.
392394

@@ -405,7 +407,7 @@ def _verify_inputs(self):
405407

406408
# Check KPOINTS
407409
if self.get("check_kpoints", True):
408-
user_kpoints = Kpoints.from_file(os.path.join(os.getcwd(), "KPOINTS"))
410+
user_kpoints = Kpoints.from_file(os.path.join(cwd, "KPOINTS"))
409411
ref_kpoints = Kpoints.from_file(
410412
os.path.join(self["ref_dir"], "inputs", "KPOINTS")
411413
)
@@ -414,17 +416,13 @@ def _verify_inputs(self):
414416
or user_kpoints.num_kpts != ref_kpoints.num_kpts
415417
):
416418
raise ValueError(
417-
"KPOINT files are inconsistent! Paths are:\n{}\n{} with kpoints {} and {}".format(
418-
os.getcwd(),
419-
os.path.join(self["ref_dir"], "inputs"),
420-
user_kpoints,
421-
ref_kpoints,
422-
)
419+
f"KPOINT files are inconsistent! Paths are:\n{cwd}\n{input_path} "
420+
f"with kpoints {user_kpoints} and {ref_kpoints}"
423421
)
424422

425423
# Check POSCAR
426424
if self.get("check_poscar", True):
427-
user_poscar = Poscar.from_file(os.path.join(os.getcwd(), "POSCAR"))
425+
user_poscar = Poscar.from_file(os.path.join(cwd, "POSCAR"))
428426
ref_poscar = Poscar.from_file(
429427
os.path.join(self["ref_dir"], "inputs", "POSCAR")
430428
)
@@ -433,22 +431,18 @@ def _verify_inputs(self):
433431
or user_poscar.site_symbols != ref_poscar.site_symbols
434432
):
435433
raise ValueError(
436-
"POSCAR files are inconsistent! Paths are:\n{}\n{}".format(
437-
os.getcwd(), os.path.join(self["ref_dir"], "inputs")
438-
)
434+
f"POSCAR files are inconsistent! Paths are:\n{cwd}\n{input_path}"
439435
)
440436

441437
# Check POTCAR
442438
if self.get("check_potcar", True):
443-
user_potcar = Potcar.from_file(os.path.join(os.getcwd(), "POTCAR"))
439+
user_potcar = Potcar.from_file(os.path.join(cwd, "POTCAR"))
444440
ref_potcar = Potcar.from_file(
445441
os.path.join(self["ref_dir"], "inputs", "POTCAR")
446442
)
447443
if user_potcar.symbols != ref_potcar.symbols:
448444
raise ValueError(
449-
"POTCAR files are inconsistent! Paths are:\n{}\n{}".format(
450-
os.getcwd(), os.path.join(self["ref_dir"], "inputs")
451-
)
445+
f"POTCAR files are inconsistent! Paths are:\n{cwd}\n{input_path}"
452446
)
453447

454448
logger.info("RunVaspFake: verified inputs successfully")

atomate/vasp/fireworks/core.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ def __init__(
9999
and job_type == "double_relaxation"
100100
):
101101
warnings.warn(
102-
"A double relaxation run might not be appropriate with ISIF {}".format(
103-
vasp_input_set.incar["ISIF"]
104-
)
102+
f"A double relaxation run might not be appropriate with ISIF {vasp_input_set.incar['ISIF']}"
105103
)
106104

107105
t = []
@@ -1082,7 +1080,7 @@ class NEBRelaxationFW(Firework):
10821080
Task 1) Read in a structure with "st_label" ("rlx", "ep0" or "ep1") and generates input sets.
10831081
Task 2) Run VASP using Custodian
10841082
Task 3) Update structure to spec
1085-
Task 4) Pass CalcLocs named "{}_dir".format(st_label)
1083+
Task 4) Pass CalcLocs named f"{st_label}_dir"
10861084
"""
10871085

10881086
def __init__(
@@ -1163,7 +1161,7 @@ class NEBFW(Firework):
11631161
The group of structures are labeled with neb_label (1, 2...)
11641162
Task 2) Run NEB VASP using Custodian
11651163
Task 3) Update structure to spec
1166-
Task 4) Pass CalcLocs named "neb_{}".format(neb_label)
1164+
Task 4) Pass CalcLocs named f"neb_{neb_label}"
11671165
"""
11681166

11691167
def __init__(

atomate/vasp/fireworks/lobster.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(
5353
lobsterin_key_dict: dict = None,
5454
lobstertodb_kwargs: dict = None,
5555
additional_outputs: List[str] = None,
56-
**kwargs
56+
**kwargs,
5757
):
5858
"""
5959
@@ -86,10 +86,8 @@ def __init__(
8686
"""
8787

8888
# TODO: make this lobster firework more flexible to allow for FATBAND and other types of calculations
89-
90-
fw_name = "{}-{}".format(
91-
structure.composition.reduced_formula if structure else "unknown", name
92-
)
89+
formula = structure.composition.reduced_formula if structure else "unknown"
90+
fw_name = f"{formula}-{name}"
9391

9492
t = []
9593
# copies all files from previous VASP calculation;

atomate/vasp/fireworks/nmr.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(
2020
copy_vasp_outputs=True,
2121
db_file=None,
2222
parents=None,
23-
**kwargs
23+
**kwargs,
2424
):
2525
"""
2626
Firework for NMR tensor calculations
@@ -41,9 +41,8 @@ def __init__(
4141
FW or list of FWS.
4242
kwargs: Other kwargs that are passed to Firework.__init__.
4343
"""
44-
fw_name = "{}-{}".format(
45-
structure.composition.reduced_formula if structure else "unknown", name
46-
)
44+
formula = structure.composition.reduced_formula if structure else "unknown"
45+
fw_name = f"{formula}-{name}"
4746

4847
isotopes = isotopes.split() if isinstance(isotopes, str) else isotopes
4948
t = []

0 commit comments

Comments
 (0)