Skip to content

Commit

Permalink
[thermo] fix docstrings of estimate (markovmodel#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
marscher authored Jul 2, 2016
1 parent 740eed1 commit 04685c6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 38 deletions.
42 changes: 23 additions & 19 deletions pyemma/thermo/estimators/DTRAM_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ class DTRAM(_Estimator, _MEMM, _ProgressReporter):
"""
def __init__(
self, bias_energies_full, lag, count_mode='sliding', connectivity='largest',
maxiter=10000, maxerr=1.0E-15, save_convergence_info=0, dt_traj='1 step',
init=None, init_maxiter=10000, init_maxerr=1.0E-8):
self, bias_energies_full, lag, count_mode='sliding', connectivity='largest',
maxiter=10000, maxerr=1.0E-15, save_convergence_info=0, dt_traj='1 step',
init=None, init_maxiter=10000, init_maxerr=1.0E-8):
# set all parameters
self.bias_energies_full = _types.ensure_ndarray(bias_energies_full, ndim=2, kind='numeric')
self.lag = lag
Expand All @@ -142,21 +142,25 @@ def __init__(
self.conf_energies = None
self.log_lagrangian_mult = None

def _estimate(self, trajs):
def estimate(self, trajs):
"""
Parameters
----------
X : tuple of (ttrajs, dtrajs)
Simulation trajectories. ttrajs contain the indices of the thermodynamic state and
dtrajs contains the indices of the configurational states.
ttrajs : list of numpy.ndarray(X_i, dtype=int)
Every elements is a trajectory (time series). ttrajs[i][t] is the index of the
thermodynamic state visited in trajectory i at time step t.
dtrajs : list of numpy.ndarray(X_i, dtype=int)
dtrajs[i][t] is the index of the configurational state (Markov state) visited in
trajectory i at time step t.
ttrajs : list of numpy.ndarray(X_i, dtype=int)
Every elements is a trajectory (time series). ttrajs[i][t] is the index of the
thermodynamic state visited in trajectory i at time step t.
dtrajs : list of numpy.ndarray(X_i, dtype=int)
dtrajs[i][t] is the index of the configurational state (Markov state) visited in
trajectory i at time step t.
"""
return super(DTRAM, self).estimate(trajs)

def _estimate(self, trajs):
# check input
assert isinstance(trajs, (tuple, list))
assert len(trajs) == 2
Expand Down Expand Up @@ -207,14 +211,14 @@ def _estimate(self, trajs):

# run estimator
self.therm_energies, self.conf_energies, self.log_lagrangian_mult, \
self.increments, self.loglikelihoods = _dtram.estimate(
self.count_matrices, self.bias_energies,
maxiter=self.maxiter, maxerr=self.maxerr,
log_lagrangian_mult=self.log_lagrangian_mult,
conf_energies=self.conf_energies,
save_convergence_info=self.save_convergence_info,
callback=_ConvergenceProgressIndicatorCallBack(
self, 'DTRAM', self.maxiter, self.maxerr))
self.increments, self.loglikelihoods = _dtram.estimate(
self.count_matrices, self.bias_energies,
maxiter=self.maxiter, maxerr=self.maxerr,
log_lagrangian_mult=self.log_lagrangian_mult,
conf_energies=self.conf_energies,
save_convergence_info=self.save_convergence_info,
callback=_ConvergenceProgressIndicatorCallBack(
self, 'DTRAM', self.maxiter, self.maxerr))
self._progress_force_finish(stage='DTRAM', description='DTRAM')

# compute models
Expand Down Expand Up @@ -242,4 +246,4 @@ def log_likelihood(self):
self.bias_energies,
self.conf_energies,
self.count_matrices,
_np.zeros(shape=self.conf_energies.shape, dtype=_np.float64)))
_np.zeros(shape=self.conf_energies.shape, dtype=_np.float64)))
26 changes: 15 additions & 11 deletions pyemma/thermo/estimators/TRAM_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,28 @@ def __init__(
self.log_lagrangian_mult = None
self.loglikelihoods = None

def _estimate(self, X):
def estimate(self, X):
"""
Parameters
----------
X : tuple of (ttrajs, dtrajs, btrajs)
Simulation trajectories. ttrajs contain the indices of the thermodynamic state, dtrajs
contains the indices of the configurational states and btrajs contain the biases.
ttrajs : list of numpy.ndarray(X_i, dtype=int)
Every elements is a trajectory (time series). ttrajs[i][t] is the index of the
thermodynamic state visited in trajectory i at time step t.
dtrajs : list of numpy.ndarray(X_i, dtype=int)
dtrajs[i][t] is the index of the configurational state (Markov state) visited in
trajectory i at time step t.
btrajs : list of numpy.ndarray((X_i, T), dtype=numpy.float64)
For every simulation frame seen in trajectory i and time step t, btrajs[i][t,k] is the
bias energy of that frame evaluated in the k'th thermodynamic state (i.e. at the k'th
Umbrella/Hamiltonian/temperature).
ttrajs : list of numpy.ndarray(X_i, dtype=int)
Every elements is a trajectory (time series). ttrajs[i][t] is the index of the
thermodynamic state visited in trajectory i at time step t.
dtrajs : list of numpy.ndarray(X_i, dtype=int)
dtrajs[i][t] is the index of the configurational state (Markov state) visited in
trajectory i at time step t.
btrajs : list of numpy.ndarray((X_i, T), dtype=numpy.float64)
For every simulation frame seen in trajectory i and time step t, btrajs[i][t,k] is the
bias energy of that frame evaluated in the k'th thermodynamic state (i.e. at the k'th
Umbrella/Hamiltonian/temperature).
"""
return super(TRAM, self).estimate(trajs)

def _estimate(self, X):
ttrajs, dtrajs_full, btrajs = X
# shape and type checks
assert len(ttrajs) == len(dtrajs_full) == len(btrajs)
Expand Down
19 changes: 11 additions & 8 deletions pyemma/thermo/estimators/WHAM_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,24 @@ def __init__(
self.therm_energies = None
self.conf_energies = None

def _estimate(self, trajs):
# TODO: fix docstring
def estimate(self, trajs):
"""
Parameters
----------
X : tuple of (ttrajs, dtrajs)
Simulation trajectories. ttrajs contain the indices of the thermodynamic state and
dtrajs contains the indices of the configurational states.
ttrajs : list of numpy.ndarray(X_i, dtype=int)
Every elements is a trajectory (time series). ttrajs[i][t] is the index of the
thermodynamic state visited in trajectory i at time step t.
dtrajs : list of numpy.ndarray(X_i, dtype=int)
dtrajs[i][t] is the index of the configurational state (Markov state) visited in
trajectory i at time step t.
ttrajs : list of numpy.ndarray(X_i, dtype=int)
Every elements is a trajectory (time series). ttrajs[i][t] is the index of the
thermodynamic state visited in trajectory i at time step t.
dtrajs : list of numpy.ndarray(X_i, dtype=int)
dtrajs[i][t] is the index of the configurational state (Markov state) visited in
trajectory i at time step t.
"""
return super(WHAM, self).estimate(trajs)

def _estimate(self, trajs):
# check input
assert isinstance(trajs, (tuple, list))
assert len(trajs) == 2
Expand Down

0 comments on commit 04685c6

Please sign in to comment.