def set_params_from_dict(self, meta_dict): """Set object parameters by given metadata dictionary Parameters ---------- meta_dict: dict """ for param_name, param_value in meta_dict.items(): if key_in_grid1d(param_name): setattr(self.grid, param_name, param_value) elif is_numerical(param_value): setattr(self, param_name, param_value)
def create_from_dict(cls, meta_dict): """Set object parameters by given metadata dictionary Parameters ---------- meta_dict: dict """ filtered_dict = {} grid_dict = {} for param_name, param_value in meta_dict.items(): if key_in_grid1d(param_name): grid_dict[param_name] = param_value elif is_numerical(param_value): filtered_dict[param_name] = param_value grid = Grid1d(**grid_dict) filtered_dict['grid'] = grid return cls(**filtered_dict)
def set_params_from_dict(self, meta_dict): """Set object parameters by given metadata dictionary Parameters ---------- meta_dict: dict """ for param_name, param_value in meta_dict.items(): if key_in_grid1d(param_name): setattr(self.grid, param_name, param_value) elif is_numerical(param_value): setattr(self, param_name, param_value) self._zeropi = ZeroPi(EJ=self.EJ, EL=self.EL, ECJ=self.ECJ, EC=self.EC, dEJ=self.dEJ, dCJ=self.dCJ, flux=self.flux, ng=self.ng, grid=self.grid, ncut=self.ncut, truncated_dim=self.zeropi_cutoff)
def _get_metadata_dict(self): meta_dict = { key: value for key, value in self.__dict__.items() if is_numerical(value) } return meta_dict