From 7fa3c0de1a972aa6e954183c3404651b6d74d0b9 Mon Sep 17 00:00:00 2001 From: "Matthew W. Thompson" Date: Thu, 23 Jan 2025 11:03:01 -0600 Subject: [PATCH] DOC: Update experimental tag on examples, tests --- .github/workflows/examples.yaml | 1 - docs/using/experimental.md | 2 -- .../openmm-import/.gitignore | 0 .../openmm-import/README.md | 0 .../openmm-import/protein-ligand.ipynb | 0 .../unit_tests/components/test_interchange.py | 4 +-- .../interop/openmm/_import/test_compat.py | 12 ++----- .../interop/openmm/_import/test_import.py | 33 ++++--------------- .../unit_tests/operations/test_combine.py | 18 ++-------- 9 files changed, 14 insertions(+), 56 deletions(-) rename examples/{experimental => }/openmm-import/.gitignore (100%) rename examples/{experimental => }/openmm-import/README.md (100%) rename examples/{experimental => }/openmm-import/protein-ligand.ipynb (100%) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index d0f634b1d..c5c993d59 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -30,7 +30,6 @@ jobs: env: OE_LICENSE: ${{ github.workspace }}/oe_license.txt - INTERCHANGE_EXPERIMENTAL: "1" steps: - uses: actions/checkout@v4 diff --git a/docs/using/experimental.md b/docs/using/experimental.md index 773968e9c..a6df3161d 100644 --- a/docs/using/experimental.md +++ b/docs/using/experimental.md @@ -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 diff --git a/examples/experimental/openmm-import/.gitignore b/examples/openmm-import/.gitignore similarity index 100% rename from examples/experimental/openmm-import/.gitignore rename to examples/openmm-import/.gitignore diff --git a/examples/experimental/openmm-import/README.md b/examples/openmm-import/README.md similarity index 100% rename from examples/experimental/openmm-import/README.md rename to examples/openmm-import/README.md diff --git a/examples/experimental/openmm-import/protein-ligand.ipynb b/examples/openmm-import/protein-ligand.ipynb similarity index 100% rename from examples/experimental/openmm-import/protein-ligand.ipynb rename to examples/openmm-import/protein-ligand.ipynb diff --git a/openff/interchange/_tests/unit_tests/components/test_interchange.py b/openff/interchange/_tests/unit_tests/components/test_interchange.py index be14964bc..fb97fa7cb 100644 --- a/openff/interchange/_tests/unit_tests/components/test_interchange.py +++ b/openff/interchange/_tests/unit_tests/components/test_interchange.py @@ -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 diff --git a/openff/interchange/_tests/unit_tests/interop/openmm/_import/test_compat.py b/openff/interchange/_tests/unit_tests/interop/openmm/_import/test_compat.py index c4958c4b5..6dfd1f860 100644 --- a/openff/interchange/_tests/unit_tests/interop/openmm/_import/test_compat.py +++ b/openff/interchange/_tests/unit_tests/interop/openmm/_import/test_compat.py @@ -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") @@ -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") @@ -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") diff --git a/openff/interchange/_tests/unit_tests/interop/openmm/_import/test_import.py b/openff/interchange/_tests/unit_tests/interop/openmm/_import/test_import.py index 4350f4d5e..b5ae26162 100644 --- a/openff/interchange/_tests/unit_tests/interop/openmm/_import/test_import.py +++ b/openff/interchange/_tests/unit_tests/interop/openmm/_import/test_import.py @@ -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( @@ -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: @@ -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) @@ -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") @@ -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", @@ -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") @@ -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() @@ -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( @@ -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) diff --git a/openff/interchange/_tests/unit_tests/operations/test_combine.py b/openff/interchange/_tests/unit_tests/operations/test_combine.py index 98cf27a00..def233b44 100644 --- a/openff/interchange/_tests/unit_tests/operations/test_combine.py +++ b/openff/interchange/_tests/unit_tests/operations/test_combine.py @@ -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]) @@ -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") @@ -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") @@ -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 @@ -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