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
22 changes: 20 additions & 2 deletions paths_cli/tests/wizard/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,31 @@
import openpathsampling as paths
import mdtraj as md

# should be able to remove this try block when we drop OpenMM < 7.6
try:
import openmm as mm
from openmm import unit as u
except ImportError:
try:
from simtk import openmm as mm
from simtk import unit as u
except ImportError:
HAS_OPENMM = False
else: # -no-cov-
HAS_OPENMM = True
else:
HAS_OPENMM = True

@pytest.fixture
def ad_openmm(tmpdir):
"""
Provide directory with files to start alanine depeptide sim in OpenMM
"""
mm = pytest.importorskip('simtk.openmm')
u = pytest.importorskip('simtk.unit')
# switch back to importorskip when we drop OpenMM < 7.6
if not HAS_OPENMM:
pytest.skip("could not import openmm")
# mm = pytest.importorskip('simtk.openmm')
# u = pytest.importorskip('simtk.unit')
openmmtools = pytest.importorskip('openmmtools')
md = pytest.importorskip('mdtraj')
testsystem = openmmtools.testsystems.AlanineDipeptideVacuum()
Expand Down
18 changes: 17 additions & 1 deletion paths_cli/tests/wizard/test_openmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@
_load_openmm_xml, _load_topology, openmm, OPENMM_SERIALIZATION_URL
)

# should be able to remove this try block when we drop OpenMM < 7.6
try:
import openmm as mm
except ImportError:
try:
from simtk import openmm as mm
except ImportError:
HAS_OPENMM = False
else:
HAS_OPENMM = True # -no-cov-
else:
HAS_OPENMM = True

def test_helper_url():
assert_url(OPENMM_SERIALIZATION_URL)

@pytest.mark.parametrize('obj_type', ['system', 'integrator', 'foo'])
def test_load_openmm_xml(ad_openmm, obj_type):
mm = pytest.importorskip('simtk.openmm')
# switch back to importorskip when we drop OpenMM < 7.6
if not HAS_OPENMM:
pytest.skip("could not import openmm")
# mm = pytest.importorskip("simtk.openmm")
filename = f"{obj_type}.xml"
inputs = [filename]
expected_count = 1
Expand Down
14 changes: 10 additions & 4 deletions paths_cli/wizard/openmm.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
from paths_cli.wizard.errors import FILE_LOADING_ERROR_MSG, not_installed
from paths_cli.wizard.core import get_object

# should be able to simplify this try block when we drop OpenMM < 7.6
try:
from simtk import openmm as mm
import mdtraj as md
import openmm as mm
except ImportError:
HAS_OPENMM = False
try:
from simtk import openmm as mm
except ImportError:
HAS_OPENMM = False
else: # -no-cov-
HAS_OPENMM = True
else:
HAS_OPENMM = True

OPENMM_SERIALIZATION_URL=(
"http://docs.openmm.org/latest/api-python/generated/"
"simtk.openmm.openmm.XmlSerializer.html"
"openmm.openmm.XmlSerializer.html"
)

def _openmm_serialization_helper(wizard, user_input): # no-cov
Expand Down