From f0f7897d60fdb9ba49bd2f92b387f71a138fca7e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 12:43:33 -0400 Subject: [PATCH] Use `BaseSamplerV1` with explicit version (#653) (#654) This change is motivated by the following warning: > DeprecationWarning: The class ``qiskit.primitives.base.base_sampler.BaseSampler`` > is deprecated as of qiskit 1.2. It will be removed no earlier > than 3 months after the release date. The `BaseSampler` class is > a type alias for the `BaseSamplerV1` interface that has been > deprecated in favor of explicitly versioned interface classes. > It is recommended to migrate all implementations to use > `BaseSamplerV2`. However, for implementations incompatible with > `BaseSamplerV2`, `BaseSampler` can be replaced with the explicitly > versioned `BaseSamplerV1` class. Related to #551 and #506. (cherry picked from commit a9bfc91b9855a78fd6b0dd9ffadcd03069808fc7) Co-authored-by: Jim Garrison --- circuit_knitting/utils/simulation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/circuit_knitting/utils/simulation.py b/circuit_knitting/utils/simulation.py index d1946afba..c66b472a3 100644 --- a/circuit_knitting/utils/simulation.py +++ b/circuit_knitting/utils/simulation.py @@ -29,7 +29,7 @@ import numpy as np from qiskit.circuit import QuantumCircuit from qiskit.quantum_info import Statevector, Operator -from qiskit.primitives.base import BaseSampler, SamplerResult +from qiskit.primitives.base import BaseSamplerV1, SamplerResult from qiskit.primitives.primitive_job import PrimitiveJob from qiskit.result import QuasiDistribution @@ -128,7 +128,7 @@ def simulate_statevector_outcomes(qc: QuantumCircuit, /) -> dict[int, float]: return {outcome: sum(prob for prob, _ in svs) for outcome, svs in current.items()} -class ExactSampler(BaseSampler): +class ExactSampler(BaseSamplerV1): """Sampler which returns exact probabilities for each possible outcome. This sampler supports: