Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Cody Wang <speller26@gmail.com>
  • Loading branch information
ashlhans and speller26 authored Apr 11, 2024
1 parent 264259d commit 3c660b2
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/braket/circuits/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,24 +441,17 @@ def _check_if_qubit_measured(
ValueError: If adding a gate or noise operation after a measure instruction.
"""
if self._measure_targets:
measure_on_target = (
target and any(tar in self._measure_targets for tar in target)
if isinstance(target, Iterable)
else target in self._measure_targets
)
measure_on_target = any(tar in self._measure_targets for tar in QubitSet(target))
measure_on_target_mapping = target_mapping and any(
targ in self._measure_targets for targ in target_mapping.values()
)
measure_on_instruction_target = (
instruction
and instruction.target
and any(targ in self._measure_targets for targ in instruction.target)
measure_on_instruction_target = any(
targ in self._measure_targets for targ in QubitSet(instruction.target)
)
if (
# check if there is a measure instruction on the targeted qubit(s)
measure_on_target
or measure_on_target_mapping
or measure_on_instruction_target
measure_on_target_mapping
or any(tar in self._measure_targets for tar in QubitSet(target) + QubitSet(instruction.target))
):
raise ValueError("cannot apply instruction to measured qubits.")

Expand Down

0 comments on commit 3c660b2

Please sign in to comment.