Skip to content

Commit

Permalink
added tests, fixed logger issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jdetle committed May 30, 2016
1 parent f1dd6e2 commit 0671f02
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion package/MDAnalysis/analysis/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ def rotation_matrix(a, b, weights=None):

rot = np.zeros(9, dtype=np.float64)
rmsd = qcp.CalcRMSDRotationalMatrix(a.T, b.T, N, rot, weights)
logger.info("qcp: %d", rmsd)
return np.matrix(rot.reshape(3, 3)), rmsd


Expand Down
3 changes: 1 addition & 2 deletions package/MDAnalysis/analysis/diffusionmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,14 @@ def _prepare(self):
self.rot = np.zeros(9)

def _single_frame(self):
logger.info("_ts.frame {0}, numframes{1}".format(self._ts.frame, self.nframes))
traj_index = self._ts.frame
i_ref = np.copy(self.u.trajectory[traj_index].positions-self.atoms.center_of_mass())

#diagonal entries need not be calculated due to metric(x,x) == 0 in theory
for j in range(self.nframes-1, self._ts.frame-1, -1):
j_ref = np.copy(self.u.trajectory[j].positions-self.atoms.center_of_mass())
self.rmsd_matrix[traj_index, j] = self.metric(i_ref.T.astype(np.float64),\
j_ref.T.astype(np.float64), self.natoms, self.rot, self.weights)
j_ref.T.astype(np.float64), self.natoms, self.rot, None)

def _conclude(self):
self.rmsd_matrix = self.rmsd_matrix + self.rmsd_matrix.T - \
Expand Down
17 changes: 9 additions & 8 deletions testsuite/MDAnalysisTests/analysis/test_diffusionmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,21 @@ def __init__(self):
#assert_almost_equal(self.ev[0,0], .095836037343022831)
#faster
u = MDAnalysis.Universe(PDB, XTC)
eg, ev = diffusionmap.diffusionmap(u, select = 'backbone', k = 5)
self.eg = eg
self.ev = ev
dmap = diffusionmap.DiffusionMap(u, select='backbone', k = 5)
dmap.run()
self.eigvals = dmap.eigenvalues
self.eigvects = dmap.eigenvectors


def test_eg(self):
assert_equal(self.eg.shape, (10, ))
assert_almost_equal(self.eg[0], 1.0, decimal=5)
assert_almost_equal(self.eg[-1], 0.0142, decimal = 3)
assert_equal(self.eigvals.shape, (10, ))
assert_almost_equal(self.eigvals[0], 1.0, decimal=5)
assert_almost_equal(self.eigvals[-1], 0.0142, decimal = 3)


def test_ev(self):
assert_equal(self.ev.shape, (10, 10))
assert_almost_equal(self.ev[0, 0], -0.3019, decimal = 2)
assert_equal(self.eigvects.shape, (10, 10))
assert_almost_equal(self.eigvects[0, 0], -0.3019, decimal = 2)



0 comments on commit 0671f02

Please sign in to comment.