Example #1
0
    def add_gate(self, gate, qubit=None):
        """Add a set of gates to the given qubit.

        For the qubits with no specificied gate, an IdentityGate will be given.
        The length of the step is given by the longest pulse.

        Parameters
        ----------
        qubit : int or list of int
            The qubit(s) to add the gate(s) to.
        gate : :obj:`BaseGate` or list of :obj:`BaseGate`
            The gate(s) to add.
        """
        if qubit is None:
            if self.n_qubit == 1:
                qubit = 0
            else:
                qubit = [n for n in range(self.n_qubit)]

        step = Step()
        if isinstance(gate, list):
            if len(gate) == 1:
                raise ValueError(
                    "For single gates, don't provide gate as a list.")
            if not isinstance(qubit, list):
                raise ValueError(
                    "Please provide qubit indices as a list when adding more thab one gate."
                )
            if len(gate) != len(qubit):
                raise ValueError(
                    "Length of gate list must be equal to length of qubit list."
                )

            for q, g in zip(qubit, gate):
                step.add_gate(q, g)

        else:
            if gate.number_of_qubits() > 1:
                if not isinstance(qubit, list):
                    raise ValueError(
                        "Please provide qubit list for gates with more than one qubit."
                    )
            else:
                if not isinstance(qubit, int):
                    raise ValueError(
                        "For single gates, give qubit as int (not list).")
            step.add_gate(qubit, gate)

        self.sequence.append(step)
Example #2
0
	def _run (self):
		Step._run(self)
		_experiment.set_log_output(str(self._expr))
		return self._complete(self._expr)
Example #3
0
 def _run(self):
     Step._run(self)
     _experiment.set_log_output(str(self._expr))
     return self._complete(self._expr)