Beispiel #1
0
 def __init__(self, name=None, model=None, state=None, world=None, logger=logger):
     """Initializer.
     """
     super(Simulator, self).__init__(name) # implies self.name
     self.model = model
     self.state = state
     self.world = world
     self.logger = logger
     logger.debug('%s:: Instance initialized.' %(self.__class__.__name__))
Beispiel #2
0
    def save(self, hdf5_or_filename, strict_version=True):
        """Save data into a file.

        This method ALWAYS OVERWRITE data in exisisting file.

        - hdf5_or_filename: h5py.File instance or string of file path.
        - strict_version: Raise error if file version is not in SUPPORTED VERSION.
        """
        data_root = super(Simulator, self).save(hdf5_or_filename, strict_version=True)
        # all green here, ready to serialize.
        self.save_model(data_root, strict_version)
        self.save_state(data_root, strict_version)
        self.save_world(data_root, strict_version)
        logger.debug('%s:: saved to %s.' %(self.__class__.__name__, hdf5_or_filename))
        return data_root
Beispiel #3
0
    def load(self, hdf5_or_filename, strict_version=True):
        """Load data from a file (into exisiting instance).

        This method ALWAYS OVERWRITE instance attribute with loaded file.

        - hdf5_or_filename: h5py.File instance or string of file path.
        - strict_version: Raise error if file version is not in SUPPORTED VERSION.
        """
        data_root = super(Simulator, self).load(hdf5_or_filename, strict_version=True)
        # all green here, ready to update.
        self.load_model(data_root, strict_version)
        self.load_state(data_root, strict_version)
        self.load_world(data_root, strict_version)
        logger.debug('%s:: loaded from %s.' %(self.__class__.__name__, hdf5_or_filename))
        return data_root