From 5e24b3ab29690c5de21d9272dfe2231268f4eef7 Mon Sep 17 00:00:00 2001 From: John Detlefs Date: Mon, 6 Jun 2016 13:21:44 -0700 Subject: [PATCH] Constant epsilon tests --- .../analysis/test_diffusionmap.py | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/testsuite/MDAnalysisTests/analysis/test_diffusionmap.py b/testsuite/MDAnalysisTests/analysis/test_diffusionmap.py index 821405eee0f..f4a4943e9a2 100644 --- a/testsuite/MDAnalysisTests/analysis/test_diffusionmap.py +++ b/testsuite/MDAnalysisTests/analysis/test_diffusionmap.py @@ -17,7 +17,7 @@ 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 @@ -25,15 +25,15 @@ 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() @@ -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) @@ -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)