def test_handle_measurement(self):
    "Handle measurement correctly.\n\n         q0:--.-----(+)-m-------\n              |      |  |\n         q1:-(+)-(+)-|--|-m-----\n                  |  |  | |\n         q2:------|--|--|-|-m---\n                  |  |  | | |\n         q3:-[H]--.--.--|-|-|-m-\n                        | | | |\n         c0:------------.-|-|-|-\n         c1:--------------.-|-|-\n         c2:----------------.-|-\n         c3:------------------.-\n\n         CouplingMap map: [0]->[1]->[2]->[3]\n\n        expected count: '0000': 50%\n                        '1011': 50%\n        "
    self.counts = {'1011': 512, '0000': 512}
    self.shots = 1024
    self.delta = 5
    coupling_map = [[0, 1], [1, 2], [2, 3]]
    qr = QuantumRegister(4, 'q')
    cr = ClassicalRegister(4, 'c')
    circuit = QuantumCircuit(qr, cr, name='handle_measurement')
    circuit.h(qr[3])
    circuit.cx(qr[0], qr[1])
    circuit.cx(qr[3], qr[1])
    circuit.cx(qr[3], qr[0])
    circuit.measure(qr, cr)
    result = self.create_passmanager(coupling_map).run(circuit)
    self.assertResult(result, circuit)
Handle measurement correctly.

 q0:--.-----(+)-m-------
      |      |  |
 q1:-(+)-(+)-|--|-m-----
          |  |  | |
 q2:------|--|--|-|-m---
          |  |  | | |
 q3:-[H]--.--.--|-|-|-m-
                | | | |
 c0:------------.-|-|-|-
 c1:--------------.-|-|-
 c2:----------------.-|-
 c3:------------------.-

 CouplingMap map: [0]->[1]->[2]->[3]

expected count: '0000': 50%
                '1011': 50%
def test_handle_measurement(self):
    "Handle measurement correctly.\n\n         q0:--.-----(+)-m-------\n              |      |  |\n         q1:-(+)-(+)-|--|-m-----\n                  |  |  | |\n         q2:------|--|--|-|-m---\n                  |  |  | | |\n         q3:-[H]--.--.--|-|-|-m-\n                        | | | |\n         c0:------------.-|-|-|-\n         c1:--------------.-|-|-\n         c2:----------------.-|-\n         c3:------------------.-\n\n         CouplingMap map: [0]->[1]->[2]->[3]\n\n        expected count: '0000': 50%\n                        '1011': 50%\n        "
    self.counts = {'1011': 512, '0000': 512}
    self.shots = 1024
    self.delta = 5
    coupling_map = [[0, 1], [1, 2], [2, 3]]
    qr = QuantumRegister(4, 'q')
    cr = ClassicalRegister(4, 'c')
    circuit = QuantumCircuit(qr, cr, name='handle_measurement')
    circuit.h(qr[3])
    circuit.cx(qr[0], qr[1])
    circuit.cx(qr[3], qr[1])
    circuit.cx(qr[3], qr[0])
    circuit.measure(qr, cr)
    result = self.create_passmanager(coupling_map).run(circuit)
    self.assertResult(result, circuit)