def test_4_2(self): t4 = timescales(self.P4)[1] lags = [int(t4)] its = msm.timescales_msm([self.dtraj4_2], lags=lags) est = its.timescales[0] np.testing.assert_array_less(est, t4 + 20.0) np.testing.assert_array_less(t4 - 20.0, est)
def test_2(self): t2 = timescales(self.P2)[1] lags = [1, 2, 3, 4, 5] its = msm.timescales_msm([self.dtraj2], lags=lags) est = its.timescales[0] np.testing.assert_array_less(est, t2 + 2.0) np.testing.assert_array_less(t2 - 2.0, est)
def compute_nice(self, reversible): """ Tests if standard its estimates run without errors :return: """ for i in range(len(self.dtrajs)): its = msm.timescales_msm(self.dtrajs[i], reversible=reversible)
def test_too_large_lagtime(self): dtraj = [[0, 1, 1, 1, 0]] lags = [1, 2, 3, 4, 5, 6, 7, 8] expected_lags = [1, 2] # 3, 4 is impossible because no finite timescales. import warnings with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") its = msm.timescales_msm(dtraj, lags=lags, reversible=False) # FIXME: we do not trigger a UserWarning, but msmtools.exceptions.SpectralWarning, intended? #assert issubclass(w[-1].category, UserWarning) np.testing.assert_equal(its.lags, expected_lags)
def test_its_msm(self): estimator = msm.timescales_msm( [self.double_well_data.dtraj_T100K_dt10_n6good], lags=[1, 10, 100, 1000], n_jobs=2) ref = np.array([ [174.22244263, 3.98335928, 1.61419816, 1.1214093, 0.87692952], [285.56862305, 6.66532284, 3.05283223, 2.6525504, 1.9138432], [325.35442195, 24.17388446, 20.52185604, 20.10058217, 17.35451648], [ 343.53679359, 255.92796581, 196.26969348, 195.56163418, 170.58422303 ] ]) # rough agreement with MLE assert np.allclose(estimator.timescales, ref, rtol=0.1, atol=10.0)
def test_fraction_of_frames(self): dtrajs = [ [0, 1, 0], # These two will fail for lag >2 [1, 0, 1], # These two will fail for lag >2 [0, 1, 1, 1], [1, 0, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], ] lengths = [len(traj) for traj in dtrajs] lags = [1, 2, 3] its = msm.timescales_msm(dtrajs, lags=lags) all_frames = np.sum(lengths) longer_than_3 = np.sum(lengths[2:]) test_frac = longer_than_3 / all_frames assert np.allclose(its.fraction_of_frames, np.array([1, 1, test_frac]))
def test_timescales(self): from pyerna.msm import timescales_msm its = timescales_msm(self.dtraj, lags=[1, 2], mincount_connectivity=0, errors=None) assert its.estimator.mincount_connectivity == 0
def test_lag_generation(self): its = msm.timescales_msm(self.dtraj4_2, lags=1000) np.testing.assert_array_equal(its.lags, [ 1, 2, 3, 5, 8, 12, 18, 27, 41, 62, 93, 140, 210, 315, 473, 710, 1000 ])