-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate PrimitivesV1 and their utils #11490
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,15 +24,11 @@ | |
from qiskit.exceptions import QiskitError | ||
from qiskit.quantum_info import Statevector | ||
from qiskit.quantum_info.operators.base_operator import BaseOperator | ||
from qiskit.utils.deprecation import deprecate_func | ||
|
||
from .base import BaseEstimator, EstimatorResult | ||
from .primitive_job import PrimitiveJob | ||
from .utils import ( | ||
_circuit_key, | ||
_observable_key, | ||
bound_circuit_to_instruction, | ||
init_observable, | ||
) | ||
from .utils import _circuit_key, _observable_key, bound_circuit_to_instruction, init_observable | ||
|
||
|
||
class Estimator(BaseEstimator[PrimitiveJob[EstimatorResult]]): | ||
|
@@ -51,6 +47,7 @@ class Estimator(BaseEstimator[PrimitiveJob[EstimatorResult]]): | |
this option is ignored. | ||
""" | ||
|
||
@deprecate_func(since="0.46.0", additional_msg="Use StatevectorEstimator instead.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the estimator V2 PR, it looks like the new class is also called |
||
def __init__(self, *, options: dict | None = None): | ||
""" | ||
Args: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
from qiskit.exceptions import QiskitError | ||
from qiskit.quantum_info import Statevector | ||
from qiskit.result import QuasiDistribution | ||
from qiskit.utils.deprecation import deprecate_func | ||
|
||
from .base import BaseSampler, SamplerResult | ||
from .primitive_job import PrimitiveJob | ||
|
@@ -52,6 +53,7 @@ class Sampler(BaseSampler[PrimitiveJob[SamplerResult]]): | |
option is ignored. | ||
""" | ||
|
||
@deprecate_func(since="0.46.0", additional_msg="Use StatevectorSampler instead.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as with the Estimator. |
||
def __init__(self, *, options: dict | None = None): | ||
""" | ||
Args: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,11 +22,13 @@ | |
from qiskit.circuit import Instruction, QuantumCircuit | ||
from qiskit.circuit.bit import Bit | ||
from qiskit.circuit.library.data_preparation import Initialize | ||
from qiskit.quantum_info import SparsePauliOp, Statevector, PauliList | ||
from qiskit.quantum_info import PauliList, SparsePauliOp, Statevector | ||
from qiskit.quantum_info.operators.base_operator import BaseOperator | ||
from qiskit.quantum_info.operators.symplectic.base_pauli import BasePauli | ||
from qiskit.utils.deprecation import deprecate_func | ||
|
||
|
||
@deprecate_func(since="0.46.0") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the deprecation is with no replacement, we usually add a small message explaining it. |
||
def init_circuit(state: QuantumCircuit | Statevector) -> QuantumCircuit: | ||
"""Initialize state by converting the input to a quantum circuit. | ||
|
||
|
@@ -45,6 +47,7 @@ def init_circuit(state: QuantumCircuit | Statevector) -> QuantumCircuit: | |
return qc | ||
|
||
|
||
@deprecate_func(since="0.46.0") | ||
def init_observable(observable: BaseOperator | str) -> SparsePauliOp: | ||
"""Initialize observable by converting the input to a :class:`~qiskit.quantum_info.SparsePauliOp`. | ||
|
||
|
@@ -73,6 +76,7 @@ def init_observable(observable: BaseOperator | str) -> SparsePauliOp: | |
return SparsePauliOp(observable) | ||
|
||
|
||
@deprecate_func(since="0.46.0") | ||
def final_measurement_mapping(circuit: QuantumCircuit) -> dict[int, int]: | ||
"""Return the final measurement mapping for the circuit. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
deprecations: | ||
- | | ||
PrimitivesV1 has been deprecated. Use PrimitivesV2 instead. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if people would understand what "PrimitivesV1" are, adding a list of what the deprecated classes are would help. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would help to show the path of the new
PrimitiveResult
class. From #11227 I take that would be: