OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0],q[1];
measure q -> c;
running staq to output Cirq code results in a source string that will throw an error upon execution
Traceback (most recent call last):
File "bellcirq.py", line 98, in <module>
cirq.CNOT(q[0], q[1]),
File "/home/cades/.local/lib/python3.7/site-packages/cirq/ops/raw_types.py", line 259, in __call__
return self.on(*args, **kwargs)
File "/home/cades/.local/lib/python3.7/site-packages/cirq/ops/common_gates.py", line 861, in on
return super().on(*args)
File "/home/cades/.local/lib/python3.7/site-packages/cirq/ops/raw_types.py", line 200, in on
return gate_operation.GateOperation(self, list(qubits))
File "/home/cades/.local/lib/python3.7/site-packages/cirq/ops/gate_operation.py", line 41, in __init__
gate.validate_args(qubits)
File "/home/cades/.local/lib/python3.7/site-packages/cirq/ops/raw_types.py", line 190, in validate_args
_validate_qid_shape(self, qubits)
File "/home/cades/.local/lib/python3.7/site-packages/cirq/ops/raw_types.py", line 520, in _validate_qid_shape
val, qubits))
ValueError: Duplicate qids for <cirq.CNOT>. Expected unique qids but got <[cirq.NamedQubit('q[i]'), cirq.NamedQubit('q[i]')]>.
Given the following simple OpenQasm
running staq to output Cirq code results in a source string that will throw an error upon execution
The fix is pretty simple, update https://github.com/softwareQinc/staq/blob/master/include/output/cirq.hpp#L272 to evaluate the index var
i
.q = [cirq.NamedQubit("q[{}]".format(i)) for i in range(2)]