braket.circuits.qubit_set module¶
-
class
braket.circuits.qubit_set.
QubitSet
(qubits: Union[Qubit, int, Iterable[Union[Qubit, int]]] = [])[source]¶ Bases:
boltons.setutils.IndexedSet
An ordered, unique set of quantum bits.
Note
QubitSet implements __hash__() but is a mutable object, therefore be careful when mutating this object.
- Parameters
qubits (int, Qubit, or iterable of int / Qubit) – Qubits to be included in the QubitSet.
Examples
>>> qubits = QubitSet([0, 1]) >>> for qubit in qubits: ... print(qubit) ... Qubit(0) Qubit(1)
>>> qubits = QubitSet([0, 1, [2, 3]]) >>> for qubit in qubits: ... print(qubit) ... Qubit(0) Qubit(1) Qubit(2) Qubit(3)
-
map
(mapping: Dict[Union[Qubit, int], Union[Qubit, int]]) → braket.circuits.qubit_set.QubitSet[source]¶ Creates a new QubitSet where this instance’s qubits are mapped to the values in
mapping
. If this instance contains a qubit that is not in themapping
that qubit is not modified.- Parameters
mapping (dictionary[int or Qubit, int or Qubit]) – A dictionary of qubit mappings to apply. Key is the qubit in this instance to target, and the value is what the key will be changed to.
- Returns
QubitSet – A new QubitSet with the
mapping
applied.
Examples
>>> qubits = QubitSet([0, 1]) >>> mapping = {0: 10, Qubit(1): Qubit(11)} >>> qubits.map(mapping) QubitSet([Qubit(10), Qubit(11)])