Skip to content

Commit

Permalink
Constant epsilon tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jdetle committed Jun 6, 2016
1 parent c3f5564 commit 5e24b3a
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions testsuite/MDAnalysisTests/analysis/test_diffusionmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
import numpy as np
import MDAnalysis
import MDAnalysis.analysis.diffusionmap as diffusionmap
from numpy.testing import (assert_almost_equal, assert_equal)
from numpy.testing import (assert_almost_equal, assert_equal, raises)


from MDAnalysisTests.datafiles import PDB, XTC


class TestDiffusionmap(object):
def __init__(self):
#slow 6s test
#u = MDAnalysis.Universe(PSF,DCD)
#eg,ev=diffusionmap.diffusionmap(u)
#assert_equal(self.eg.shape, (98,))
#assert_almost_equal(self.eg[0], 1.0)
#assert_almost_equal(self.eg[-1],0.03174182)
#assert_equal(self.ev.shape, (98,98))
#assert_almost_equal(self.ev[0,0], .095836037343022831)
#faster
# slow 6s test
# u = MDAnalysis.Universe(PSF,DCD)
# eg,ev=diffusionmap.diffusionmap(u)
# assert_equal(self.eg.shape, (98,))
# assert_almost_equal(self.eg[0], 1.0)
# assert_almost_equal(self.eg[-1],0.03174182)
# assert_equal(self.ev.shape, (98,98))
# assert_almost_equal(self.ev[0,0], .095836037343022831)
# faster
self.u = MDAnalysis.Universe(PDB, XTC)
self.dmap = diffusionmap.DiffusionMap(self.u, select='backbone', k=5)
self.dmap.run()
Expand All @@ -42,7 +42,7 @@ def __init__(self):
self.weights = np.ones((self.dmap.nframes, ))

def test_eg(self):
#number of frames is trajectory is now 10?
# number of frames is trajectory is now 10 vs. 98
assert_equal(self.eigvals.shape, (self.dmap.nframes, ))
assert_almost_equal(self.eigvals[0], 1.0, decimal=5)
assert_almost_equal(self.eigvals[-1], 0.0142, decimal=3)
Expand All @@ -57,3 +57,17 @@ def test_weights(self):
dmap2.run()
assert_almost_equal(self.eigvals, dmap2.eigenvalues, decimal=5)
assert_almost_equal(self.eigvects, dmap2.eigenvectors, decimal=6)
assert_raised

@raises(ValueError)
def test_wrong_weights(self):
dmap2 = diffusionmap.DiffusionMap(self.u, select='backbone',
weights=np.ones((2,)),
k=5)

def test_constant_epsilon(self):
dmap3 = diffusionmap.DiffusionMap(self.u, select='backbone', k=5,
epsilon=4.62827648)
dmap3.run()
assert_almost_equal(self.eigvals, dmap3.eigenvalues, decimal=5)
assert_almost_equal(self.eigvects, dmap3.eigenvectors, decimal=5)

0 comments on commit 5e24b3a

Please sign in to comment.