Closed mtweiden closed 8 months ago
Thanks for being quick with this fix! A couple of changes: I would override Gate.qasm_name
or add an attribute to the class _qasm_name
. This is because you are not changing how the entire qasm line gets printed.
Looking at the decoding, the cu1
, cu2
, cu3
, cswap
, c3x
, and c4x
are all the standard qasm2 identitifers that are handled this way. Does your implementation catch the cswap
, c3x
, and c4x
?
I do like that your implementation handles multiple controls on gates nicely, but I worry this will also create a situation where we can encode something we can decode, e.g. ControlledGate(XGate(), 5)
. As annoying and limiting as this sounds, I think we should just check for the standard qasm ids, and print a helpful (or annoying but more specific) error in other cases.
Thanks again for putting this up!
This new version overrides the Gate.qasm_name
property. There's a check now to ensure that only standard OpenQASM2.0 identifiers (or at least those in bqskit.ir.lang.qasm2.visitor.py
) can be encoded.
This PR adds support for outputting qasm of singly-controlled "standard" gates. Standard gates are those that have a defined
qasm_name
property.Resolves #214