Skip to content

Commit

Permalink
add comments for the different cases if a qubit is already measured
Browse files Browse the repository at this point in the history
  • Loading branch information
ashlhans committed Mar 29, 2024
1 parent 9d673ea commit 0134489
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/braket/circuits/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,16 @@ def _check_if_qubit_measured(
ValueError: If adding a gate or noise operation after a measure instruction.
"""
if (
# check if there is a measure instruction on the target qubit
target
and target in self._measure_targets
or (target_mapping and all(targ in self._measure_targets for targ in target_mapping))
# check if there is a measure instruction on any qubits in the target_mapping
or (target_mapping and any(targ in self._measure_targets for targ in target_mapping))
# If no target or target_mapping is supplied, check if there is a measure
# instruction on the current instructions target qubit
or (
instruction.target
and all(targ in self._measure_targets for targ in instruction.target)
and any(targ in self._measure_targets for targ in instruction.target)
)
):
raise ValueError(
Expand Down

0 comments on commit 0134489

Please sign in to comment.