Skip to content

Commit 5071a98

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4f73a9b commit 5071a98

19 files changed

+56
-86
lines changed

gmso/abc/abstract_potential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def add_tag(self, tag: str, value: Any, overwrite=True) -> None:
135135
"""Add metadata for a particular tag"""
136136
if self.tags.get(tag) and not overwrite:
137137
raise ValueError(
138-
f"Tag {tag} already exists. " f"Please use overwrite=True to overwrite"
138+
f"Tag {tag} already exists. Please use overwrite=True to overwrite"
139139
)
140140
self.tags[tag] = value
141141

gmso/core/box.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _validate_lengths(lengths):
4646
):
4747
if lengths[0] > 0 and lengths[1] > 0:
4848
warnings.warn(
49-
"A c value of 0 was passed. This will be " "interpreted as a 2-D box."
49+
"A c value of 0 was passed. This will be interpreted as a 2-D box."
5050
)
5151
else:
5252
raise ValueError(

gmso/core/parametric_potential.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def etree(self, units=None):
252252
f"Please specify member_classes or member_types attribute."
253253
)
254254
for idx, value in enumerate(iterating_attribute):
255-
attrib[f"{prefix}{idx+1}"] = str(value)
255+
attrib[f"{prefix}{idx + 1}"] = str(value)
256256
xml_element = etree.Element(self.__class__.__name__, attrib=attrib)
257257
params = etree.SubElement(xml_element, "Parameters")
258258

@@ -340,7 +340,6 @@ def member_types(x):
340340

341341
desc = desc.replace(
342342
">",
343-
f", \n parameters: {self.parameters},\n"
344-
f"member types: {member_types(self)}>",
343+
f", \n parameters: {self.parameters},\nmember types: {member_types(self)}>",
345344
)
346345
return desc

gmso/core/topology.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,7 @@ def _set_scaling_factor(self, value, molecule_id, interaction, name, index):
793793

794794
if any(np.isnan(value)):
795795
raise ValueError(
796-
f"Cannot assign a nan/NoneType to `{name}`. "
797-
f"Provided value: {org_value}"
796+
f"Cannot assign a nan/NoneType to `{name}`. Provided value: {org_value}"
798797
)
799798

800799
if value.shape != (1,) and value.shape != (3,):
@@ -1788,7 +1787,7 @@ def _parse_parameter_expression(self, df, parameter, unyts_bool):
17881787
getattr(getattr(self, parameter)[0], parameter[:-1] + "_type").parameters
17891788
):
17901789
df[
1791-
f"Parameter {i} ({param}) {getattr(getattr(self, parameter)[0], parameter[:-1]+'_type').parameters[param].units}"
1790+
f"Parameter {i} ({param}) {getattr(getattr(self, parameter)[0], parameter[:-1] + '_type').parameters[param].units}"
17921791
] = list(
17931792
_return_float_for_unyt(
17941793
getattr(connection, parameter[:-1] + "_type").parameters[param],

gmso/external/convert_foyer_xml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def _write_nbforces(forcefield, ff_kwargs):
270270
nonBondedAtomTypes,
271271
"AtomType",
272272
attrib_dict={
273-
"name": atom_type.get("name", f"AtomType-{j+1}"),
273+
"name": atom_type.get("name", f"AtomType-{j + 1}"),
274274
"atomclass": atom_type.get("class", ""),
275275
"element": atom_type.get("element", ""),
276276
"charge": atom_type.get("charge", "0.0"),

gmso/external/convert_hoomd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ def _parse_nonbonded_forces(
751751
if i == 0:
752752
exclusions.append("bond")
753753
else:
754-
exclusions.append(f"1-{i+2}")
754+
exclusions.append(f"1-{i + 2}")
755755
nlist = hoomd.md.nlist.Cell(exclusions=exclusions, buffer=nlist_buffer)
756756

757757
nbonded_forces = list()

gmso/formats/lammpsdata.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,9 @@ def _validate_unit_compatibility(top, base_unyts):
647647
float(base_unyts.convert_parameter(parameter, n_decimals=6, name=name)),
648648
parameter.value,
649649
atol=1e-3,
650-
), f"Units System {base_unyts.usystem} is not compatible with {atype} with value {parameter}"
650+
), (
651+
f"Units System {base_unyts.usystem} is not compatible with {atype} with value {parameter}"
652+
)
651653

652654

653655
def _write_header(out_file, top, atom_style, dihedral_parser):
@@ -1171,7 +1173,7 @@ def _write_conn_data(out_file, top, connStr, sorted_typesList):
11711173
if sort_by_types(ele) == ctype_members
11721174
]
11731175
for index in indexList:
1174-
typeStr = f"{i+1:<6d}\t{index+1:<6d}\t"
1176+
typeStr = f"{i + 1:<6d}\t{index + 1:<6d}\t"
11751177
sorted_membersList = sort_connection_members(conn, sort_by="index", top=top)
11761178
indexStr = "\t".join(
11771179
[

gmso/formats/mcf.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def _write_atom_information(mcf, top, in_ring):
315315
mcf.write("{:d}\n".format(len(top.sites)))
316316
for idx, site in enumerate(top.sites):
317317
mcf.write(
318-
"{:<4d} " "{:<6s} " "{:<2s} " "{:8.4f} " "{:12.8f} ".format(
318+
"{:<4d} {:<6s} {:<2s} {:8.4f} {:12.8f} ".format(
319319
idx + 1,
320320
atypes_list[idx],
321321
names[idx],
@@ -325,15 +325,15 @@ def _write_atom_information(mcf, top, in_ring):
325325
)
326326
if vdw_style == "LJ":
327327
mcf.write(
328-
"{:3s} " "{:10.5f} " "{:10.5f}".format(
328+
"{:3s} {:10.5f} {:10.5f}".format(
329329
vdw_style,
330330
(site.atom_type.parameters["epsilon"] / u.kb).in_units("K").value,
331331
site.atom_type.parameters["sigma"].in_units("Angstrom").value,
332332
)
333333
)
334334
elif vdw_style == "Mie":
335335
mcf.write(
336-
"{:3s} " "{:10.5f} " "{:10.5f} " "{:8.3f} " "{:8.3f}".format(
336+
"{:3s} {:10.5f} {:10.5f} {:8.3f} {:8.3f}".format(
337337
vdw_style,
338338
(site.atom_type.parameters["epsilon"] / u.kb).in_units("K").value,
339339
site.atom_type.parameters["sigma"].in_units("Angstrom").value,
@@ -363,7 +363,7 @@ def _write_bond_information(mcf, top):
363363
mcf.write("{:d}\n".format(len(top.bonds)))
364364
for idx, bond in enumerate(top.bonds):
365365
mcf.write(
366-
"{:<4d} " "{:<4d} " "{:<4d} " "{:s} " "{:10.5f}\n".format(
366+
"{:<4d} {:<4d} {:<4d} {:s} {:10.5f}\n".format(
367367
idx + 1,
368368
top.get_index(bond.connection_members[0]) + 1,
369369
top.get_index(bond.connection_members[1]) + 1,
@@ -403,7 +403,7 @@ def _write_angle_information(mcf, top):
403403
angle_style = _get_angle_style(angle)
404404
if angle_style == "fixed":
405405
mcf.write(
406-
"{:s} " "{:10.5f}\n".format(
406+
"{:s} {:10.5f}\n".format(
407407
angle_style,
408408
angle.connection_type.parameters["theta_eq"]
409409
.in_units(u.degree)
@@ -412,7 +412,7 @@ def _write_angle_information(mcf, top):
412412
)
413413
elif angle_style == "harmonic":
414414
mcf.write(
415-
"{:s} " "{:10.5f} " "{:10.5f}\n".format(
415+
"{:s} {:10.5f} {:10.5f}\n".format(
416416
angle_style,
417417
(0.5 * angle.connection_type.parameters["k"] / u.kb)
418418
.in_units("K/rad**2")
@@ -452,7 +452,7 @@ def _write_dihedral_information(mcf, top):
452452
mcf.write("{:d}\n".format(len(top.dihedrals)))
453453
for idx, dihedral in enumerate(top.dihedrals):
454454
mcf.write(
455-
"{:<4d} " "{:<4d} " "{:<4d} " "{:<4d} " "{:<4d} ".format(
455+
"{:<4d} {:<4d} {:<4d} {:<4d} {:<4d} ".format(
456456
idx + 1,
457457
top.get_index(dihedral.connection_members[0]) + 1,
458458
top.get_index(dihedral.connection_members[1]) + 1,
@@ -488,7 +488,7 @@ def _write_dihedral_information(mcf, top):
488488
# So we need to exclude the last term in the GMSO topology.
489489
dihedral_style = "OPLS"
490490
mcf.write(
491-
"{:s} " "{:10.5f} " "{:10.5f} " "{:10.5f} " "{:10.5f}\n".format(
491+
"{:s} {:10.5f} {:10.5f} {:10.5f} {:10.5f}\n".format(
492492
dihedral_style,
493493
0.5
494494
* dihedral.connection_type.parameters["k0"]
@@ -510,7 +510,7 @@ def _write_dihedral_information(mcf, top):
510510
)
511511
elif dihedral_style == "CHARMM":
512512
mcf.write(
513-
"{:s} " "{:10.5f} " "{:10.5f} " "{:10.5f}\n".format(
513+
"{:s} {:10.5f} {:10.5f} {:10.5f}\n".format(
514514
dihedral_style,
515515
dihedral.connection_type.parameters["k"].in_units("kJ/mol").value,
516516
dihedral.connection_type.parameters["n"],
@@ -521,7 +521,7 @@ def _write_dihedral_information(mcf, top):
521521
)
522522
elif dihedral_style == "HARMONIC":
523523
mcf.write(
524-
"{:s} " "{:10.5f} " "{:10.5f}\n".format(
524+
"{:s} {:10.5f} {:10.5f}\n".format(
525525
dihedral_style.lower(),
526526
0.5
527527
* dihedral.connection_type.parameters["k"].in_units("kJ/mol").value,
@@ -558,8 +558,7 @@ def _write_improper_information(mcf, top):
558558
improper_style = "harmonic"
559559
for i, improper in enumerate(top.impropers):
560560
mcf.write(
561-
"{:<4d} {:<4d} {:<4d} {:<4d} {:<4d}"
562-
" {:s} {:10.5f} {:10.5f}\n".format(
561+
"{:<4d} {:<4d} {:<4d} {:<4d} {:<4d} {:s} {:10.5f} {:10.5f}\n".format(
563562
i + 1,
564563
top.get_index(improper.connection_members[0]) + 1,
565564
top.get_index(improper.connection_members[1]) + 1,

gmso/formats/top.py

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,10 @@ def write_top(top, filename, top_vars=None):
5858
)
5959
)
6060
out_file.write(
61-
"[ defaults ]\n"
62-
"; nbfunc\t"
63-
"comb-rule\t"
64-
"gen-pairs\t"
65-
"fudgeLJ\t\t"
66-
"fudgeQQ\n"
61+
"[ defaults ]\n; nbfunc\tcomb-rule\tgen-pairs\tfudgeLJ\t\tfudgeQQ\n"
6762
)
6863
out_file.write(
69-
"{0}\t\t" "{1}\t\t" "{2}\t\t" "{3}\t\t" "{4}\n\n".format(
64+
"{0}\t\t{1}\t\t{2}\t\t{3}\t\t{4}\n\n".format(
7065
top_vars["nbfunc"],
7166
top_vars["comb-rule"],
7267
top_vars["gen-pairs"],
@@ -76,25 +71,12 @@ def write_top(top, filename, top_vars=None):
7671
)
7772

7873
out_file.write(
79-
"[ atomtypes ]\n"
80-
"; name\t"
81-
"at.num\t\t"
82-
"mass\t"
83-
"charge\t\t"
84-
"ptype\t"
85-
"sigma\t"
86-
"epsilon\n"
74+
"[ atomtypes ]\n; name\tat.num\t\tmass\tcharge\t\tptype\tsigma\tepsilon\n"
8775
)
8876

8977
for atom_type in top.atom_types(PotentialFilters.UNIQUE_NAME_CLASS):
9078
out_file.write(
91-
"{0:12s}"
92-
"{1:4s}"
93-
"{2:12.5f}"
94-
"{3:12.5f}\t"
95-
"{4:4s}"
96-
"{5:12.5f}"
97-
"{6:12.5f}\n".format(
79+
"{0:12s}{1:4s}{2:12.5f}{3:12.5f}\t{4:4s}{5:12.5f}{6:12.5f}\n".format(
9880
atom_type.name,
9981
str(_lookup_atomic_number(atom_type)),
10082
atom_type.mass.in_units(u.amu).value,
@@ -115,7 +97,7 @@ def write_top(top, filename, top_vars=None):
11597
"bond_restraints": "\n[ bonds ] ;Harmonic potential restraint\n"
11698
"; ai\taj\tfunct\tb0\t\tkb\n",
11799
"pairs": "\n[ pairs ]\n; ai\taj\tfunct\n",
118-
"angles": "\n[ angles ]\n" "; ai\taj\tak\tfunct\tphi_0\t\tk0\n",
100+
"angles": "\n[ angles ]\n; ai\taj\tak\tfunct\tphi_0\t\tk0\n",
119101
"angle_restraints": (
120102
"\n[ angle_restraints ]\n"
121103
"; ai\taj\tai\tak\tfunct\ttheta_eq\tk\tmultiplicity\n"
@@ -132,14 +114,14 @@ def write_top(top, filename, top_vars=None):
132114
}
133115
for tag in unique_molecules:
134116
"""Write out nrexcl for each unique molecule."""
135-
out_file.write("\n[ moleculetype ]\n" "; name\tnrexcl\n")
117+
out_file.write("\n[ moleculetype ]\n; name\tnrexcl\n")
136118

137119
# TODO: Lookup and join nrexcl from each molecule object
138-
out_file.write("{0}\t" "{1}\n\n".format(tag, top_vars["nrexcl"]))
120+
out_file.write("{0}\t{1}\n\n".format(tag, top_vars["nrexcl"]))
139121

140122
"""Write out atoms for each unique molecule."""
141123
out_file.write(
142-
"[ atoms ]\n" "; nr\ttype\tresnr\tresidue\t\tatom\tcgnr\tcharge\tmass\n"
124+
"[ atoms ]\n; nr\ttype\tresnr\tresidue\t\tatom\tcgnr\tcharge\tmass\n"
143125
)
144126
# Each unique molecule need to be reindexed (restarting from 0)
145127
# The shifted_idx_map is needed to make sure all the atom index used in
@@ -148,14 +130,7 @@ def write_top(top, filename, top_vars=None):
148130
for idx, site in enumerate(unique_molecules[tag]["sites"]):
149131
shifted_idx_map[top.get_index(site)] = idx
150132
out_file.write(
151-
"{0:8s}"
152-
"{1:12s}"
153-
"{2:8s}"
154-
"{3:12s}"
155-
"{4:8s}"
156-
"{5:4s}"
157-
"{6:12.5f}"
158-
"{7:12.5f}\n".format(
133+
"{0:8s}{1:12s}{2:8s}{3:12s}{4:8s}{5:4s}{6:12.5f}{7:12.5f}\n".format(
159134
str(idx + 1),
160135
site.atom_type.name,
161136
str(site.molecule.number + 1 if site.molecule else 1),
@@ -302,9 +277,9 @@ def write_top(top, filename, top_vars=None):
302277
)
303278
)
304279

305-
out_file.write("\n[ system ]\n" "; name\n" "{0}\n\n".format(top.name))
280+
out_file.write("\n[ system ]\n; name\n{0}\n\n".format(top.name))
306281

307-
out_file.write("[ molecules ]\n" "; molecule\tnmols\n")
282+
out_file.write("[ molecules ]\n; molecule\tnmols\n")
308283
for tag in unique_molecules:
309284
out_file.write(
310285
"{0}\t{1}\n".format(tag, len(unique_molecules[tag]["subtags"]))

gmso/lib/potential_templates.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
def _verify_potential_template_keys(_dict, name):
2626
"""Verify the potential template is properly formatted."""
2727
assert "name" in _dict, f"Key name not found in the potential template {name}.json"
28-
assert (
29-
"expression" in _dict
30-
), f"Key expression not found in the potential template {name}.json"
31-
assert (
32-
"independent_variables" in _dict
33-
), f"Key independent_variables not found in the potential template {name}.json"
28+
assert "expression" in _dict, (
29+
f"Key expression not found in the potential template {name}.json"
30+
)
31+
assert "independent_variables" in _dict, (
32+
f"Key independent_variables not found in the potential template {name}.json"
33+
)
3434
if str(name) != _dict["name"]:
35-
raise GMSOError(f'Mismatch between Potential name {name} and {_dict["name"]}')
35+
raise GMSOError(f"Mismatch between Potential name {name} and {_dict['name']}")
3636

3737

3838
def _load_template_json(item, json_dir=JSON_DIR):

0 commit comments

Comments
 (0)