@@ -0,0 +1,1488 @@
+from __future__ import print_function%0Aimport numpy as np%0Aimport scipy.linalg%0Afrom scipy.linalg import eigvals%0Afrom scipy.optimize import approx_fprime%0Afrom msmbuilder.cluster import NDGrid%0Afrom msmbuilder.example_datasets import load_doublewell%0Afrom msmbuilder.msm import MarkovStateModel, ContinuousTimeMSM%0Afrom msmbuilder.msm.core import _solve_msm_eigensystem%0A%0A%0Adef test_0():%0A    random = np.random.RandomState(0)%0A    h = 1e-7%0A    X = %5B%5B1, 1, 1, 1, 0, 0, 0, 0, 0, 2,2,2,2,2,1, 1, 1, 1 ,1, 0, 0, 0, 0, 1, 1, 1, 1, 1%5D%5D%0A    model = MarkovStateModel().fit(X)%0A    n = model.n_states_%0A%0A    u, lv, rv = _solve_msm_eigensystem(model.transmat_, n)%0A%0A    for k in range(n):%0A        dLambda_dP_numeric = np.zeros((n, n))%0A        for i in range(n):%0A            for j in range(n):%0A                H = np.zeros((n, n))%0A                H%5Bi, j%5D = h%0A                w = -np.sort(-eigvals(model.transmat_ + H))%0A                dLambda_dP_numeric%5Bi, j%5D = (w%5Bk%5D - model.eigenvalues_%5Bk%5D) / h%0A%0A%0A        dLambda_dP_numeric%0A        analytic = np.outer(lv%5B:, k%5D, rv%5B:, k%5D)%0A        np.testing.assert_almost_equal(dLambda_dP_numeric, analytic)%0A%0Adef test_1():%0A    X = load_doublewell(random_state=0)%5B'trajectories'%5D%0A    for i in range(10):%0A        Y = NDGrid(n_bins_per_feature=10).fit_transform(%5BX%5Bi%5D%5D)%0A        model = MarkovStateModel(verbose=False).fit(Y)%0A        model2 = ContinuousTimeMSM().fit(Y)%0A%0A        print(model.uncertainty_timescales())%0A        print(model2.uncertainty_timescales())%0A        print()%0A%0A

add test