Open refi64 opened 5 years ago
eng.flush()
statements need to be put before accessing the result of some measurements.
Now, I am not sure having a CNOT
gate with identical control and target qubits makes a lot of sense, because by definition, the control target should not be modified after the application of the gate. Also, it is usually understood that 2-qubit gate get applied on two different qubits.
It is true, however, that ProjectQ currently does not checks whether control and target qubits are disjoints.
Yeah identical qubits in a CNOT isn't useful or even allowed by most frameworks, but crashing with an obscure IndexError isn't very helpful in that case either...
Yeah identical qubits in a CNOT isn't useful or even allowed by most frameworks, but crashing with an obscure IndexError isn't very helpful in that case either...
I agree! So I'll keep this issue open until we fix this (hopefully sometime soon)
Repro:
This yields:
With
verbose=True
:Of course,
eng.flush()
fixes the issue, but this should probably raise that relevant exception instead of the more obscure IndexError...On that note, is there a reason why this doesn't work:
EDIT: I just realized my
eng.flush()
's were before theMeasure
statements in order to avoid the crash, but aren't they supposed to be after?EDIT 2: The same crash can be reproduced via
CNOT | (q0, q0)
.