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: Optional[Sequence[dwave.gate.primitives.Bit]] = None)[source]¶
Bases:
dwave.gate.registers.registers.Register
[dwave.gate.primitives.Bit
]Classical register to store bits.
- Parameters
data – Sequence of bits (defaults to empty).
- to_qasm(label: Optional[Hashable] = None, idx: Optional[int] = 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: Optional[Sequence[dwave.gate.primitives.Qubit]] = None)[source]¶
Bases:
dwave.gate.registers.registers.Register
[dwave.gate.primitives.Qubit
]Quantum register to store qubits.
- Parameters
data – Sequence of qubits (defaults to empty).
- to_qasm(label: Optional[Hashable] = None, idx: Optional[int] = 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: Optional[Sequence[dwave.gate.registers.registers.Data]] = None)[source]¶
Bases:
dwave.gate.registers.cyregister.cyRegister
,AbstractSet
[dwave.gate.registers.registers.Data
],Sequence
[dwave.gate.registers.registers.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: Optional[Sequence[dwave.gate.primitives.Variable]] = None)[source]¶
Bases:
dwave.gate.registers.registers.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).