def test_count_3(self): S1 = np.array([0, 1, 2, 3, 4]) S2 = np.array([2, 2, 2, 2, 6]) H = np.array([1, 1, 5, 1, 1, 0, 1]) assert (dt.number_of_states([S1, S2]) == 7) assert (dt.number_of_states([S1, S2], only_used=True) == 6) assert (np.allclose(dt.count_states([S1, S2]), H))
def test_count_3(self): S1 = np.array([0, 1, 2, 3, 4]) S2 = np.array([2, 2, 2, 2, 6]) H = np.array([1, 1, 5, 1, 1, 0, 1]) assert(dt.number_of_states([S1,S2]) == 7) assert(dt.number_of_states([S1,S2], only_used=True) == 6) assert(np.allclose(dt.count_states([S1,S2]),H))
def __init__(self, dtrajs, lags=None, nits=10, connected=True, reversible=True, failfast=False): r"""Calculates the implied timescales for a series of lag times. Parameters ---------- dtrajs : array-like or list of array-likes discrete trajectories lags = None : array-like with integers integer lag times at which the implied timescales will be calculated k = 10 : int number of implied timescales to be computed. Will compute less if the number of states are smaller connected = True : boolean compute the connected set before transition matrix estimation at each lag separately reversible = True : boolean estimate the transition matrix reversibly (True) or nonreversibly (False) failfast = False : boolean if True, will raise an error as soon as not all requested timescales can be computed at all requested lagtimes. If False, will continue with a warning and compute the timescales/lagtimes that are possible. """ # initialize self._dtrajs = _ensure_dtraj_list(dtrajs) self._connected = connected self._reversible = reversible # maximum number of timescales nstates = number_of_states(self._dtrajs) self._nits = min(nits, nstates - 1) # trajectory lengths self.lengths = np.zeros(len(self._dtrajs)) for i in range(len(self._dtrajs)): self.lengths[i] = len(self._dtrajs[i]) self.maxlength = np.max(self.lengths) # lag time if (lags is None): maxlag = 0.5 * np.sum(self.lengths) / float(len(self.lengths)) self._lags = self._generate_lags(maxlag, 1.5) else: self._lags = np.array(lags) # check if some lag times are forbidden. if np.max(self._lags) >= self.maxlength: Ifit = np.where(self._lags < self.maxlength)[0] Inofit = np.where(self._lags >= self.maxlength)[0] warnings.warn( 'Some lag times exceed the longest trajectories. Will ignore lag times: ' + str(self._lags[Inofit])) self._lags = self._lags[Ifit] # estimate self._estimate()
def test_count_1(self): S = np.array([0, 0, 0, 0, 0, 0]) H = np.array([6]) assert (dt.number_of_states(S) == 1) assert (dt.number_of_states(S, only_used=True) == 1) assert (np.allclose(dt.count_states(S), H))
def test_count_big(self): import pyemma.datasets dtraj = pyemma.datasets.load_2well_discrete().dtraj_T100K_dt10 dt.number_of_states(dtraj) dt.count_states(dtraj)
def test_count_2(self): S = np.array([1, 1, 1, 1, 1, 1]) H = np.array([0,6]) assert(dt.number_of_states(S) == 2) assert(dt.number_of_states(S, only_used=True) == 1) assert(np.allclose(dt.count_states(S),H))
def test_count_big(self): dtraj = dt.read_discrete_trajectory(testpath+'2well_traj_100K.dat') # just run these to see if there's any exception dt.number_of_states(dtraj) dt.count_states(dtraj)