Skip to content

Commit 313681b

Browse files
committed
Pre-commit hooks
1 parent 9cfcd2f commit 313681b

File tree

6 files changed

+60
-58
lines changed

6 files changed

+60
-58
lines changed

src/fes_ml/alchemical/alchemical_state.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@ def check_integrity(self):
4949
Alchemical state to check.
5050
"""
5151
assert isinstance(self.system, _mm.System), "System is not an OpenMM System."
52-
assert isinstance(self.integrator, _mm.Integrator), (
53-
"Integrator is not an OpenMM Integrator."
54-
)
55-
assert isinstance(self.context, _mm.Context), (
56-
"Context is not an OpenMM Context."
57-
)
58-
assert isinstance(self.simulation, _app.Simulation), (
59-
"Simulation is not an OpenMM Simulation."
60-
)
61-
assert isinstance(self.topology, _mm.app.Topology), (
62-
"Topology is not an OpenMM Topology."
63-
)
64-
assert isinstance(self.modifications, dict), (
65-
"Modifications is not a dictionary."
66-
)
52+
assert isinstance(
53+
self.integrator, _mm.Integrator
54+
), "Integrator is not an OpenMM Integrator."
55+
assert isinstance(
56+
self.context, _mm.Context
57+
), "Context is not an OpenMM Context."
58+
assert isinstance(
59+
self.simulation, _app.Simulation
60+
), "Simulation is not an OpenMM Simulation."
61+
assert isinstance(
62+
self.topology, _mm.app.Topology
63+
), "Topology is not an OpenMM Topology."
64+
assert isinstance(
65+
self.modifications, dict
66+
), "Modifications is not a dictionary."

src/fes_ml/alchemical/modifications/emle_potential.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ def apply(
117117
cv_force = [
118118
f for f in system.getForces() if f.getName() == "MLInterpolation"
119119
]
120-
assert len(cv_force) == 1, (
121-
f"There are {len(cv_force)} MLInterpolation forces. Only one is allowed."
122-
)
120+
assert (
121+
len(cv_force) == 1
122+
), f"There are {len(cv_force)} MLInterpolation forces. Only one is allowed."
123123

124124
cv_force = cv_force[0]
125-
assert isinstance(cv_force, _mm.CustomCVForce), (
126-
f"Expected a CustomCVForce, but got {type(cv_force)}."
127-
)
125+
assert isinstance(
126+
cv_force, _mm.CustomCVForce
127+
), f"Expected a CustomCVForce, but got {type(cv_force)}."
128128

129129
for i in range(cv_force.getNumGlobalParameters()):
130130
if cv_force.getGlobalParameterName(i) == "lambda_interpolate":

src/fes_ml/alchemical/strategies/openff_strategy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@ def _get_alchemical_atoms(
373373
)
374374

375375
else:
376-
assert isinstance(alchemical_atoms, list), (
377-
"Alchemical_atoms must be a list of int."
378-
)
376+
assert isinstance(
377+
alchemical_atoms, list
378+
), "Alchemical_atoms must be a list of int."
379379

380380
logger.debug(f"Alchemical atoms: {alchemical_atoms}")
381381
return alchemical_atoms
@@ -749,9 +749,9 @@ def create_alchemical_state(
749749
if integrator is None:
750750
integrator = self._create_integrator(temperature, friction, timestep)
751751
else:
752-
assert isinstance(integrator, _mm.Integrator), (
753-
"integrator must be an OpenMM Integrator."
754-
)
752+
assert isinstance(
753+
integrator, _mm.Integrator
754+
), "integrator must be an OpenMM Integrator."
755755
integrator = _deepcopy(integrator)
756756

757757
# Create the simulation

src/fes_ml/fes.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def __setstate__(
134134
)
135135

136136
for alc in self.alchemical_states:
137-
assert isinstance(alc, AlchemicalState), (
138-
"alchemical_state must be an AlchemicalState object."
139-
)
137+
assert isinstance(
138+
alc, AlchemicalState
139+
), "alchemical_state must be an AlchemicalState object."
140140
alc.check_integrity()
141141
alc.context.setPositions(self._positions)
142142
alc.context.setPeriodicBoxVectors(*self._pbc)
@@ -297,9 +297,9 @@ def _minimize_state(
297297
else:
298298
alchemical_state = self.alchemical_states[window]
299299

300-
assert isinstance(alchemical_state, AlchemicalState), (
301-
"alchemical_state must be an AlchemicalState object."
302-
)
300+
assert isinstance(
301+
alchemical_state, AlchemicalState
302+
), "alchemical_state must be an AlchemicalState object."
303303
alchemical_state.check_integrity()
304304

305305
logger.info(
@@ -343,9 +343,9 @@ def minimize(
343343
"""
344344
if window is None and alchemical_state is None:
345345
# Attempt batch minimization
346-
assert self.alchemical_states is not None, (
347-
"The alchemical states have not been created. Run `create_alchemical_states` first."
348-
)
346+
assert (
347+
self.alchemical_states is not None
348+
), "The alchemical states have not been created. Run `create_alchemical_states` first."
349349

