Skip to content

Commit

Permalink
Assorted updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Mar 14, 2024
1 parent a30adc3 commit 0e5e784
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 45 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

defaults:
run:
shell: bash -l {0}
shell: bash -leo pipefail {0} {0}

jobs:
test:
Expand All @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest]
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -37,23 +37,20 @@ jobs:
python=${{ matrix.python-version }}
- name: Install Package
run: |
python -m pip install -e .
run: python -m pip install -e .

- name: Run Tests
run: |
pytest -v -nauto --cov=smirnoff_plugins --cov-report=xml --color=yes smirnoff_plugins/_tests/
run: pytest smirnoff_plugins/_tests/ \
-v -n logical \
--cov=smirnoff_plugins --cov-report=xml --color=yes

- name: Run Example
if: ${{ false }}
shell: bash -l {0}
run: |
python examples/buckingham-water.py
run: python examples/buckingham-water.py

- name: Run mypy
continue-on-error: true
run: |
mypy smirnoff_plugins/
run: mypy smirnoff_plugins/

- name: CodeCov
uses: codecov/codecov-action@v4
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ ci:
autoupdate_schedule: "quarterly"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: debug-statements
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 24.2.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
7 changes: 3 additions & 4 deletions devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: smirnoff-plugins-test
channels:
- jaimergp/label/unsupported-cudatoolkit-shim
- conda-forge

dependencies:
Expand All @@ -10,8 +9,8 @@ dependencies:
# Core dependencies
- numpy
- openmm
- openff-toolkit >=0.14.3
- openff-interchange >=0.3.18
- openff-toolkit =0.15
- openff-interchange
- openff-utilities
- openff-models

Expand All @@ -21,4 +20,4 @@ dependencies:
- pytest-xdist
- pytest-randomly

- mypy =1.2
- mypy
6 changes: 5 additions & 1 deletion examples/buckingham-water.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This script provides an example of how to construct a force field for a four site
water model which uses a custom Buckingham potential to describe the non-bonded vdW
interactions."""

import math

import numpy
Expand Down Expand Up @@ -107,7 +108,10 @@ def main():
positions = openmm.unit.Quantity(
numpy.vstack(
[
(molecule.conformers[0].m_as(unit.angstrom) + numpy.array([[x, y, z]]) * 2.5)
(
molecule.conformers[0].m_as(unit.angstrom)
+ numpy.array([[x, y, z]]) * 2.5
)
for x in range(math.ceil(n_molecules ** (1 / 3)))
for y in range(math.ceil(n_molecules ** (1 / 3)))
for z in range(math.ceil(n_molecules ** (1 / 3)))
Expand Down
6 changes: 0 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ warn_unused_configs = True
warn_unused_ignores = True
warn_incomplete_stub = True
show_error_codes = True
# https://github.com/pydantic/pydantic/issues/5192
disable_error_code = call-arg


[mypy-openff.toolkit.*]
ignore_missing_imports = True
Expand All @@ -58,8 +55,5 @@ ignore_missing_imports = True
[mypy-openmm.app]
ignore_missing_imports = True

[mypy-openmm.app.element]
ignore_missing_imports = True

[mypy-openmm.unit]
ignore_missing_imports = True
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
smirnoff-plugins
Custom parameter handlers for extending SMIRNOFF force fields.
"""

import sys

from setuptools import find_packages, setup
Expand Down
5 changes: 2 additions & 3 deletions smirnoff_plugins/_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import numpy
import pytest
from openff.toolkit.topology import Molecule, Topology
from openff.toolkit.typing.engines.smirnoff import ForceField, ParameterList
from openff.units import unit
from openff.toolkit import ForceField, Molecule, Topology, unit
from openff.toolkit.typing.engines.smirnoff.parameters import ParameterList


@pytest.fixture()
Expand Down
11 changes: 5 additions & 6 deletions smirnoff_plugins/_tests/handlers/test_nonbonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
import openmm.unit
import pytest
from openff.interchange import Interchange
from openff.toolkit import Topology
from openff.toolkit.topology import Molecule
from openff.toolkit.typing.engines.smirnoff import ForceField
from openff.units import unit
from openff.toolkit import ForceField, Molecule, Topology, unit
from openff.units.openmm import from_openmm, to_openmm
from openff.utilities import get_data_file_path

from smirnoff_plugins.utilities.openmm import (
evaluate_energy,
evaluate_water_energy_at_distances,
Expand Down Expand Up @@ -429,7 +427,8 @@ def mock_modify_openmm_forces(

de = ForceField(
get_data_file_path("_tests/data/de-force-1.0.1.offxml", "smirnoff_plugins"),
load_plugins=True)
load_plugins=True,
)

combined_energies = get_openmm_energies(
interchange=de.create_interchange(ligand.to_topology()),
Expand Down Expand Up @@ -764,7 +763,7 @@ def test_multipole_energies():
{"smirks": "[#10:1]", "polarity": "1 * angstrom**3"}
)

hf = Molecule.from_smiles("[F:1][H:2]")
hf = Molecule.from_mapped_smiles("[F:1][H:2]")
hf.generate_conformers(n_conformers=1)
off_top = hf.to_topology()
neon = Molecule.from_smiles("[Ne]")
Expand Down
11 changes: 5 additions & 6 deletions smirnoff_plugins/collections/nonbonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
_SMIRNOFFNonbondedCollection,
)
from openff.models.types import FloatQuantity
from openff.toolkit import Topology
from openff.toolkit import Quantity, Topology, unit
from openff.toolkit.topology import Atom
from openff.toolkit.typing.engines.smirnoff.parameters import ParameterHandler
from openff.units import Quantity, unit
from openmm import CustomManyParticleForce, openmm

from smirnoff_plugins.handlers.nonbonded import (
Expand Down Expand Up @@ -363,10 +362,10 @@ class SMIRNOFFDampedExp6810Collection(_NonbondedPlugin):
"rho = 0.5*(rho1+rho2);"
)

force_at_zero: FloatQuantity[
"kilojoules_per_mole * nanometer**-1" # noqa
] = unit.Quantity(
49.6144931952, unit.kilojoules_per_mole * unit.nanometer**-1 # noqa
force_at_zero: FloatQuantity["kilojoules_per_mole * nanometer**-1"] = ( # noqa
unit.Quantity(
49.6144931952, unit.kilojoules_per_mole * unit.nanometer**-1 # noqa
)
)

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions smirnoff_plugins/handlers/nonbonded.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import abc

from openff.toolkit import unit
from openff.toolkit.typing.engines.smirnoff.parameters import (
ElectrostaticsHandler,
IncompatibleParameterError,
LibraryChargeHandler,
ParameterAttribute,
ParameterHandler,
Expand All @@ -11,8 +13,6 @@
_allow_only,
vdWHandler,
)
from openff.toolkit.utils.exceptions import IncompatibleParameterError
from openff.units import unit


class _CustomNonbondedHandler(ParameterHandler, abc.ABC):
Expand Down
3 changes: 1 addition & 2 deletions smirnoff_plugins/utilities/openmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
import openmm.unit
from openff.interchange import Interchange
from openff.interchange.interop.openmm._positions import to_openmm_positions
from openff.toolkit import ForceField, Molecule, Topology
from openff.units import unit
from openff.toolkit import ForceField, Molecule, Topology, unit
from openff.units.openmm import ensure_quantity
from openff.utilities import temporary_cd

Expand Down

0 comments on commit 0e5e784

Please sign in to comment.