Skip to content

Commit 5d4e47e

Browse files
committed
no need to handle id gate as a special case
1 parent 4299cf4 commit 5d4e47e

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/qrisp/interface/converter/cirq_converter.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
'measure': M,
2626
'reset': R,
2727
'id': I,
28-
'p': ZPowGate,
29-
'sx': XPowGate,
30-
'sx_dg': XPowGate,
28+
'p': None,
29+
'sx': None,
30+
'sx_dg': None,
3131
}
3232

3333

@@ -69,22 +69,19 @@ def convert_to_cirq(qrisp_circuit):
6969

7070
cirq_gate = qrisp_cirq_ops_dict[op_i]
7171

72-
if instr.op.params and not isinstance(instr.op, ControlledOperation):
72+
if op_i != 'id' and instr.op.params and not isinstance(instr.op, ControlledOperation):
7373
# for single qubit parametrized gates
74-
if op_i == 'id':
75-
# added becasue the identity gate has parameters (0, 0, 0)
76-
cirq_circuit.append(cirq_gate(*cirq_op_qubits))
74+
# added becasue the identity gate has parameters (0, 0, 0)
75+
if op_i == 'p':
76+
# Cirq does not have a phase gate
77+
# for this reason, it has to be dealt with as a special case.
78+
# the ZPowGate has a global phase in addition to the
79+
# phase exponent. The default is to assume global_shift = 0 in cirq
80+
exp_param = params[0]
81+
cirq_circuit.append(ZPowGate(exponent=exp_param)(*cirq_op_qubits))
7782
else:
78-
if op_i == 'p':
79-
# Cirq does not have a phase gate
80-
# for this reason, it has to be dealt with as a special case.
81-
# the ZPowGate has a global phase in addition to the
82-
# phase exponent. The default is to assume global_shift = 0 in cirq
83-
exp_param = params[0]
84-
cirq_circuit.append(ZPowGate(exponent=exp_param)(*cirq_op_qubits))
85-
else:
86-
gate_instance = cirq_gate(*params)
87-
cirq_circuit.append(gate_instance(*cirq_op_qubits))
83+
gate_instance = cirq_gate(*params)
84+
cirq_circuit.append(gate_instance(*cirq_op_qubits))
8885

8986
elif isinstance(instr.op, ControlledOperation):
9087
# control and target qubits from qrisp

0 commit comments

Comments
 (0)