def test_decompose_conditional(self):
    'Test decompose a 1-qubit gates with a conditional.\n        '
    qr = QuantumRegister(1, 'qr')
    cr = ClassicalRegister(1, 'cr')
    circuit = QuantumCircuit(qr, cr)
    circuit.h(qr).c_if(cr, 1)
    circuit.x(qr).c_if(cr, 1)
    dag = circuit_to_dag(circuit)
    pass_ = Decompose(HGate)
    after_dag = pass_.run(dag)
    ref_circuit = QuantumCircuit(qr, cr)
    ref_circuit.u2(0, pi, qr[0]).c_if(cr, 1)
    ref_circuit.x(qr).c_if(cr, 1)
    ref_dag = circuit_to_dag(ref_circuit)
    self.assertEqual(after_dag, ref_dag)
Test decompose a 1-qubit gates with a conditional.
def test_decompose_conditional(self):
    '\n        '
    qr = QuantumRegister(1, 'qr')
    cr = ClassicalRegister(1, 'cr')
    circuit = QuantumCircuit(qr, cr)
    circuit.h(qr).c_if(cr, 1)
    circuit.x(qr).c_if(cr, 1)
    dag = circuit_to_dag(circuit)
    pass_ = Decompose(HGate)
    after_dag = pass_.run(dag)
    ref_circuit = QuantumCircuit(qr, cr)
    ref_circuit.u2(0, pi, qr[0]).c_if(cr, 1)
    ref_circuit.x(qr).c_if(cr, 1)
    ref_dag = circuit_to_dag(ref_circuit)
    self.assertEqual(after_dag, ref_dag)