Skip to content

state_encoder

Common interface for preparing a quantum state from classical data.

StateEncoder

Bases: ABC

Prepare a normalized State from classical data.

Subclasses define which classical inputs they accept. Every encoding returns a state vector that simulators can take as initial_state.

Source code in shadowsim/encoding/state_encoder.py
class StateEncoder(ABC):
    """Prepare a normalized ``State`` from classical data.

    Subclasses define which classical inputs they accept. Every encoding returns
    a state vector that simulators can take as ``initial_state``.
    """

    @abstractmethod
    def encode(self, data: npt.ArrayLike) -> State:
        """Return the quantum state prepared from ``data``.

        Args:
            data: Classical input for this encoding.

        Returns:
            A normalized state on the qubits this encoding uses.
        """
        raise NotImplementedError

encode abstractmethod

encode(data: ArrayLike) -> State

Return the quantum state prepared from data.

Parameters:

  • data (ArrayLike) –

    Classical input for this encoding.

Returns:

  • State –

    A normalized state on the qubits this encoding uses.

Source code in shadowsim/encoding/state_encoder.py
@abstractmethod
def encode(self, data: npt.ArrayLike) -> State:
    """Return the quantum state prepared from ``data``.

    Args:
        data: Classical input for this encoding.

    Returns:
        A normalized state on the qubits this encoding uses.
    """
    raise NotImplementedError