def fromdict(self, cfg: dict) -> None: for key, gate in cfg.items(): if "mapto" in gate.keys(): instr = copy.deepcopy(self.instructions[gate["mapto"]]) instr.name = key for drive_chan, comps in gate["drive_channels"].items(): for comp, props in comps.items(): for par, val in props["params"].items(): instr.comps[drive_chan][comp].params[ par].set_value(val) else: # TODO: initialize directly by using the constructor. instr = Instruction(ideal=[[1]]) # Set ideal to mute warning instr.from_dict(gate, name=key) self.instructions[key] = instr self.__initialize_parameters()
def test_save_and_load(): global instr, pmap instr = Instruction() instr.from_dict(hjson.loads(instr_dict_str, object_pairs_hook=hjson_decode)) pmap = ParameterMap(model=model, generator=generator, instructions=[instr]) test_extended_pulse()