Registers#
Registers for collecting qubits, bits and variables.
Provides performant container classes for keeping track of and handling primitive type objects (see
dwave.gate.primitives
for details on the supported objects).
Registers Module#
- class ClassicalRegister(data: Sequence[Bit] | None = None)[source]#
-
Classical register to store bits.
- Parameters:
data – Sequence of bits (defaults to empty).
- to_qasm(label: Hashable | None = None, idx: int | None = None) str [source]#
Converts the classical register into an OpenQASM string.
- Parameters:
label – Optional label for the quantum register.
idx – Optional index number for quantum register.
- Returns:
OpenQASM string representation of the circuit.
- Return type:
- class QuantumRegister(data: Sequence[Qubit] | None = None)[source]#
-
Quantum register to store qubits.
- Parameters:
data – Sequence of qubits (defaults to empty).
- to_qasm(label: Hashable | None = None, idx: int | None = None) str [source]#
Converts the quantum register into an OpenQASM string.
- Parameters:
label – Optional label for the quantum register.
idx – Optional index number for quantum register.
- Returns:
OpenQASM string representation of the circuit.
- Return type:
- class Register(data: Sequence[Data] | None = None)[source]#
Bases:
cyRegister
,AbstractSet
[Data
],Sequence
[Data
]Register to store qubits and/or classical bits.
- Parameters:
data – Sequence of hashable data items (defaults to empty).
- exception RegisterError[source]#
Bases:
Exception
Exception to be raised when there is an error with a Register.
- class SelfIncrementingRegister(data: Sequence[Variable] | None = None)[source]#
Bases:
Register
Self-incrementing classical register to store parameter variables.
The self-incrementing register will automatically add variable parameters when attemting to index outside of the register scope, and then return the requested index. For example, attempting to get parameter at index 3 in a
SelfIncrementingRegister
of length 1 would be equal to first runningRegister.add([Variable("p1"), Variable("p2")])
and then returningVariable("p2")
.- Parameters:
label – Classical register label. data: Sequence of bits (defaults to empty).
data – Sequence of parameters or variables (defaults to empty).