Ejemplo n.º 1
0
 def test_iterator(self):
     c = self.ass
     for itraj, chunk in c:
         assert types.is_int(itraj)
         assert types.is_int_matrix(chunk)
         assert chunk.shape[0] <= c.chunksize or c.chunksize == 0
         assert chunk.shape[1] == c.dimension()
Ejemplo n.º 2
0
 def test_iterator(self):
     for c in self.cl:
         for itraj, chunk in c:
             assert types.is_int(itraj)
             assert types.is_int_matrix(chunk)
             assert chunk.shape[0] <= c.chunksize
             assert chunk.shape[1] == c.dimension()
Ejemplo n.º 3
0
 def test_get_output(self):
     c = self.ass
     O = c.get_output()
     assert types.is_list(O)
     assert len(O) == 1
     assert types.is_int_matrix(O[0])
     assert O[0].shape[0] == self.T
     assert O[0].shape[1] == 1
Ejemplo n.º 4
0
 def test_get_output(self):
     for c in self.cl:
         O = c.get_output()
         assert types.is_list(O)
         assert len(O) == 1
         assert types.is_int_matrix(O[0])
         assert O[0].shape[0] == self.T
         assert O[0].shape[1] == 1
Ejemplo n.º 5
0
def _apply_offsets_to_samples(indices, offsets):
    r""" This private function applies the given offsets returned by the milestone_counting function to
    the results of the sample_indexes_by_* functions.

    This is necessary in order to obtain the right order in the input files.

    Notes
    -----
    Operates in place.

    Parameters
    ----------
    indices :  list of ndarray( (N, 2) )
        trajectory and corresponding frame indices of original input
    offsets: dict {itraj, offset}

    """
    from pyemma.util import types
    assert types.is_int_matrix(indices)
    assert isinstance(offsets, list), offsets

    # 1. restore itraj indices (the mapping is relative to the original oder)
    last_valid = None
    n_missing = 0
    for itraj, offset in enumerate(offsets):
        if offset is None:  # this itraj is missing
            n_missing += 1
        else:
            if n_missing > 0:
                # shift subsequent indices by n_missing
                indices[indices[:, 0] > last_valid, 0] += n_missing
            last_valid = itraj
            n_missing = 0

    # 2. restore frame indices (relative to org order)
    for itraj, offset in enumerate(offsets):
        if offset is None:
            continue
        indices[indices[:, 0] == itraj, 1] += offset