Skip to content

Commit

Permalink
remove deprecated Provider ABC Qiskit#12145
Browse files Browse the repository at this point in the history
  • Loading branch information
1ucian0 committed Nov 13, 2024
1 parent 5099f6e commit e8d6ba9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
25 changes: 23 additions & 2 deletions qiskit/providers/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, configuration, provider=None, **fields):
Args:
configuration (BackendConfiguration): A backend configuration
object for the backend object.
provider (qiskit.providers.Provider): Optionally, the provider
provider: Optionally, the provider
object that this Backend comes from.
fields: kwargs for the values to use to override the default
options.
Expand Down Expand Up @@ -158,6 +158,14 @@ def properties(self):
"""
return None

def provider(self):
"""Return the backend provider.
Returns:
provider: the provider responsible for the backend.
"""
return self._provider

def status(self):
"""Return the backend status.
Expand Down Expand Up @@ -242,7 +250,7 @@ class QubitProperties:
This class provides the optional properties that a backend can provide for
a qubit. These represent the set of qubit properties that Qiskit can
currently work with if present. However, if your backend provides additional
currently work with if present. However if your backend provides additional
properties of qubits you should subclass this to add additional custom
attributes for those custom/additional properties provided by the backend.
"""
Expand Down Expand Up @@ -318,6 +326,7 @@ class BackendV2(Backend, ABC):

def __init__(
self,
provider=None,
name: str = None,
description: str = None,
online_date: datetime.datetime = None,
Expand All @@ -327,6 +336,8 @@ def __init__(
"""Initialize a BackendV2 based backend
Args:
provider: An optional backwards reference to the provider
object that the backend is from
name: An optional name for the backend
description: An optional description of the backend
online_date: An optional datetime the backend was brought online
Expand All @@ -345,6 +356,7 @@ def __init__(
"""

self._options = self._default_options()
self._provider = provider
if fields:
for field in fields:
if field not in self._options.data:
Expand Down Expand Up @@ -617,6 +629,15 @@ def options(self):
"""
return self._options

@property
def provider(self):
"""Return the backend provider.
Returns:
provider: the provider responsible for the backend.
"""
return self._provider

@abstractmethod
def run(self, run_input, **options):
"""Run on the backend.
Expand Down
4 changes: 4 additions & 0 deletions qiskit/providers/basic_provider/basic_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ class BasicSimulator(BackendV2):

def __init__(
self,
provider=None,
target: Target | None = None,
**fields,
) -> None:
"""
Args:
provider: An optional backwards reference to the provider object that the backend
is from.
target: An optional target to configure the simulator.
fields: kwargs for the values to use to override the default
options.
Expand All @@ -88,6 +91,7 @@ def __init__(
"""

super().__init__(
provider=provider,
name="basic_simulator",
description="A python simulator for quantum experiments",
backend_version="0.1",
Expand Down
3 changes: 1 addition & 2 deletions test/utils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ def tearDown(self):
# due to importing the instances from the top-level qiskit namespace.
from qiskit.providers.basic_provider import BasicProvider

with self.assertWarns(DeprecationWarning):
BasicProvider()._backends = BasicProvider()._verify_backends()
BasicProvider()._backends = BasicProvider()._verify_backends()

def assertQuantumCircuitEqual(self, qc1, qc2, msg=None):
"""Extra assertion method to give a better error message when two circuits are unequal."""
Expand Down

0 comments on commit e8d6ba9

Please sign in to comment.