47 lines
2.9 KiB
Plaintext
47 lines
2.9 KiB
Plaintext
---
|
||
title: ExpectationFactory
|
||
description: API reference for qiskit.opflow.expectations.ExpectationFactory
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.opflow.expectations.ExpectationFactory
|
||
---
|
||
|
||
# ExpectationFactory
|
||
|
||
<Class id="qiskit.opflow.expectations.ExpectationFactory" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.45/qiskit/opflow/expectations/expectation_factory.py" signature="qiskit.opflow.expectations.ExpectationFactory" modifiers="class">
|
||
Bases: [`object`](https://docs.python.org/3/library/functions.html#object "(in Python v3.12)")
|
||
|
||
Deprecated: factory class for convenient automatic selection of an Expectation based on the Operator to be converted and backend used to sample the expectation value.
|
||
|
||
## Methods
|
||
|
||
### build
|
||
|
||
<Function id="qiskit.opflow.expectations.ExpectationFactory.build" signature="build(operator, backend=None, include_custom=True)" modifiers="static">
|
||
A factory method for convenient automatic selection of an Expectation based on the Operator to be converted and backend used to sample the expectation value.
|
||
|
||
<Admonition title="Deprecated since version 0.24.0" type="danger">
|
||
The method `qiskit.opflow.expectations.expectation_factory.ExpectationFactory.build()` is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. For code migration guidelines, visit [https://qisk.it/opflow\_migration](https://qisk.it/opflow_migration).
|
||
</Admonition>
|
||
|
||
**Parameters**
|
||
|
||
* **operator** ([*OperatorBase*](qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")) – The Operator whose expectation value will be taken.
|
||
* **backend** ([*Backend*](qiskit.providers.Backend "qiskit.providers.backend.Backend") *|*[*QuantumInstance*](qiskit.utils.QuantumInstance "qiskit.utils.quantum_instance.QuantumInstance") *| None*) – The backend which will be used to sample the expectation value.
|
||
* **include\_custom** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.12)")) – Whether the factory will include the (Aer) specific custom expectations if their behavior against the backend might not be as expected. For instance when using Aer qasm\_simulator with paulis the Aer snapshot can be used but the outcome lacks shot noise and hence does not intuitively behave overall as people might expect when choosing a qasm\_simulator. It is however fast as long as the more state vector like behavior is acceptable.
|
||
|
||
**Returns**
|
||
|
||
The expectation algorithm which best fits the Operator and backend.
|
||
|
||
**Raises**
|
||
|
||
[**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.12)") – If operator is not of a composition for which we know the best Expectation method.
|
||
|
||
**Return type**
|
||
|
||
[*ExpectationBase*](qiskit.opflow.expectations.ExpectationBase "qiskit.opflow.expectations.expectation_base.ExpectationBase")
|
||
</Function>
|
||
</Class>
|
||
|