Skip to content

Commit

Permalink
unify unassigned frame assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
thempel committed Jul 1, 2019
1 parent cffa5eb commit 6018096
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions pyemma/msm/estimators/_dtraj_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from msmtools import estimation as msmest
from pyemma.util.annotators import alias, aliased
from pyemma.util.linalg import submatrix
from pyemma.util.discrete_trajectories import visited_set, rewrite_dtrajs_to_core_sets
from pyemma.util.discrete_trajectories import visited_set

__author__ = 'noe'

Expand Down Expand Up @@ -184,15 +184,11 @@ def count_lagged(self, lag, count_mode='sliding', mincount_connectivity='1/n',
# Compute count matrix
count_mode = count_mode.lower()
if core_set is not None and count_mode in ('sliding', 'sample'):

# set non-core states to -1
for d in self._dtrajs:
d[~np.in1d(d, core_set)] = -1

if milestoning_method == 'last_core':

# assign -1 frames to last visited core
for d in self._dtrajs:
assert d[0] != -1
while -1 in d:
mask = (d == -1)
d[mask] = d[np.roll(mask, -1)]
Expand Down
8 changes: 2 additions & 6 deletions pyemma/util/discrete_trajectories.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,12 @@ def rewrite_dtrajs_to_core_sets(dtrajs, core_set, in_place=False):
if not in_place:
dtrajs = copy.deepcopy(dtrajs)

# build a boolean expression to create a mask of indices within the core set.
expr = ['(d == {i})'.format(i=i) for i in core_set]
expr = '|'.join(expr)

# if we have no state definition at the beginning of a trajectory, we store the offset to the first milestone.
offsets = [0]*len(dtrajs)

for i, d in enumerate(dtrajs):
within_core_set = eval(expr)
outside_core_set = np.logical_not(within_core_set)
# set non-core states to -1
outside_core_set = ~np.in1d(d, core_set)
if not np.any(outside_core_set):
continue
d[outside_core_set] = -1
Expand Down

0 comments on commit 6018096

Please sign in to comment.