qrunch.quantum.estimators.estimator

Protocols for estimators.

Classes

Estimator

Class for estimating observables.

EstimatorResults

Object for holding the results given by the estimator.

class Estimator

Bases: ABC

Class for estimating observables.

clear_cache() None

Clear the measurement cache.

Return type:

None

has_spin_particle_conservation() bool

Return True, if the estimator is set to use spin particle conservation.

Return type:

bool

has_total_particle_conservation() bool

Return True, if the estimator is set to use total particle conservation.

Return type:

bool

run(observables: Sequence[int | float | complex | Expression[PauliOperators]] | int | float | complex | Expression[PauliOperators] | Sequence[HermitianPauliSum] | HermitianPauliSum, circuits: Sequence[Circuit], shots: int | ShotsPerGroup | None) EstimatorResults
run(observables: int | float | complex | Expression[PauliOperators] | HermitianPauliSum, circuits: Circuit, shots: int | ShotsPerGroup | None) ExpectationValue
run(observables: Sequence[int | float | complex | Expression[PauliOperators]] | Sequence[HermitianPauliSum], circuits: Circuit, shots: int | ShotsPerGroup | None) list[ExpectationValue]

Estimate the value of the observables using the circuit state.

For each observable the following will be calculated: <circuit|observable|circuit>.

Parameters:
Return type:

ExpectationValue | list[ExpectationValue] | EstimatorResults

abstractmethod validate_shots_type(shots_type: Type[int | ShotsPerGroup | None]) list[str]

Validate that the sampler supports the given shots type. Return a list of error messages if not supported.

Parameters:

shots_type (Type[int | ShotsPerGroup | None])

Return type:

list[str]

class EstimatorResults

Bases: object

Object for holding the results given by the estimator.

The results for each circuit is a list of expectation values. The order of the expectation values corresponds to the order of the observables evaluated by the estimator.

__init__(results: list[tuple[Circuit, list[ExpectationValue]]]) None

Build the estimator results object.

Parameters:

results (list[tuple[Circuit, list[ExpectationValue]]]) – The results in simple list of lists-like format.

Return type:

None

n_observables() int

Return how many observables have been evaluated for each circuit.

Return type:

int

values() Iterable[list[ExpectationValue]]

Get an iterable over all expectation values for all circuits.

Return type:

Iterable[list[ExpectationValue]]