From 09ef78820fbc20daa796f9b3b1a428b4e2fbf46c Mon Sep 17 00:00:00 2001 From: Ryan Shaffer <3620100+rmshaffer@users.noreply.github.com> Date: Thu, 26 Oct 2023 11:58:53 -0400 Subject: [PATCH] Allow measure to accept any iterable --- .../experimental/autoqasm/instructions/measurements.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/braket/experimental/autoqasm/instructions/measurements.py b/src/braket/experimental/autoqasm/instructions/measurements.py index 2b9fb98dc..d92357de2 100644 --- a/src/braket/experimental/autoqasm/instructions/measurements.py +++ b/src/braket/experimental/autoqasm/instructions/measurements.py @@ -23,6 +23,7 @@ def my_program(): """ +from collections.abc import Iterable from typing import Union from braket.experimental.autoqasm import program @@ -30,18 +31,18 @@ def my_program(): from braket.experimental.autoqasm.instructions.qubits import QubitIdentifierType, _qubit -def measure(qubits: Union[QubitIdentifierType, list[QubitIdentifierType]]) -> aq_types.BitVar: +def measure(qubits: Union[QubitIdentifierType, Iterable[QubitIdentifierType]]) -> aq_types.BitVar: """Add qubit measurement statements to the program and assign the measurement results to bit variables. Args: - qubits (Union[QubitIdentifierType, list[QubitIdentifierType]]): The target qubits + qubits (Union[QubitIdentifierType, Iterable[QubitIdentifierType]]): The target qubits to measure. Returns: BitVar: Bit variable the measurement results are assigned to. """ - if not isinstance(qubits, list): + if not isinstance(qubits, Iterable): qubits = [qubits] oqpy_program = program.get_program_conversion_context().get_oqpy_program()