PartialState¶
- class guppylang.emulator.PartialState(*args, **kwargs)[source]¶
Protocol for an emulator state type. Different simulation backends may have different state representations.
- __abstractmethods__ = frozenset({})¶
- __init__(*args, **kwargs)¶
- __subclasshook__()¶
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
- as_single_state(zero_threshold: float = 1e-12) S [source]¶
If the state is a single pure state return it.
- Args:
- zero_threshold: Threshold for considering a state amplitude to be zero.
Defaults to 1e-12.
- Raises:
NotSingleStateError: If the state is not a pure state.
- Returns:
The state as a single state type.
- state_distribution(zero_threshold: float = 1e-12) list[TracedState[S]] [source]¶
Distribution of states after tracing out unspecified qubits. In general this results in a distribution of states, each with a probability.
- Args:
- zero_threshold: Threshold for considering a state amplitude to be zero.
Defaults to 1e-12.
- Returns:
List of traced states, each with a state vector and a probability.