QubitSet
- class braket.registers.qubit_set.QubitSet(qubits=None)[source]
Bases:
IndexedSetAn 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 (
Union[Qubit,int,Iterable[Union[Qubit,int]],None]) – Qubits to be included in theQubitSet. 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)[source]
Creates a new
QubitSetwhere this instance’s qubits are mapped to the values inmapping. If this instance contains a qubit that is not in themappingthat qubit is not modified.- Parameters:
mapping (
dict[Union[Qubit,int],Union[Qubit,int]]) – 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.- Return type:
- Returns:
QubitSet – A new QubitSet with the
mappingapplied.
Examples
>>> qubits = QubitSet([0, 1]) >>> mapping = {0: 10, Qubit(1): Qubit(11)} >>> qubits.map(mapping) QubitSet([Qubit(10), Qubit(11)])