Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@shortcut('nstates')
def number_of_states(dtrajs, only_used=False):
r"""returns the number of states in the given trajectories.
Parameters
----------
dtraj : array_like or list of array_like
Discretized trajectory or list of discretized trajectories
only_used = False : boolean
If False, will return max+1, where max is the largest index used.
If True, will return the number of states that occur at least once.
"""
return _number_of_states(dtrajs, only_used=only_used)
@shortcut('save_dtraj')
def save_discrete_trajectory(filename, dtraj):
r"""Write discrete trajectory to binary file.
Parameters
----------
filename : str
The filename of the discrete state trajectory file.
The filename can either contain the full or the
relative path to the file.
dtraj : array-like of int
Discrete state trajectory
See also
--------
load_discrete_trajectory
@shortcut('dtrajs_active')
def discrete_trajectories_active(self):
"""
A list of integer arrays with the discrete trajectories mapped to the connectivity mode used.
For example, for connectivity='largest', the indexes will be given within the connected set.
Frames that are not in the connected set will be -1.
"""
self._check_is_estimated()
# compute connected dtrajs
self._dtrajs_active = []
for dtraj in self._dtrajs_full:
self._dtrajs_active.append(self._full2active[dtraj])
return self._dtrajs_active
@shortcut('connected_cmatrix')
def largest_connected_submatrix(C, directed=True, lcc=None):
r"""Compute the count matrix on the largest connected set.
Parameters
----------
C : scipy.sparse matrix
Count matrix specifying edge weights.
directed : bool, optional
Whether to compute connected components for a directed or
undirected graph. Default is True
lcc : (M,) ndarray, optional
The largest connected set
Returns
-------
C_cc : scipy.sparse matrix
@shortcut('dtrajs_obs')
def discrete_trajectories_obs(self):
"""
A list of integer arrays with the discrete trajectories mapped to the observation mode used.
When using observe_active = True, the indexes will be given on the MSM active set. Frames that are not in the
observation set will be -1. When observe_active = False, this attribute is identical to
discrete_trajectories_full
"""
return self._dtrajs_obs
@shortcut('dtrajs_full')
def discrete_trajectories_full(self):
"""
A list of integer arrays with the original (unmapped) discrete trajectories:
"""
self._check_is_estimated()
return self._dtrajs_full
@shortcut('read_dtraj')
def read_discrete_trajectory(filename):
"""Read discrete trajectory from ascii file.
The ascii file containing a single column with integer entries is
read into an array of integers.
Parameters
----------
filename : str
The filename of the discrete state trajectory file.
The filename can either contain the full or the
relative path to the file.
Returns
-------
dtraj : (M, ) ndarray
@shortcut('dtrajs_full')
def discrete_trajectories_full(self):
"""
A list of integer arrays with the original trajectories.
"""
return self._dtrajs_full
@shortcut('histogram')
def count_states(dtrajs):
r"""returns a histogram count
Parameters
----------
dtraj : array_like or list of array_like
Discretized trajectory or list of discretized trajectories
Returns
-------
count : ndarray((n), dtype=int)
the number of occurrances of each state. n=max+1 where max is the largest state index found.
"""
return _count_states(dtrajs)
@shortcut('read_dtraj')
def read_discrete_trajectory(filename):
r"""Read discrete trajectory from ascii file.
Parameters
----------
filename : str
The filename of the discretized trajectory file.
The filename can either contain the full or the
relative path to the file.
Returns
-------
dtraj : (M, ) ndarray of int
Discrete state trajectory.
See also