Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update experimental tag on examples, tests #1150

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .github/workflows/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:

env:
OE_LICENSE: ${{ github.workspace }}/oe_license.txt
INTERCHANGE_EXPERIMENTAL: "1"

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 0 additions & 2 deletions docs/using/experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ In order to facilitate testing these features, though, they are included in the
See each function's docstring for more detailed information.

* `Interchange.from_gromacs`: Import data from GROMACS files.
* `Interchange.from_openmm`: Import data from OpenMM objects.
* `Interchange.__add__`: Combine two `Interchange` objects (this is called under the hood when using the `+` operator with two `Interchange` objects).

## Using experimental features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,7 @@ def test_from_gromacs_error(self):
Interchange.from_gromacs()

@skip_if_missing("openmm")
def test_from_openmm_called(self, monkeypatch, simple_interchange):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

def test_from_openmm_called(self, simple_interchange):
topology = simple_interchange.to_openmm_topology()
system = simple_interchange.to_openmm()
positions = simple_interchange.positions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

class TestUnsupportedCases:
@pytest.mark.filterwarnings("ignore:.*are you sure you don't want to pass positions")
def test_error_topology_mismatch(self, monkeypatch, sage_unconstrained, ethanol):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

def test_error_topology_mismatch(self, sage_unconstrained, ethanol):
topology = ethanol.to_topology()
topology.box_vectors = Quantity([4, 4, 4], "nanometer")

Expand All @@ -37,9 +35,7 @@ def test_error_topology_mismatch(self, monkeypatch, sage_unconstrained, ethanol)
topology=other_topology.to_openmm(),
)

def test_found_virtual_sites(self, monkeypatch, tip4p, water):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

def test_found_virtual_sites(self, tip4p, water):
topology = water.to_topology()
topology.box_vectors = Quantity([4, 4, 4], "nanometer")

Expand All @@ -54,9 +50,7 @@ def test_found_virtual_sites(self, monkeypatch, tip4p, water):
topology=topology.to_openmm(),
)

def test_missing_positions_warning(self, monkeypatch, sage, water):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

def test_missing_positions_warning(self, sage, water):
topology = water.to_topology()
topology.box_vectors = Quantity([4, 4, 4], "nanometer")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

@skip_if_missing("openmm")
class TestFromOpenMM:
def test_simple_roundtrip(self, monkeypatch, sage_unconstrained, ethanol):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

def test_simple_roundtrip(self, sage_unconstrained, ethanol):
ethanol.generate_conformers(n_conformers=1)

