Skip to content

Commit

Permalink
Stop using deprecated BaseBackend class
Browse files Browse the repository at this point in the history
The BaseBackend class in qiskit-terra (along with the rest of the legacy
provider interface) is deprecated and being removed soon in
Qiskit/qiskit#7886. To avoid potential compatibility issues or
deprecation warnings we shouldn't be using this class anymore. This
commit removes the last 2 uses of these legacy classes to avoid issues
moving forward.
  • Loading branch information
mtreinish committed Apr 5, 2022
1 parent 73b29ad commit 4a07912
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions qiskit/providers/aer/noise/noise_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from numpy import ndarray

from qiskit.circuit import Instruction, Delay
from qiskit.providers import BaseBackend, BackendV1, BackendV2
from qiskit.providers.exceptions import BackendPropertyError
from qiskit.providers.models import BackendProperties
from qiskit.transpiler import PassManager
Expand Down Expand Up @@ -303,10 +302,14 @@ def from_backend(cls, backend,
Raises:
NoiseError: If the input backend is not valid.
"""
if isinstance(backend, BackendV2):
backend_interface_version = getattr(backend, "version", None)
if not isinstance(backend_interface_version, int):
backend_interface_version = 0

if backend_interface_version == 2:
raise NoiseError(
"NoiseModel.from_backend does not currently support V2 Backends.")
if isinstance(backend, (BaseBackend, BackendV1)):
if backend_interface_version <= 1:
properties = backend.properties()
configuration = backend.configuration()
basis_gates = configuration.basis_gates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from warnings import warn
from collections import OrderedDict
from qiskit.providers import BaseBackend, Backend
from qiskit.providers import Backend
from ...aererror import AerError
from .hamiltonian_model import HamiltonianModel

Expand Down Expand Up @@ -94,7 +94,7 @@ def from_backend(cls, backend, subsystem_list=None):
AerError: If channel or u_channel_lo are invalid.
"""

if not isinstance(backend, (BaseBackend, Backend)):
if not isinstance(backend, Backend):
raise AerError("{} is not a Qiskit backend".format(backend))

# get relevant information from backend
Expand Down

0 comments on commit 4a07912

Please sign in to comment.