Skip to content

Commit

Permalink
Handle deprecation of FakeBackendV2 in Qiskit 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wshanks committed Feb 3, 2024
1 parent 08ea54c commit 6558622
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions qiskit_experiments/framework/backend_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,24 @@ class unifies data access for various data fields.
"""
from qiskit.providers.models import PulseBackendConfiguration
from qiskit.providers import BackendV1, BackendV2
from qiskit.providers.fake_provider import fake_backend, FakeBackendV2, FakeBackend
from qiskit.providers.fake_provider import FakeBackendV2, FakeBackend

# One of the FakeBackendV2's was moved from qiskit to qiskit-ibm-runtime. Check
# both packages until dropping support for qiskit<1
try:
from qiskit.providers.fake_provider.fake_backend import FakeBackendV2 as QiskitFakeBackendV2
except ImportError:

class QiskitFakeBackendV2:
pass


try:
from qiskit_ibm_runtime.fake_provider.fake_backend import FakeBackendV2 as RuntimeFakeBackendV2
except ImportError:

class RuntimeFakeBackendV2:
pass


class BackendData:
Expand Down Expand Up @@ -255,7 +272,9 @@ def is_simulator(self):
if self._backend.configuration().simulator or isinstance(self._backend, FakeBackend):
return True
if self._v2:
if isinstance(self._backend, (FakeBackendV2, fake_backend.FakeBackendV2)):
if isinstance(
self._backend, (FakeBackendV2, QiskitFakeBackendV2, RuntimeFakeBackendV2)
):
return True

return False
Expand Down

0 comments on commit 6558622

Please sign in to comment.