Skip to content

Commit

Permalink
Skip tests that take WAYYYYY too long if openmm not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
avirshup committed Oct 15, 2016
1 parent 0af4a10 commit 20b97a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 2 additions & 1 deletion moldesign/_tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np

import moldesign as mdt
from moldesign import units as u
import numpy as np

DEFSTEP = 0.000005*u.angstrom

Expand Down
14 changes: 4 additions & 10 deletions moldesign/_tests/test_mm.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,19 @@ def test_properties(objkey, request):
assert forces.shape == mol.positions.shape


@pytest.mark.skipif(mdt.interfaces.openmm.force_remote,
reason="Numerical derivatives need to be parallelized, "
"otherwise this takes too long")
@pytest.mark.parametrize('objkey', registered_types['mdready'])
def test_forces(objkey, request):
mol = request.getfuncargvalue(objkey)

if mol.num_atoms > 20:
atoms = random.sample(mol.atoms, 20)
else:
atoms = mol.atoms

anagrad = -mol.calculate_forces().defunits_value()
numgrad = helpers.num_grad(mol,
mol.calculate_potential_energy,
atoms=atoms,
step=0.005*u.angstrom
).defunits_value()
testgrad = np.array([anagrad[a.index] for a in atoms])
np.testing.assert_allclose(testgrad, numgrad, rtol=1.0, atol=1.0e-5)
# note: rtol doesn't work here, because the force varies too slowly in some directions and
# too quickly in others. So we just use an absolute error cutoff instead
assert np.sqrt(np.sum((anagrad-numgrad) ** 2))/(3.0*mol.num_atoms) <= 1.0e-4 # this isn't good


@pytest.mark.parametrize('objkey', registered_types['mdready'])
Expand Down

0 comments on commit 20b97a8

Please sign in to comment.