braket.registers.qubit_set module
- class braket.registers.qubit_set.QubitSet(qubits: QubitSetInput | None = None)[source]
Bases:
IndexedSet
An ordered, unique set of quantum bits.
Note
QubitSet implements
__hash__()
but is a mutable object, therefore be careful when mutating this object.Initializes a
QubitSet
.- Parameters:
qubits (QubitSetInput | None) – Qubits to be included in the
QubitSet
. Default isNone
.
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[Qubit | int, Qubit | int]) QubitSet [source]
Creates a new
QubitSet
where this instance’s qubits are mapped to the values inmapping
. If this instance contains a qubit that is not in themapping
that qubit is not modified.- Parameters:
mapping (dict[QubitInput, QubitInput]) – 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)])