예제 #1
0
def _qobj_to_circuit_cals(qobj, pulse_lib, param_pulses):
    """Return circuit calibrations dictionary from qobj/exp config calibrations."""
    qobj_cals = qobj.config.calibrations.to_dict()["gates"]
    converter = QobjToInstructionConverter(pulse_lib)

    qc_cals = {}
    for gate in qobj_cals:
        config = (tuple(gate["qubits"]), tuple(gate["params"]))
        cal = {
            config: pulse.Schedule(
                name="%s %s %s" % (gate["name"], str(gate["params"]), str(gate["qubits"]))
            )
        }
        for instruction in gate["instructions"]:
            schedule = (
                converter.convert_parametric(PulseQobjInstruction.from_dict(instruction))
                if "pulse_shape" in instruction and instruction["pulse_shape"] in param_pulses
                else converter(PulseQobjInstruction.from_dict(instruction))
            )
            cal[config] = cal[config].insert(schedule.ch_start_time(), schedule)
        if gate["name"] in qc_cals:
            qc_cals[gate["name"]].update(cal)
        else:
            qc_cals[gate["name"]] = cal

    return qc_cals
예제 #2
0
    def from_dict(cls, data):
        """Create a new Command object from a dictionary.

        Args:
            data (dict): A dictionary representing the ``Command``
                         to create. It will be in the same format as output by
                         :meth:`to_dict`.

        Returns:
            qiskit.providers.model.Command: The ``Command`` from the input
                dictionary.
        """
        in_data = copy.copy(data)
        if "sequence" in in_data:
            in_data["sequence"] = [
                PulseQobjInstruction.from_dict(x) for x in in_data.pop("sequence")
            ]
        return cls(**in_data)