{"action":"created","issue":{"url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/956","repository_url":"https://api.github.com/repos/markovmodel/PyEMMA","labels_url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/956/labels{/name}","comments_url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/956/comments","events_url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/956/events","html_url":"https://github.com/markovmodel/PyEMMA/issues/956","id":182317539,"number":956,"title":"[coor/save_traj] fragmented trajectory reader","user":{"login":"gph82","id":7518004,"avatar_url":"https://avatars.githubusercontent.com/u/7518004?v=3","gravatar_id":"","url":"https://api.github.com/users/gph82","html_url":"https://github.com/gph82","followers_url":"https://api.github.com/users/gph82/followers","following_url":"https://api.github.com/users/gph82/following{/other_user}","gists_url":"https://api.github.com/users/gph82/gists{/gist_id}","starred_url":"https://api.github.com/users/gph82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gph82/subscriptions","organizations_url":"https://api.github.com/users/gph82/orgs","repos_url":"https://api.github.com/users/gph82/repos","events_url":"https://api.github.com/users/gph82/events{/privacy}","received_events_url":"https://api.github.com/users/gph82/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/markovmodel/PyEMMA/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-11T16:54:36Z","updated_at":"2016-10-13T13:36:14Z","closed_at":"2016-10-13T13:36:14Z","body":"Hi everyone. \r\nsave_traj is extensively tested, also with the fragmented trajectory reader:\r\n https://github.com/markovmodel/PyEMMA/blob/1bd334b11478f07883d6d071a8de652063f0a849/pyemma/coordinates/tests/test_save_traj.py \r\nBut I am getting this behavior where save_traj fails for frame indices larger than the fragment size, which is 10000 in this case:\r\nAnyone has a clue of what is exactly going on here? I'm pinging @marscher, @clonker because it seems the error is happening in __init_stride...Thanks a lot. \r\n```python\r\nsrc_fragmented.n_frames_total()\r\n# 20000\r\nsrc_fragmented.number_of_trajectories()\r\n# 1\r\n\r\npyemma.coordinates.save_traj(src_fragmented, [[0,9999]], None)\r\n<mdtraj.Trajectory with 1 frames, 504 atoms, 28 residues, and unitcells at 0x7f60f4b95e80>\r\n\r\npyemma.coordinates.save_traj(src_fragmented, [[0,10000]], None)\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-178-5901a8c6f695> in <module>()\r\n----> 1 pyemma.coordinates.save_traj(src_fragmented, [[0,10000]], None)\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/api.py in save_traj(traj_inp, indexes, outfile, top, stride, chunksize, image_molecules, verbose)\r\n    660                          % (len(trajfiles), indexes[:,0].max()))\r\n    661 \r\n--> 662     traj = frames_from_files(trajfiles, top, indexes, chunksize, stride, reader=reader)\r\n    663 \r\n    664     # Avoid broken molecules\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/util/frames_from_file.py in frames_from_files(files, top, frames, chunksize, stride, verbose, copy_not_join, reader)\r\n    125     collected_frames = []\r\n    126     with it:\r\n--> 127         for x in it:\r\n    128             collected_frames.append(x)\r\n    129 \r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/_base/datasource.py in __next__(self)\r\n    606 \r\n    607     def __next__(self):\r\n--> 608         return self.next()\r\n    609 \r\n    610     def _use_cols(self, X):\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/_base/datasource.py in next(self)\r\n    643 \r\n    644     def next(self):\r\n--> 645         X = self._it_next()\r\n    646         while X is not None and (\r\n    647                 (not self.return_traj_index and len(X) == 0) or (self.return_traj_index and len(X[1]) == 0)\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/_base/datasource.py in _it_next(self)\r\n    623         self.state.pos = self.state.pos_adv\r\n    624         try:\r\n--> 625             X = self._use_cols(self._next_chunk())\r\n    626         except StopIteration:\r\n    627             self._last_chunk_in_traj = True\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/fragmented_trajectory_reader.py in _next_chunk(self)\r\n    285                 raise StopIteration()\r\n    286 \r\n--> 287         X = next(self._it, None)\r\n    288         if X is None:\r\n    289             raise StopIteration()\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/fragmented_trajectory_reader.py in __next__(self)\r\n     80                     self._fragment_indices = self.__get_ra_index_indices()\r\n     81                     self._reader_it = self._readers[self._reader_at].iterator(\r\n---> 82                         self.__get_ifrag_ra_indices(self._fragment_indices, 0), return_trajindex=False\r\n     83                     )\r\n     84                 else:\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/_base/iterable.py in iterator(self, stride, lag, chunk, return_trajindex, cols, skip)\r\n    144         chunk = chunk if chunk is not None else self.default_chunksize\r\n    145         it = self._create_iterator(skip=skip, chunk=chunk, stride=stride,\r\n--> 146                                    return_trajindex=return_trajindex, cols=cols)\r\n    147         if lag > 0:\r\n    148             it.return_traj_index = True\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/feature_reader.py in _create_iterator(self, skip, chunk, stride, return_trajindex, cols)\r\n    137     def _create_iterator(self, skip=0, chunk=0, stride=1, return_trajindex=True, cols=None):\r\n    138         return FeatureReaderIterator(self, skip=skip, chunk=chunk, stride=stride,\r\n--> 139                                      return_trajindex=return_trajindex, cols=cols)\r\n    140 \r\n    141     def describe(self):\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/feature_reader.py in __init__(self, data_source, skip, chunk, stride, return_trajindex, cols)\r\n    303                 data_source, skip=skip, chunk=chunk, stride=stride,\r\n    304                 return_trajindex=return_trajindex,\r\n--> 305                 cols=cols\r\n    306         )\r\n    307         #self._cols = cols\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/_base/datasource.py in __init__(self, data_source, skip, chunk, stride, return_trajindex, cols)\r\n    308                                    ntraj=self.number_of_trajectories(),\r\n    309                                    cols=cols)\r\n--> 310         self.__init_stride(stride)\r\n    311         self._pos = 0\r\n    312         self._last_chunk_in_traj = False\r\n\r\n/home/mi/gph82/programs/PyEmma/pyemma/coordinates/data/_base/datasource.py in __init_stride(self, stride)\r\n    318             self.state.stride[:, 1] += self.state.skip\r\n    319             keys = stride[:, 0]\r\n--> 320             if keys.max() >= self.number_of_trajectories():\r\n    321                 raise ValueError(\"provided too large trajectory index in stride argument (given max index: %s, \"\r\n    322                                  \"allowed: %s)\" % (keys.max(), self.number_of_trajectories() - 1))\r\n\r\n/home/mi/gph82/miniconda3/lib/python3.4/site-packages/numpy/core/_methods.py in _amax(a, axis, out, keepdims)\r\n     24 # small reductions\r\n     25 def _amax(a, axis=None, out=None, keepdims=False):\r\n---> 26     return umr_maximum(a, axis, None, out, keepdims)\r\n     27 \r\n     28 def _amin(a, axis=None, out=None, keepdims=False):\r\n\r\nValueError: zero-size array to reduction operation maximum which has no identity\r\n` ` ` "},"comment":{"url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/comments/253514712","html_url":"https://github.com/markovmodel/PyEMMA/issues/956#issuecomment-253514712","issue_url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/956","id":253514712,"user":{"login":"gph82","id":7518004,"avatar_url":"https://avatars.githubusercontent.com/u/7518004?v=3","gravatar_id":"","url":"https://api.github.com/users/gph82","html_url":"https://github.com/gph82","followers_url":"https://api.github.com/users/gph82/followers","following_url":"https://api.github.com/users/gph82/following{/other_user}","gists_url":"https://api.github.com/users/gph82/gists{/gist_id}","starred_url":"https://api.github.com/users/gph82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gph82/subscriptions","organizations_url":"https://api.github.com/users/gph82/orgs","repos_url":"https://api.github.com/users/gph82/repos","events_url":"https://api.github.com/users/gph82/events{/privacy}","received_events_url":"https://api.github.com/users/gph82/received_events","type":"User","site_admin":false},"created_at":"2016-10-13T13:36:14Z","updated_at":"2016-10-13T13:36:14Z","body":"Great, both my test-case and the actual system giving problems work perfectly now. Thanks @clonker ! I'm closing the issue."}}
{"actor":{"display_login":"gph82"}}