Skip to content

Commit f3fb405

Browse files
Simplify conditions when noise should not be applied in model.py
1 parent dafceb3 commit f3fb405

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/bloqade/cirq_utils/noise/model.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,23 +248,17 @@ def noisy_moment(self, moment, system_qubits):
248248
# Moment with original ops
249249
original_moment = moment
250250

251+
no_noise_condition = len(moment.operations) == 0 or cirq.is_measurement(moment.operations[0]) or isinstance(moment.operations[0].gate, cirq.ResetChannel) or isinstance(moment.operations[0].gate, cirq.BitFlipChannel)
252+
251253
# Check if the moment is empty
252-
if len(moment.operations) == 0 or cirq.is_measurement(moment.operations[0]):
254+
if no_noise_condition:
253255
move_noise_ops = []
254256
gate_noise_ops = []
255257
# Check if the moment contains 1-qubit gates or 2-qubit gates
256258
elif len(moment.operations[0].qubits) == 1:
257-
if (
258-
(isinstance(moment.operations[0].gate, cirq.ResetChannel))
259-
or (cirq.is_measurement(moment.operations[0]))
260-
or (isinstance(moment.operations[0].gate, cirq.BitFlipChannel))
261-
):
262-
move_noise_ops = []
263-
gate_noise_ops = []
264-
else:
265-
gate_noise_ops, move_noise_ops = self._single_qubit_moment_noise_ops(
266-
moment, system_qubits
267-
)
259+
gate_noise_ops, move_noise_ops = self._single_qubit_moment_noise_ops(
260+
moment, system_qubits
261+
)
268262
elif len(moment.operations[0].qubits) == 2:
269263
control_qubits = [op.qubits[0] for op in moment.operations]
270264
target_qubits = [op.qubits[1] for op in moment.operations]

0 commit comments

Comments
 (0)