qrisp.QuantumVariable.decoder#

QuantumVariable.decoder(i)[source]#

The decoder method specifies how a QuantumVariable turns the outcomes of measurements into human-readable values. It recieves an integer i and returns a human-readable value.

This method is supposed to be overloaded when defining new quantum types.

Parameters:
iint

Integer representing the outcome of a measurement of the qubits of this QuantumVariable.

Returns:
A human-readable value. Has to be hashable.

Examples

We create a QuantumFloat and inspect its decoder:

>>> from qrisp import QuantumFloat
>>> qf = QuantumFloat(3, -1, signed = False)
>>> print(qf.decoder(1))
0.5

This implies that if the 3 qubits of this QuantumFloat are measured in state 001, this outcome corresponds to the value 0.5.