350350
for alc in self.alchemical_states:
351351
self._minimize_state(tolerance, max_iterations, alc, reporter=reporter)
@@ -388,9 +388,9 @@ def _equilibrate_state(
388388
else:
389389
alchemical_state = self.alchemical_states[window]
390390

391-
assert isinstance(alchemical_state, AlchemicalState), (
392-
"alchemical_state must be an AlchemicalState object."
393-
)
391+
assert isinstance(
392+
alchemical_state, AlchemicalState
393+
), "alchemical_state must be an AlchemicalState object."
394394
alchemical_state.check_integrity()
395395

396396
# Append reporters to the simulation
@@ -431,9 +431,9 @@ def equilibrate(
431431
"""
432432
if window is None and alchemical_state is None:
433433
# Attempt batch equilibration
434-
assert self.alchemical_states is not None, (
435-
"The alchemical states have not been created. Run `create_alchemical_states` first."
436-
)
434+
assert (
435+
self.alchemical_states is not None
436+
), "The alchemical states have not been created. Run `create_alchemical_states` first."
437437

438438
for alc in self.alchemical_states:
439439
self._equilibrate_state(nsteps, alc, reporters=reporters)
@@ -480,9 +480,9 @@ def run_single_state(
480480
alchemical_state = self.alchemical_states[window]
481481

482482
# Check the integrity of the alchemical state
483-
assert isinstance(alchemical_state, AlchemicalState), (
484-
"alchemical_state must be an AlchemicalState object."
485-
)
483+
assert isinstance(
484+
alchemical_state, AlchemicalState
485+
), "alchemical_state must be an AlchemicalState object."
486486
alchemical_state.check_integrity()
487487

488488
if not self._U_kl:
@@ -562,9 +562,9 @@ def run_production_batch(
562562
u_kln : np.ndarray
563563
Array with the potential energies of the simulations.
564564
"""
565-
assert self.alchemical_states is not None, (
566-
"The alchemical states have not been created. Run `create_alchemical_states` first."
567-
)
565+
assert (
566+
self.alchemical_states is not None
567+
), "The alchemical states have not been created. Run `create_alchemical_states` first."
568568

569569
# Resume from the last checkpoint
570570
if not self._U_kln:

src/fes_ml/log.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def log_banner() -> None:
2323
║ version: {} ║
2424
║ ║
2525
╚══════════════════════════════════════════════════════╝
26-
""".format(__version__)
26+
""".format(
27+
__version__
28+
)
2729

2830
lines = banner.split("\n")
2931

src/fes_ml/mts.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,19 @@ def set_force_groups(
109109
- If a group is not provided, all forces are set to the fastest force group.
110110
"""
111111
if alchemical_states is not None:
112-
assert isinstance(alchemical_states, list), (
113-
"alchemical_states must be a list."
114-
)
112+
assert isinstance(
113+
alchemical_states, list
114+
), "alchemical_states must be a list."
115115
for alc in alchemical_states:
116-
assert isinstance(alc, AlchemicalState), (
117-
"All elements in alchemical_states must be AlchemicalState."
118-
)
116+
assert isinstance(
117+
alc, AlchemicalState
118+
), "All elements in alchemical_states must be AlchemicalState."
119119
alc.check_integrity()
120120
self.alchemical_states = alchemical_states
121121
else:
122-
assert self.alchemical_states is not None, (
123-
"alchemical_states must be provided to set the force groups."
124-
)
122+
assert (
123+
self.alchemical_states is not None
124+
), "alchemical_states must be provided to set the force groups."
125125

126126
if force_group_dict is not None:
127127
# get the fastest force group for the unassigned forces

0 commit comments

Comments
 (0)