-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make add_control identify known definitions by type not name #3540
Comments
I can make these changes if no one's started already |
Sounds good, I don't know of anyone who has. |
FYI, #3631 partially addresses this problem (at least for the standard gates). Implementation on this may want to wait until that merges. |
I'm going to close this as stale now, in part because the data model of Terra is that the gate name is treated as an opcode; a circuit named Please feel free to re-open if there's more to discuss. |
Information
What is the current behavior?
Currently when controlling a gate via gate.control(), the add_control function will check if the to be generated gate exists as special gate in extensions (such as cnot, toffoli, ect...), and create that instead of a generic one. This check is done by comparing the gate.name attribute against 'x', 'y', 'z' and so on. This can be problematic and should be replaced with a type check.
This can actually lead to a bug, for example if a gate is created from a circuit object via qc.to_gate(), and the circuit was unfortunately named (e.g. 'x'). Then the resulting gate will also have the same name, and could thus be transformed into the wrong gate upon controlling it (e.g. into a CnotGate if named 'x').
Steps to reproduce the problem
What is the expected behavior?
Suggested solutions
The text was updated successfully, but these errors were encountered: