Skip to content

Commit

Permalink
Linted files with black
Browse files Browse the repository at this point in the history
  • Loading branch information
jaketanderson committed Sep 7, 2024
1 parent 9ad2d31 commit 064b07c
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 54 deletions.
32 changes: 16 additions & 16 deletions paprika/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,11 +1272,11 @@ def compute_free_energy(self, phases=["attach", "pull", "release"], seed=None):
phase
][method]["fraction_fe_matrix"][fraction][0, -1]

self.results[phase][method]["fraction_sem"][
fraction
] = self.results[phase][method]["fraction_sem_matrix"][fraction][
0, -1
]
self.results[phase][method]["fraction_sem"][fraction] = (
self.results[phase][method]["fraction_sem_matrix"][fraction][
0, -1
]
)

# Set these higher level (total) values, which will be slightly
# easier to access
Expand All @@ -1298,23 +1298,23 @@ def compute_free_energy(self, phases=["attach", "pull", "release"], seed=None):
# Store convergence values, which are helpful for running
# simulations
windows = len(self.results[phase][method]["sem_matrix"])
self.results[phase][method][
"largest_neighbor"
] = openff_unit.Quantity(
np.ones([windows], np.float64) * -1.0,
units=self.energy_unit,
self.results[phase][method]["largest_neighbor"] = (
openff_unit.Quantity(
np.ones([windows], np.float64) * -1.0,
units=self.energy_unit,
)
)
logger.info(f"{phase}: computing largest_neighbor for {method}...")

for i in range(windows):
if i == 0:
self.results[phase][method]["largest_neighbor"][
i
] = self.results[phase][method]["sem_matrix"][i][i + 1]
self.results[phase][method]["largest_neighbor"][i] = (
self.results[phase][method]["sem_matrix"][i][i + 1]
)
elif i == windows - 1:
self.results[phase][method]["largest_neighbor"][
i
] = self.results[phase][method]["sem_matrix"][i][i - 1]
self.results[phase][method]["largest_neighbor"][i] = (
self.results[phase][method]["sem_matrix"][i][i - 1]
)
else:
left = self.results[phase][method]["sem_matrix"][i][i - 1]
right = self.results[phase][method]["sem_matrix"][i][i + 1]
Expand Down
7 changes: 2 additions & 5 deletions paprika/restraints/openmm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module aimed at applying restraints directly to OpenMM systems."""

import logging

import numpy as np
Expand Down Expand Up @@ -67,11 +68,7 @@ def apply_positional_restraints(
# But then we can't access atom indices. Using `atom.xx` works for
# coordinates, but is unitless.
if isinstance(k_pos, float):
k = (
k_pos
* openmm_unit.kilocalories_per_mole
/ openmm_unit.angstroms**2
)
k = k_pos * openmm_unit.kilocalories_per_mole / openmm_unit.angstroms**2
elif isinstance(k_pos, openmm_unit.Quantity):
k = k_pos
elif isinstance(k_pos, openff_unit.Quantity):
Expand Down
14 changes: 8 additions & 6 deletions paprika/restraints/restraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,9 @@ def initialize(self):
if phase[key] is not None:
phase[key] = check_unit(
phase[key],
base_unit=target_unit
if key == "target"
else force_constant_unit,
base_unit=(
target_unit if key == "target" else force_constant_unit
),
)

# Check pull units
Expand All @@ -637,9 +637,11 @@ def initialize(self):
if key in self._custom_restraint_values:
self._custom_restraint_values[key] = check_unit(
self._custom_restraint_values[key],
base_unit=force_constant_unit
if key in ["rk2", "rk3"]
else target_unit,
base_unit=(
force_constant_unit
if key in ["rk2", "rk3"]
else target_unit
),
)
else:
self._custom_restraint_values[key] = None
Expand Down
1 change: 1 addition & 0 deletions paprika/tests/test_evaluator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests evaluator modules.
"""

import logging
import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions paprika/tests/test_io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test that we can save and load restraints as JSON.
"""

import os
import shutil

Expand Down
37 changes: 10 additions & 27 deletions paprika/tests/test_restraints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests the restraints utilities.
"""

import logging
import os

Expand Down Expand Up @@ -134,9 +135,7 @@ def test_DAT_restraint():
rest2.initialize()

target_units = openff_unit.degrees
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
assert rest2.restraint_type == RestraintType.Angle
assert rest2.index1 == [13, 31, 49, 67, 85, 103]
assert rest2.index2 == [119]
Expand Down Expand Up @@ -205,9 +204,7 @@ def test_DAT_restraint():
rest3.initialize()

target_units = openff_unit.degrees
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
assert rest3.restraint_type == RestraintType.Torsion
assert rest3.index1 == [31]
assert rest3.index2 == [13]
Expand Down Expand Up @@ -278,9 +275,7 @@ def test_DAT_restraint():
rest4.initialize()

target_units = openff_unit.degrees
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
assert rest4.index1 == [31]
assert rest4.index2 == [13]
assert rest4.index3 == [119]
Expand Down Expand Up @@ -348,9 +343,7 @@ def test_DAT_restraint():
rest5.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest5.index1 == [13, 31, 49, 67, 85, 103]
assert rest5.index2 == [109, 113, 115, 119]
assert rest5.index3 is None
Expand Down Expand Up @@ -417,9 +410,7 @@ def test_DAT_restraint():
rest6.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest6.index1 == [13, 31, 49, 67, 85, 103]
assert rest6.index2 == [109, 113, 115, 119]
assert rest6.index3 is None
Expand Down Expand Up @@ -484,9 +475,7 @@ def test_DAT_restraint():
rest7.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest7.index1 == [13, 14, 111]
assert rest7.index2 == [3]
assert rest7.index3 is None
Expand Down Expand Up @@ -547,9 +536,7 @@ def test_DAT_restraint():
rest8.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest8.index1 == [13]
assert rest8.index2 == [119]
assert rest8.index3 is None
Expand Down Expand Up @@ -587,9 +574,7 @@ def test_DAT_restraint():
rest9.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest9.index1 == [13]
assert rest9.index2 == [119]
assert rest9.index3 is None
Expand Down Expand Up @@ -627,9 +612,7 @@ def test_DAT_restraint():
rest10.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest10.index1 == [13]
assert rest10.index2 == [119]
assert rest10.index3 is None
Expand Down
1 change: 1 addition & 0 deletions paprika/tests/test_tleap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests tleap tools.
"""

import logging
import os
import random as random
Expand Down

0 comments on commit 064b07c

Please sign in to comment.