Skip to content

Commit

Permalink
Fix test improperly comparing measurement values (#591)
Browse files Browse the repository at this point in the history
* fix failing test

* trying again to fix the test
  • Loading branch information
albi3ro authored Oct 22, 2024
1 parent 2e02d73 commit fad15a1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1639,18 +1639,24 @@ def test_diff_meas_circuit(self):
qc.cx(0, 1)
qc.measure(1, 1)

m1, m2 = load(qc)()
for m, w in zip((m1, m2), (0, 1)):
assert isinstance(m, qml.measurements.MeasurementValue)
assert len(m.measurements) == 1
assert m.measurements[0].wires == qml.wires.Wires(w)

qc1 = QuantumCircuit(3, 3)
qc1.h(0)
qc1.measure(2, 2)
qc1.rx(angle, [0])
qc1.cx(0, 1)
qc1.measure(1, 1)

qtemp, qtemp1 = load(qc), load(qc1)
assert qtemp()[0] == qml.measure(0) and qtemp1()[0] == qml.measure(2)

qtemp2 = load(qc, measurements=[qml.expval(qml.PauliZ(0))])
assert qtemp()[0] != qtemp2()[0] and qtemp2()[0] == qml.expval(qml.PauliZ(0))
m1, m2 = load(qc1)()
for m, w in zip((m1, m2), (2, 1)):
assert isinstance(m, qml.measurements.MeasurementValue)
assert len(m.measurements) == 1
assert m.measurements[0].wires == qml.wires.Wires(w)


class TestConverterPennyLaneCircuitToQiskit:
Expand Down

0 comments on commit fad15a1

Please sign in to comment.