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 | None) EstimatorResults
run(observables: int | float | complex | Expression[PauliOperators] | HermitianPauliSum, circuits: Circuit, shots: int | None) ExpectationValue
run(observables: Sequence[int | float | complex | Expression[PauliOperators]] | Sequence[HermitianPauliSum], circuits: Circuit, shots: int | 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:
  • observables – Observable(s) to be estimated.

  • circuits – States to make estimation from.

  • shots – number of shots or None if using a full state vector calculation.

abstractmethod supports_shots_equals_none() bool

Return whether the estimator supports shots = None.

Shots = None means that a full state vector simulation is done.

Return type:

bool

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.

  • observables – The observables evaluated by the estimator.

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]]