# Path: molmod/io/common.py
# class SlicedReader(object):
#     """Base class for readers that can read a slice of all the frames"""
# 
#     def __init__(self, f, sub=slice(None)):
#         """
#            Argument:
#             | ``f``  --  a filename or a file-like object
# 
#            Optional argument:
#             | ``sub``  --  a slice indicating which frames to read/skip
# 
#         """
#         if isinstance(f, basestring):
#             self._auto_close = True
#             self._f = open(f)
#         else:
#             self._auto_close = False
#             self._f = f
#         self._sub = sub
#         self._counter = 0
# 
#     def __del__(self):
#         """Clean up the open file"""
#         if self._auto_close:
#             self._f.close()
# 
#     def _read_frame(self):
#         """Read a single frame from the trajectory"""
#         raise NotImplementedError
# 
#     def _skip_frame(self):
#         """Skip a single frame from the trajectory"""
#         raise NotImplementedError
# 
#     def __iter__(self):
#         return self
# 
#     def __next__(self):
#         """Get the next frame from the file, taking into account the slice
# 
#            This method is part of the iterator protocol.
#         """
#         # skip frames as requested
#         while not slice_match(self._sub, self._counter):
#             self._skip_frame()
#             self._counter += 1
# 
#         result = self._read_frame()
#         self._counter += 1
#         return result


from builtins import range
from molmod.io.common import SlicedReader
import numpy as np
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
#
# --
"""Tools for parsing CPMD trajectory files"""





__all__ = ["CPMDTrajectoryReader"]


class CPMDTrajectoryReader(SlicedReader):
    """A Reader for CPMD trajectory files

       Use this reader as an iterator::

         >>> ldr = CPMDTrajectoryReader("TRAJECTORY")
         >>> for pos, vel in ldr:
         ...     print pos[4,2]
    """
    def __init__(self, f, sub=slice(None)):
        """
           Arguments:
            | ``f``  --  a filename or a file-like object

           Optional argument:
            | ``sub``  --  a slice object indicating which time frames to skip/read
        """

# Path: molmod/io/common.py
# class SlicedReader(object):
#     """Base class for readers that can read a slice of all the frames"""
# 
#     def __init__(self, f, sub=slice(None)):
#         """
#            Argument:
#             | ``f``  --  a filename or a file-like object
# 
#            Optional argument:
#             | ``sub``  --  a slice indicating which frames to read/skip
# 
#         """
#         if isinstance(f, basestring):
#             self._auto_close = True
#             self._f = open(f)
#         else:
#             self._auto_close = False
#             self._f = f
#         self._sub = sub
#         self._counter = 0
# 
#     def __del__(self):
#         """Clean up the open file"""
#         if self._auto_close:
#             self._f.close()
# 
#     def _read_frame(self):
#         """Read a single frame from the trajectory"""
#         raise NotImplementedError
# 
#     def _skip_frame(self):
#         """Skip a single frame from the trajectory"""
#         raise NotImplementedError
# 
#     def __iter__(self):
#         return self
# 
#     def __next__(self):
#         """Get the next frame from the file, taking into account the slice
# 
#            This method is part of the iterator protocol.
#         """
#         # skip frames as requested
#         while not slice_match(self._sub, self._counter):
#             self._skip_frame()
#             self._counter += 1
# 
#         result = self._read_frame()
#         self._counter += 1
#         return result


# Path: molmod/io/cpmd.py
from builtins import range
from molmod.io.common import SlicedReader
import numpy as np

# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
#
# --
"""Tools for parsing CPMD trajectory files"""





__all__ = ["CPMDTrajectoryReader"]


class CPMDTrajectoryReader(SlicedReader):
    """A Reader for CPMD trajectory files

       Use this reader as an iterator::

         >>> ldr = CPMDTrajectoryReader("TRAJECTORY")
         >>> for pos, vel in ldr:
         ...     print pos[4,2]
    """
    def __init__(self, f, sub=slice(None)):
        """
           Arguments:
            | ``f``  --  a filename or a file-like object

           Optional argument:
            | ``sub``  --  a slice object indicating which time frames to skip/read
        """

        SlicedReader.__init__(self, f, sub)