Skip to content

Commit ba4bd61

Browse files
committed
remove no-op string coercion in f"{str(foo)}"
1 parent f12cc42 commit ba4bd61

File tree

9 files changed

+36
-57
lines changed

9 files changed

+36
-57
lines changed

atomate/qchem/workflows/tests/test_FF_and_critic.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ def test_FFopt_and_critic(self):
4949
},
5050
)
5151
# use powerup to replace run with fake run
52+
alph_formula = initial_mol.composition.alphabetical_formula
5253
ref_dirs = {
53-
"{}:{}".format(
54-
initial_mol.composition.alphabetical_formula, "FFopt_testing"
55-
): os.path.join(test_files, "FFopt"),
56-
"{}:{}".format(
57-
initial_mol.composition.alphabetical_formula, "CC2_testing"
58-
): os.path.join(test_files, "critic_example"),
54+
f"{alph_formula}:FFopt_testing": os.path.join(
55+
test_files, "FFopt"
56+
),
57+
f"{alph_formula}:CC2_testing": os.path.join(
58+
test_files, "critic_example"
59+
),
5960
}
6061
fake_wf = use_fake_qchem(real_wf, ref_dirs)
6162
self.lp.add_wf(fake_wf)
@@ -70,22 +71,14 @@ def test_FFopt_and_critic(self):
7071
self.assertTrue(all([s == "COMPLETED" for s in wf_test.fw_states.values()]))
7172

7273
FFopt = self.get_task_collection().find_one(
73-
{
74-
"task_label": "{}:{}".format(
75-
initial_mol.composition.alphabetical_formula, "FFopt_testing"
76-
)
77-
}
74+
{"task_label": f"{alph_formula}:FFopt_testing"}
7875
)
7976
self.assertEqual(FFopt["calcs_reversed"][0]["input"]["smx"]["solvent"], "other")
8077
self.assertEqual(FFopt["num_frequencies_flattened"], 0)
8178
FFopt_final_mol = Molecule.from_dict(FFopt["output"]["optimized_molecule"])
8279

8380
CC2 = self.get_task_collection().find_one(
84-
{
85-
"task_label": "{}:{}".format(
86-
initial_mol.composition.alphabetical_formula, "CC2_testing"
87-
)
88-
}
81+
{"task_label": f"{alph_formula}:CC2_testing"}
8982
)
9083
CC2_initial_mol = Molecule.from_dict(CC2["input"]["initial_molecule"])
9184

