Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 18 additions & 2 deletions paths_cli/tests/wizard/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,29 @@
import openpathsampling as paths
import mdtraj as md

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')
if not HAS_OPENMM:
pytest.skip()
Comment thread
sroet marked this conversation as resolved.
Resolved
# mm = pytest.importorskip('simtk.openmm')
# u = pytest.importorskip('simtk.unit')
Comment thread
sroet marked this conversation as resolved.
Resolved
openmmtools = pytest.importorskip('openmmtools')
md = pytest.importorskip('mdtraj')
testsystem = openmmtools.testsystems.AlanineDipeptideVacuum()
Expand Down
16 changes: 15 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,26 @@
_load_openmm_xml, _load_topology, openmm, OPENMM_SERIALIZATION_URL
)

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')
if not HAS_OPENMM:
pytest.skip()
Comment thread
sroet marked this conversation as resolved.
Resolved
# mm = pytest.importorskip("simtk.openmm")
Comment thread
sroet marked this conversation as resolved.
Resolved
filename = f"{obj_type}.xml"
inputs = [filename]
expected_count = 1
Expand Down
12 changes: 8 additions & 4 deletions paths_cli/wizard/openmm.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from paths_cli.wizard.errors import FILE_LOADING_ERROR_MSG, not_installed
from paths_cli.wizard.core import get_object
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