From 3c660b23185a35bbab9bbab71b043d426edcecfc Mon Sep 17 00:00:00 2001 From: Ashlyn Hanson <65787294+ashlhans@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:12:57 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Cody Wang --- src/braket/circuits/circuit.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/braket/circuits/circuit.py b/src/braket/circuits/circuit.py index a90415386..2cf1a29b4 100644 --- a/src/braket/circuits/circuit.py +++ b/src/braket/circuits/circuit.py @@ -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.")