atomate/vasp/builders/fix_tasks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ def run(self):
4747
{"task_id": 1, "analysis": 1},
4848
):
4949
logger.info(
50-
"Converting delta_volume_percent to be on a percentage scale, tid: {}".format(
51-
t["task_id"]
52-
)
50+
f"Converting delta_volume_percent to be on a percentage scale, tid: {t['task_id']}"
5351
)
5452
self._tasks.update_one(
5553
{"task_id": t["task_id"]},

atomate/vasp/firetasks/approx_neb_tasks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,7 @@ def run_task(self, fw_spec):
503503
else:
504504
raise ValueError("NEBPathfinder requires exactly two end points")
505505
except Exception:
506-
raise ValueError(
507-
f"{str(end_points_combo)} end_points_combo input is incorrect"
508-
)
506+
raise ValueError(f"{end_points_combo} end_points_combo input is incorrect")
509507

510508
# get the database connection
511509
db_file = env_chk(self["db_file"], fw_spec)

atomate/vasp/fireworks/core.py

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,8 @@ def __init__(
177177
vasptodb_kwargs["additional_fields"] = {}
178178
vasptodb_kwargs["additional_fields"]["task_label"] = name
179179

180-
fw_name = "{}-{}".format(
181-
structure.composition.reduced_formula if structure else "unknown", name
182-
)
180+
formula = structure.composition.reduced_formula if structure else "unknown"
181+
fw_name = f"{formula}-{name}"
183182

184183
has_previous_calc = False
185184

@@ -336,9 +335,8 @@ def __init__(
336335
vasptodb_kwargs["additional_fields"] = {}
337336
vasptodb_kwargs["additional_fields"]["task_label"] = name
338337

339-
fw_name = "{}-{}".format(
340-
structure.composition.reduced_formula if structure else "unknown", name
341-
)
338+
formula = structure.composition.reduced_formula if structure else "unknown"
339+
fw_name = f"{formula}-{name}"
342340

343341
if spec_structure_key is not None:
344342
vasp_input_set = vasp_input_set or MPStaticSet(
@@ -473,9 +471,8 @@ def __init__(
473471
"""
474472
name = name if name else f"hse {mode}"
475473

476-
fw_name = "{}-{}".format(
477-
structure.composition.reduced_formula if structure else "unknown", name
478-
)
474+
formula = structure.composition.reduced_formula if structure else "unknown"
475+
fw_name = f"{formula}-{name}"
479476

480477
t = []
481478
if prev_calc_dir:
@@ -544,11 +541,8 @@ def __init__(
544541
"""
545542
input_set_overrides = input_set_overrides or {}
546543

547-
fw_name = "{}-{} {}".format(
548-
structure.composition.reduced_formula if structure else "unknown",
549-
name,
550-
mode,
551-
)
544+
formula = structure.composition.reduced_formula if structure else "unknown"
545+
fw_name = f"{formula}-{name} {mode}"
552546
t = []
553547

554548
if prev_calc_dir:
@@ -625,9 +619,8 @@ def __init__(
625619
"""
626620
name = "static dielectric" if lepsilon else "phonon"
627621

628-
fw_name = "{}-{}".format(
629-
structure.composition.reduced_formula if structure else "unknown", name
630-
)
622+
formula = structure.composition.reduced_formula if structure else "unknown"
623+
fw_name = f"{formula}-{name}"
631624

632625
user_incar_settings = user_incar_settings or {}
633626
t = []
@@ -720,10 +713,9 @@ def __init__(
720713
user_incar_settings (dict): Parameters in INCAR to override
721714
**kwargs: Other kwargs that are passed to Firework.__init__.
722715
"""
723-
name = f"{name}_{str(mode)}_{str(displacement)}"
724-
fw_name = "{}-{}".format(
725-
structure.composition.reduced_formula if structure else "unknown", name
726-
)
716+
name = f"{name}_{mode}_{displacement}"
717+
formula = structure.composition.reduced_formula if structure else "unknown"
718+
fw_name = f"{formula}-{name}"
727719

728720
user_incar_settings = user_incar_settings or {}
729721

@@ -796,9 +788,8 @@ def __init__(
796788
FW or list of FWS.
797789
**kwargs: Other kwargs that are passed to Firework.__init__.
798790
"""
799-
fw_name = "{}-{}".format(
800-
structure.composition.reduced_formula if structure else "unknown", name
801-
)
791+
formula = structure.composition.reduced_formula if structure else "unknown"
792+
fw_name = f"{formula}-{name}"
802793

803794
t = []
804795
if prev_calc_dir:
@@ -1057,9 +1048,8 @@ def __init__(
10571048
additional_fields (dict): fields added to the document such as user-defined tags or name, ids, etc
10581049
**kwargs: Other kwargs that are passed to Firework.__init__.
10591050
"""
1060-
fw_name = "{}-{}".format(
1061-
structure.composition.reduced_formula if structure else "unknown", name
1062-
)
1051+
formula = structure.composition.reduced_formula if structure else "unknown"
1052+
fw_name = f"{formula}-{name}"
10631053

10641054
additional_fields = additional_fields or {}
10651055

atomate/vasp/workflows/base/bulk_modulus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def get_wf_bulk_modulus(
5555
Workflow
5656
"""
5757

58-
tag = tag or f"bulk_modulus group: >>{str(uuid4())}<<"
58+
tag = tag or f"bulk_modulus group: >>{uuid4()}<<"
5959

6060
deformations = [Deformation(defo_mat) for defo_mat in deformations]
6161

atomate/vasp/workflows/base/ferroelectric.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ def get_wf_ferroelectric(
131131
interpolation.append(
132132
LcalcpolFW(
133133
structure=polar_structure,
134-
name=f"_interpolation_{str(i)}_polarization",
135-
static_name=f"_interpolation_{str(i)}_static",
134+
name=f"_interpolation_{i}_polarization",
135+
static_name=f"_interpolation_{i}_static",
136136
vasp_cmd=vasp_cmd,
137137
db_file=db_file,
138138
vasp_input_set=vasp_input_set_polar,

atomate/vasp/workflows/base/gibbs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_wf_gibbs_free_energy(
6969
Workflow
7070
"""
7171

72-
tag = tag or f"gibbs group: >>{str(uuid4())}<<"
72+
tag = tag or f"gibbs group: >>{uuid4()}<<"
7373

7474
deformations = [Deformation(defo_mat) for defo_mat in deformations]
7575

atomate/vasp/workflows/base/thermal_expansion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def get_wf_thermal_expansion(
6868
"'phonopy' package NOT installed. Required for the final analysis step."
6969
)
7070

71-
tag = tag or f"thermal_expansion group: >>{str(uuid4())}<<"
71+
tag = tag or f"thermal_expansion group: >>{uuid4()}<<"
7272

7373
deformations = [Deformation(defo_mat) for defo_mat in deformations]
7474

atomate/vasp/workflows/presets/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ def wf_gibbs_free_energy(structure, c=None):
477477
deformations = c.get("DEFORMATIONS", defos)
478478
user_kpoints_settings = {"grid_density": 7000}
479479

480-
tag = f"gibbs group: >>{str(uuid4())}<<"
480+
tag = f"gibbs group: >>{uuid4()}<<"
481481

482482
# input set for structure optimization
483483
vis_relax = MPRelaxSet(structure, force_gamma=True)
@@ -584,7 +584,7 @@ def wf_bulk_modulus(structure, c=None):
584584
(np.identity(3) * (1 + x)).tolist() for x in np.linspace(-0.05, 0.05, 6)
585585
]
586586

587-
tag = f"bulk_modulus group: >>{str(uuid4())}<<"
587+
tag = f"bulk_modulus group: >>{uuid4()}<<"
588588

589589
# input set for structure optimization
590590
vis_relax = MPRelaxSet(structure, force_gamma=True)
@@ -667,7 +667,7 @@ def wf_thermal_expansion(structure, c=None):
667667
(np.identity(3) * (1 + x)).tolist() for x in np.linspace(-0.1, 0.1, 10)
668668
]
669669

670-
tag = f"thermal_expansion group: >>{str(uuid4())}<<"
670+
tag = f"thermal_expansion group: >>{uuid4()}<<"
671671

672672
# input set for structure optimization
673673
vis_relax = MPRelaxSet(structure, force_gamma=True)

0 commit comments

Comments
 (0)