qrisp.lock#

lock(qubits, message='')[source]#

Locks a list of qubits, implying an error will be raised if the user tries to perform any operation involving these qubits. Using the keywoard message it is possible to extend the displayed error message.

This can be reversed by calling unlock.

Parameters:
qubitslist[Qubit] or QuantumVariable

The list of Qubits to lock.

messagestr, optional

The message why these qubits are locked.

Examples

We create a QuantumChar, lock it’s Qubits and attempt to initialize.

>>> from qrisp import QuantumChar, lock
>>> q_ch = QuantumChar()
>>> lock(q_ch, message = "Qubits are locked due to testing purposes")
>>> q_ch[:] = "g"
Exception: Qubits are locked due to testing purposes