예제 #1
0
    def test_definition_unroll_parameterized(self):
        """Verify that unrolling complex gates with parameters does not raise."""
        qr = QuantumRegister(2)
        qc = QuantumCircuit(qr)

        theta = Parameter('theta')

        qc.cu1(theta, qr[1], qr[0])
        qc.cu1(theta * theta, qr[0], qr[1])
        dag = circuit_to_dag(qc)

        out_dag = Unroller(['u1', 'cx']).run(dag)

        self.assertEqual(out_dag.count_ops(), {'u1': 6, 'cx': 4})
    def test_definition_unroll_parameterized(self):
        """Verify that unrolling complex gates with parameters does not raise."""
        qr = QuantumRegister(2)
        qc = QuantumCircuit(qr)

        theta = Parameter("theta")

        qc.append(CU1Gate(theta), [qr[1], qr[0]])
        qc.append(CU1Gate(theta * theta), [qr[0], qr[1]])
        dag = circuit_to_dag(qc)

        out_dag = Unroller(["u1", "cx"]).run(dag)

        self.assertEqual(out_dag.count_ops(), {"u1": 6, "cx": 4})