Skip to content

Commit

Permalink
Revert base class change for Sampler and Estimator V1 implementations…
Browse files Browse the repository at this point in the history
… to avoid breaking instance checks. (#12871) (#12873)

(cherry picked from commit 919cfd3)

Co-authored-by: Elena Peña Tapia <[email protected]>
  • Loading branch information
mergify[bot] and ElePT authored Jul 31, 2024
1 parent a361f6c commit 838751e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
15 changes: 8 additions & 7 deletions qiskit/primitives/backend_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
)
from qiskit.utils.deprecation import deprecate_func

from .base import BaseEstimatorV1, EstimatorResult
from .base import BaseEstimator, EstimatorResult
from .primitive_job import PrimitiveJob
from .utils import _circuit_key, _observable_key, init_observable

Expand Down Expand Up @@ -88,17 +88,18 @@ def _prepare_counts(results: list[Result]):
return counts


class BackendEstimator(BaseEstimatorV1[PrimitiveJob[EstimatorResult]]):
class BackendEstimator(BaseEstimator[PrimitiveJob[EstimatorResult]]):
"""Evaluates expectation value using Pauli rotation gates.
The :class:`~.BackendEstimator` class is a generic implementation of the
:class:`~.BaseEstimatorV1` interface that is used to wrap a :class:`~.BackendV2`
(or :class:`~.BackendV1`) object in the :class:`~.BaseEstimatorV1` API. It
:class:`~.BaseEstimator` (V1) interface that is used to wrap a :class:`~.BackendV2`
(or :class:`~.BackendV1`) object in the :class:`~.BaseEstimator` V1 API. It
facilitates using backends that do not provide a native
:class:`~.BaseEstimatorV1` implementation in places that work with
:class:`~.BaseEstimatorV1`.
:class:`~.BaseEstimator` V1 implementation in places that work with
:class:`~.BaseEstimator` V1.
However, if you're using a provider that has a native implementation of
:class:`~.BaseEstimatorV1` or :class:`~.BaseEstimatorV2`, it is a better
:class:`~.BaseEstimatorV1` ( :class:`~.BaseEstimator`) or
:class:`~.BaseEstimatorV2`, it is a better
choice to leverage that native implementation as it will likely include
additional optimizations and be a more efficient implementation.
The generic nature of this class precludes doing any provider- or
Expand Down
13 changes: 7 additions & 6 deletions qiskit/primitives/backend_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,23 @@
from qiskit.utils.deprecation import deprecate_func

from .backend_estimator import _prepare_counts, _run_circuits
from .base import BaseSamplerV1, SamplerResult
from .base import BaseSampler, SamplerResult
from .primitive_job import PrimitiveJob
from .utils import _circuit_key


class BackendSampler(BaseSamplerV1[PrimitiveJob[SamplerResult]]):
"""A :class:`~.BaseSamplerV1` implementation that provides a wrapper for
class BackendSampler(BaseSampler[PrimitiveJob[SamplerResult]]):
"""A :class:`~.BaseSampler` (V1) implementation that provides a wrapper for
leveraging the Sampler V1 interface from any backend.
This class provides a sampler interface from any backend and doesn't do
any measurement mitigation, it just computes the probability distribution
from the counts. It facilitates using backends that do not provide a
native :class:`~.BaseSamplerV1` implementation in places that work with
:class:`~.BaseSamplerV1`.
native :class:`~.BaseSampler` V1 implementation in places that work with
:class:`~.BaseSampler` V1.
However, if you're using a provider that has a native implementation of
:class:`~.BaseSamplerV1` or :class:`~.BaseESamplerV2`, it is a better
:class:`~.BaseSamplerV1` ( :class:`~.BaseSampler`) or
:class:`~.BaseESamplerV2`, it is a better
choice to leverage that native implementation as it will likely include
additional optimizations and be a more efficient implementation.
The generic nature of this class precludes doing any provider- or
Expand Down
6 changes: 3 additions & 3 deletions qiskit/primitives/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from qiskit.quantum_info.operators.base_operator import BaseOperator
from qiskit.utils.deprecation import deprecate_func

from .base import BaseEstimatorV1, EstimatorResult
from .base import BaseEstimator, EstimatorResult
from .primitive_job import PrimitiveJob
from .utils import (
_circuit_key,
Expand All @@ -36,9 +36,9 @@
)


class Estimator(BaseEstimatorV1[PrimitiveJob[EstimatorResult]]):
class Estimator(BaseEstimator[PrimitiveJob[EstimatorResult]]):
"""
Reference implementation of :class:`BaseEstimatorV1`.
Reference implementation of :class:`BaseEstimator` (V1).
:Run Options:
Expand Down
6 changes: 3 additions & 3 deletions qiskit/primitives/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from qiskit.result import QuasiDistribution
from qiskit.utils.deprecation import deprecate_func

from .base import BaseSamplerV1, SamplerResult
from .base import BaseSampler, SamplerResult
from .primitive_job import PrimitiveJob
from .utils import (
_circuit_key,
Expand All @@ -36,11 +36,11 @@
)


class Sampler(BaseSamplerV1[PrimitiveJob[SamplerResult]]):
class Sampler(BaseSampler[PrimitiveJob[SamplerResult]]):
"""
Sampler V1 class.
:class:`~Sampler` is a reference implementation of :class:`~BaseSamplerV1`.
:class:`~Sampler` is a reference implementation of :class:`~BaseSampler` (V1).
:Run Options:
Expand Down

0 comments on commit 838751e

Please sign in to comment.