qrisp.QuantumVariable.encoder#

QuantumVariable.encoder(value)[source]#

The encoder reverses the decoder, it turns human-readable values into integers.

If not overloaded, the encoder will perform a linear search on decoder inputs to match the given value.

Parameters
label

A human-readable value.

Returns
iint

The integer encoding the given value.

Raises
Exception

Unknown input value.

Examples

We create a QuantumChar and inspect it’s encoder:

>>> from qrisp import QuantumChar
>>> q_ch = QuantumChar()
>>> print(q_ch.encoder("f"))
5

This implies that if the 5 qubits of this QuantumChar are measured to 5 = 00101, the out come will be displayed as f.