Example #1
0
 def from_dict(self, cfg: Dict) -> None:
     """
     Load experiment from dictionary
     """
     model = Model()
     model.fromdict(cfg["model"])
     generator = Generator()
     generator.fromdict(cfg["generator"])
     pmap = ParameterMap(model=model, generator=generator)
     pmap.fromdict(cfg["instructions"])
     if "options" in cfg:
         for k, v in cfg["options"].items():
             self.__dict__[k] = v
     self.pmap = pmap
Example #2
0
    def read_config(self, filepath: str) -> None:
        """
        Load a file and parse it to create a Model object.

        Parameters
        ----------
        filepath : str
            Location of the configuration file

        """
        with open(filepath, "r") as cfg_file:
            cfg = hjson.loads(cfg_file.read())
        model = Model()
        model.fromdict(cfg["model"])
        generator = Generator()
        generator.fromdict(cfg["generator"])
        pmap = ParameterMap(model=model, generator=generator)
        pmap.fromdict(cfg["instructions"])
        self.pmap = pmap