def __init__(self, f, sub=slice(None), pos_unit=angstrom,
        vel_unit=angstrom/picosecond, frc_unit=amu*angstrom/picosecond**2,
        time_unit=picosecond, mass_unit=amu, restart=False,
    ):
        """
           Arguments:
             | ``f``  --  a filename or a file-like object

           Optional arguments:
             | ``sub``  --  a slice indicating the frames to be skipped/selected
             | ``pos_unit``, ``vel_unit``, ``frc_unit``, ``time_unit``,
               ``mass_unit``  --  The conversion factors for the unit conversion
                from the units in the data file to atomic units. The defaults of
                these optional arguments correspond to the defaults of dlpoly.

           When the file starts with a line that satisfies the following
           conditions, it is assumed that this is a history restart file:

           * line consists of 6 words
           * first word equals 'timestep'
           * the following for words are integers
           * the last word is a float
        """
        SlicedReader.__init__(self, f, sub)
        self._counter = 1 # make our counter compatible with dlpoly
        self.pos_unit = pos_unit
        self.vel_unit = vel_unit
        self.frc_unit = frc_unit
        self.time_unit = time_unit
        self.mass_unit = mass_unit
        restart = self._detect_restart()
        if restart is None:
            try:
                self.header = next(self._f)[:-1]
                integers = tuple(int(word) for word in next(self._f).split())
                if len(integers) != 3:
                    raise FileFormatError("Second line must contain three integers.")
                self.keytrj, self.imcon, self.num_atoms = integers
            except StopIteration:
                raise FileFormatError("File is too short. Could not read header.")
            except ValueError:
                raise FileFormatError("Second line must contain three integers.")
        else:
            self.header = ''
            self.num_atoms, self.keytrj, self.imcon = restart
        self._frame_size = 4 + self.num_atoms*(self.keytrj+2)
def __init__ ( self , f , sub = slice ( None ) , pos_unit = angstrom , vel_unit = angstrom / picosecond , frc_unit = amu * angstrom / picosecond ** 2 , time_unit = picosecond , mass_unit = amu , restart = False , ) : SlicedReader . __init__ ( self , f , sub ) self . _counter = 1 self . pos_unit = pos_unit self . vel_unit = vel_unit self . frc_unit = frc_unit self . time_unit = time_unit self . mass_unit = mass_unit restart = self . _detect_restart ( ) if restart is None : try : self . header = next ( self . _f ) [ : - 1 ] integers = tuple ( int ( word ) for word in next ( self . _f ) . split ( ) ) if len ( integers ) != 3 : raise FileFormatError ( "Second line must contain three integers." ) self . keytrj , self . imcon , self . num_atoms = integers except StopIteration : raise FileFormatError ( "File is too short. Could not read header." ) except ValueError : raise FileFormatError ( "Second line must contain three integers." ) else : self . header = '' self . num_atoms , self . keytrj , self . imcon = restart self . _frame_size = 4 + self . num_atoms * ( self . keytrj + 2 )
Arguments:
             | ``f``  --  a filename or a file-like object

           Optional arguments:
             | ``sub``  --  a slice indicating the frames to be skipped/selected
             | ``pos_unit``, ``vel_unit``, ``frc_unit``, ``time_unit``,
               ``mass_unit``  --  The conversion factors for the unit conversion
                from the units in the data file to atomic units. The defaults of
                these optional arguments correspond to the defaults of dlpoly.

           When the file starts with a line that satisfies the following
           conditions, it is assumed that this is a history restart file:

           * line consists of 6 words
           * first word equals 'timestep'
           * the following for words are integers
           * the last word is a float