Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
hooks:
- id: add-trailing-comma
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.5
rev: v0.16.7
hooks:
- id: ruff-check
args: ["--fix"]
Expand All @@ -28,11 +28,11 @@ repos:
- id: nbstripout
files: ^examples
- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.29.2
rev: v2.29.4
hooks:
- id: pyproject-fmt
- repo: https://github.com/tombi-toml/tombi-pre-commit
rev: v1.5.0
rev: v1.5.5
hooks:
- id: tombi-format
args: ["--offline"]
Expand Down
32 changes: 15 additions & 17 deletions openff/interchange/_tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@
from openff.interchange.warnings import PresetChargesAndVirtualSitesWarning


def test_issue_723():
def test_issue_723(sage):
parmed = pytest.importorskip("parmed")
force_field = ForceField("openff-2.1.0.offxml")

molecule = Molecule.from_smiles("C#N")
molecule.generate_conformers(n_conformers=1)

force_field.create_interchange(molecule.to_topology()).to_top("_x.top")
sage.create_interchange(
MoleculeWithConformer.from_smiles("C#N").to_topology(),
).to_top("_x.top")

parmed.load_file("_x.top")


@pytest.mark.skipif(not has_executable("packmol"), reason="Packmol is not installed")
@pytest.mark.parametrize("pack", [True, False])
def test_issue_1022(pack):
def test_issue_1022(sage, pack):
topology = Topology.from_molecules(
[
MoleculeWithConformer.from_smiles(smi)
Expand All @@ -54,11 +52,12 @@ def test_issue_1022(pack):
box_vectors=topology.box_vectors,
)

force_field = ForceField(
"openff-2.0.0.offxml",
get_data_file_path(
"example-sigma-hole-bromine.offxml",
"openff.interchange._tests.data",
force_field = sage.combine(
ForceField(
get_data_file_path(
"example-sigma-hole-bromine.offxml",
"openff.interchange._tests.data",
),
),
)

Expand Down Expand Up @@ -116,7 +115,7 @@ def test_issue_1031():
assert atom_name in openff_atom_names


def test_issue_1049():
def test_issue_1049(sage):
pytest.importorskip("openmm")

topology = Topology.from_molecules(
Expand All @@ -127,7 +126,7 @@ def test_issue_1049():
],
)

interchange = ForceField("openff-2.2.0.offxml", "opc.offxml").create_interchange(topology)
interchange = sage.combine(ForceField("opc.offxml")).create_interchange(topology)

openmm_topology = interchange.to_openmm_topology()
openmm_system = interchange.to_openmm_system()
Expand Down Expand Up @@ -387,7 +386,7 @@ def test_issue_1234_openmm(sage, valence_handler):
assert abs(original_energy - new_energy) > 0.1


def test_clear_caches_with_dead_weakref_proxy():
def test_clear_caches_with_dead_weakref_proxy(sage):
"""Reproduce a bug where _clear_caches raises ReferenceError when dead
weakref proxies exist in gc.get_objects(). See
https://github.com/openforcefield/openff-interchange/issues/1453
Expand All @@ -406,10 +405,9 @@ class _Dummy:
gc.collect()

molecule = MoleculeWithConformer.from_smiles("C")
force_field = ForceField("openff-2.2.0.offxml")

# This raised ReferenceError before the fix
Interchange.from_smirnoff(force_field=force_field, topology=[molecule])
sage.create_interchange(molecule.to_topology())


def test_issue_1461(sage, opc, ethanol):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"c1ccc2ccccc2c1",
],
)
def test_atom_names_with_padding(molecule):
def test_atom_names_with_padding(sage, molecule):
# pytest processes fixtures before the decorator can be applied

parmed = pytest.importorskip("parmed")
Expand All @@ -46,10 +46,7 @@ def test_atom_names_with_padding(molecule):
molecule = Molecule.from_smiles(molecule)

# Unclear if the toolkit will always load PDBs with padded whitespace in name
Interchange.from_smirnoff(
ForceField("openff-2.0.0.offxml"),
molecule.to_topology(),
).to_prmtop("tmp.prmtop")
sage.create_interchange(molecule.to_topology()).to_prmtop("tmp.prmtop")

# Loading with ParmEd striggers #679 if exclusions lists are wrong
parmed.load_file("tmp.prmtop")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ def test_combine_twice(self, sage, methane, ethanol, water_dimer):
ic2["Electrostatics"].get_charge_array(),
ic3["Electrostatics"].get_charge_array(),
],
),
ic4["Electrostatics"].get_charge_array(),
).m,
ic4["Electrostatics"].get_charge_array().m,
)

def test_combine_from_openmm_add_nagl_to_openmm(self, sage, ethanol):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def test_nagl_charges_precedence_over_am1bcc(self, sage, hexane_diol):
assigned_charges = interchange["Electrostatics"].get_charge_array()

# Should match NAGL charges, not AM1BCC
numpy.testing.assert_allclose(assigned_charges, nagl_charges)
numpy.testing.assert_allclose(assigned_charges.m, nagl_charges)

def test_library_charges_precedence_over_nagl(self, sage, methane):
"""Test that LibraryCharges takes precedence over NAGLCharges."""
Expand All @@ -391,7 +391,7 @@ def test_library_charges_precedence_over_nagl(self, sage, methane):

# Should match library charges
expected_charges = [-0.2, 0.05, 0.05, 0.05, 0.05]
numpy.testing.assert_allclose(assigned_charges, expected_charges)
numpy.testing.assert_allclose(assigned_charges.m, expected_charges)

def test_nagl_charges_precedence_over_charge_increments(self, sage, hexane_diol):
"""Test that NAGLCharges takes precedence over ChargeIncrementModel as base charges."""
Expand All @@ -411,7 +411,7 @@ def test_nagl_charges_precedence_over_charge_increments(self, sage, hexane_diol)
assigned_charges = interchange["Electrostatics"].get_charge_array()

# Should match NAGL charges, not formal charges
numpy.testing.assert_allclose(assigned_charges, nagl_charges)
numpy.testing.assert_allclose(assigned_charges.m, nagl_charges)


@skip_if_missing("openff.nagl")
Expand Down Expand Up @@ -512,7 +512,7 @@ def test_nagl_charges_identical_molecules_same_charges(self):
mol2_charges = assigned_charges[molecule1.n_atoms :]

# Should be identical
numpy.testing.assert_allclose(mol1_charges, mol2_charges)
numpy.testing.assert_allclose(mol1_charges.m, mol2_charges.m)

def test_nagl_charges_with_charge_from_molecules(self, sage, hexane_diol):
"""Test that charge_from_molecules takes precedence over NAGLCharges."""
Expand Down
2 changes: 1 addition & 1 deletion openff/interchange/_tests/unit_tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class M(_BaseModel):
assert str(box.units) == "nanometer"
assert box.shape == (3, 3)

numpy.testing.assert_allclose(box, box * numpy.eye(3))
numpy.testing.assert_allclose(box.m, (box * numpy.eye(3)).m)

def test_ndarray_to_nanometer_quantity_array(self):
class M(_BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions openff/interchange/components/interchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Interchange(_BaseModel):
Create an ``Interchange`` from an OpenFF ``ForceField`` and ``Molecule``

>>> from openff.toolkit import ForceField, Molecule
>>> sage = ForceField("openff-2.2.0.offxml")
>>> sage = ForceField("openff-2.3.0.offxml")
>>> top = Molecule.from_smiles("CCC").to_topology()
>>> interchange = sage.create_interchange(top)

Expand Down Expand Up @@ -156,7 +156,7 @@ def from_smirnoff(
>>> from openff.toolkit import ForceField, Molecule
>>> mol = Molecule.from_smiles("CC")
>>> mol.generate_conformers(n_conformers=1)
>>> sage = ForceField("openff-2.0.0.offxml")
>>> sage = ForceField("openff-2.3.0.offxml")
>>> interchange = sage.create_interchange(mol.to_topology())
>>> interchange
Interchange with 7 collections, non-periodic topology with 8 atoms.
Expand Down
Loading