From 0dcbd70d49653b8e2e40358a25ab919a36f0e073 Mon Sep 17 00:00:00 2001 From: Cody Wang Date: Mon, 28 Aug 2023 17:06:26 -0600 Subject: [PATCH] Move inline `_flatten` to top of `qubit_set.py` (#691) --- src/braket/circuits/qubit_set.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/braket/circuits/qubit_set.py b/src/braket/circuits/qubit_set.py index 155ca548e..d4571e91a 100644 --- a/src/braket/circuits/qubit_set.py +++ b/src/braket/circuits/qubit_set.py @@ -22,6 +22,14 @@ QubitSetInput = Union[QubitInput, Iterable[QubitInput]] +def _flatten(other: Any) -> Any: + if isinstance(other, Iterable) and not isinstance(other, str): + for item in other: + yield from _flatten(item) + else: + yield other + + class QubitSet(IndexedSet): """ An ordered, unique set of quantum bits. @@ -54,13 +62,6 @@ def __init__(self, qubits: QubitSetInput = None): Qubit(3) """ - def _flatten(other: Any) -> Any: - if isinstance(other, Iterable) and not isinstance(other, str): - for item in other: - yield from _flatten(item) - else: - yield other - _qubits = [Qubit.new(qubit) for qubit in _flatten(qubits)] if qubits is not None else None super().__init__(_qubits)