interchange = Interchange.from_smirnoff(
Expand Down Expand Up @@ -70,12 +68,9 @@ def simple_system(self):
@pytest.mark.parametrize("as_argument", [False, True])
def test_different_ways_to_process_box_vectors(
self,
monkeypatch,
as_argument,
simple_system,
):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

topology = Molecule.from_smiles("C").to_topology()

if as_argument:
Expand All @@ -97,12 +92,9 @@ def test_different_ways_to_process_box_vectors(

def test_topology_and_system_box_vectors_differ(
self,
monkeypatch,
simple_system,
):
"""Ensure that, if box vectors specified in the topology and system differ, those in the topology are used."""
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

topology = Molecule.from_smiles("C").to_topology()
topology.box_vectors = Quantity([4, 5, 6], unit.nanometer)

Expand All @@ -113,9 +105,7 @@ def test_topology_and_system_box_vectors_differ(

assert numpy.diag(box.m_as(unit.nanometer)) == pytest.approx([4, 5, 6])

def test_openmm_roundtrip_metadata(self, monkeypatch, sage):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

def test_openmm_roundtrip_metadata(self, sage):
# Make an example OpenMM Topology with metadata.
# Here we use OFFTK to make the OpenMM Topology, but this could just as easily come from another source
ethanol = Molecule.from_smiles("CCO")
Expand Down Expand Up @@ -156,12 +146,10 @@ def test_openmm_roundtrip_metadata(self, monkeypatch, sage):
assert atom.metadata["residue_name"] == "BNZ"

@pytest.mark.slow
def test_openmm_native_roundtrip_metadata(self, monkeypatch, sage):
def test_openmm_native_roundtrip_metadata(self, sage):
"""
Test that metadata is the same whether we load a PDB through OpenMM+Interchange vs. Topology.from_pdb.
"""
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

pdb = openmm.app.PDBFile(
get_data_file_path(
"ALA_GLY/ALA_GLY.pdb",
Expand All @@ -185,15 +173,13 @@ def test_openmm_native_roundtrip_metadata(self, monkeypatch, sage):
del off_atom_metadata["match_info"]
assert roundtrip_atom.metadata == off_atom_metadata

def test_electrostatics_cutoff_not_ignored(self, monkeypatch, ethanol):
def test_electrostatics_cutoff_not_ignored(self, ethanol):
pytest.importorskip("openmmforcefields")

import openmm.app
import openmm.unit
from openmmforcefields.generators import GAFFTemplateGenerator

monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

topology = ethanol.to_topology()
topology.box_vectors = Quantity([4, 4, 4], "nanometer")

Expand All @@ -219,13 +205,11 @@ def test_electrostatics_cutoff_not_ignored(self, monkeypatch, ethanol):
assert interchange["vdW"].cutoff.m_as(unit.nanometer) == pytest.approx(1.2345)

@needs_gmx
def test_fill_in_rigid_water_parameters(self, water_dimer, monkeypatch):
def test_fill_in_rigid_water_parameters(self, water_dimer):
import openmm.app

from openff.interchange.drivers import get_gromacs_energies

monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

openmm_force_field = openmm.app.ForceField("tip3p.xml")
openmm_topology = water_dimer.to_openmm()

Expand Down Expand Up @@ -280,9 +264,7 @@ def test_only_constrained_water(self, water_dimer):

@skip_if_missing("openmm")
class TestProcessTopology:
def test_with_openff_topology(self, monkeypatch, sage, basic_top):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

def test_with_openff_topology(self, sage, basic_top):
system = sage.create_openmm_system(basic_top)

with_openff = Interchange.from_openmm(
Expand Down Expand Up @@ -360,9 +342,8 @@ def test_parse_switching_distance_unused(self):

@skip_if_missing("openmm")
class TestConvertConstraints:
def test_num_constraints(self, monkeypatch, sage, basic_top):
def test_num_constraints(self, sage, basic_top):
"""Test that the number of constraints is preserved when converting to and from OpenMM"""
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

interchange = sage.create_interchange(basic_top)

Expand Down
18 changes: 3 additions & 15 deletions openff/interchange/_tests/unit_tests/operations/test_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@

class TestCombine:
@skip_if_missing("openmm")
def test_basic_combination(self, monkeypatch, sage_unconstrained):
def test_basic_combination(self, sage_unconstrained):
"""Test basic use of Interchange.__add__() based on the README example"""
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

mol = Molecule.from_smiles("C")
mol.generate_conformers(n_conformers=1)
top = Topology.from_molecules([mol])
Expand All @@ -40,9 +38,7 @@ def test_basic_combination(self, monkeypatch, sage_unconstrained):

@pytest.mark.filterwarnings("ignore:Setting positions to None")
@pytest.mark.slow
def test_parameters_do_not_clash(self, monkeypatch, sage_unconstrained):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

def test_parameters_do_not_clash(self, sage_unconstrained):
thf = Molecule.from_smiles("C1CCOC1")
ace = Molecule.from_smiles("CC(=O)O")

Expand Down Expand Up @@ -71,12 +67,10 @@ def make_interchange(molecule: Molecule) -> Interchange:

# TODO: Ensure the de-duplication is maintained after exports

def test_positions_setting(self, monkeypatch, sage):
def test_positions_setting(self, sage):
"""Test that positions exist on the result if and only if
both input objects have positions."""

monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

ethane = Molecule.from_smiles("CC")
methane = Molecule.from_smiles("C")

Expand All @@ -98,13 +92,10 @@ def test_positions_setting(self, monkeypatch, sage):
@pytest.mark.parametrize("handler", ["Electrostatics", "vdW"])
def test_error_mismatched_cutoffs(
self,
monkeypatch,
sage,
basic_top,
handler,
):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

sage_modified = ForceField("openff-2.1.0.offxml")

sage_modified[handler].cutoff *= 1.5
Expand All @@ -119,12 +110,9 @@ def test_error_mismatched_cutoffs(

def test_error_mismatched_switching_function(
self,
monkeypatch,
sage,
basic_top,
):
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", "1")

sage_modified = ForceField("openff-2.1.0.offxml")

sage_modified["vdW"].switch_width *= 0.0
Expand Down
Loading