Skip to content

Commit

Permalink
Fix bug with retrieving fake backends (#1402)
Browse files Browse the repository at this point in the history
* bug fix w retrieving fake backend

* Move test
  • Loading branch information
kt474 authored Feb 23, 2024
1 parent 08c419b commit 88da374
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion qiskit_ibm_runtime/fake_provider/fake_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def backend(self, name=None, **kwargs): # type: ignore
"""
backend = self._backends[0]
if name:
filtered_backends = [backend for backend in self._backends if backend.name() == name]
filtered_backends = [backend for backend in self._backends if backend.name == name]
if not filtered_backends:
raise QiskitBackendNotFoundError()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fixed a bug where retrieving a fake backend through ``FakeProviderForBackendV2.backend()``
would result in a type error.
9 changes: 8 additions & 1 deletion test/unit/fake_provider/test_fake_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, transpile
from qiskit.utils import optionals

from qiskit_ibm_runtime.fake_provider import FakeAthens, FakePerth
from qiskit_ibm_runtime.fake_provider import FakeAthens, FakePerth, FakeProviderForBackendV2
from ...ibm_test_case import IBMTestCase


Expand Down Expand Up @@ -60,3 +60,10 @@ def test_fake_backend_v2_noise_model_always_present(self):
res = backend.run(qc, shots=1000).result().get_counts()
# Assert noise was present and result wasn't ideal
self.assertNotEqual(res, {"1": 1000})

def test_retrieving_single_backend(self):
"""Test retrieving a single backend."""
provider = FakeProviderForBackendV2()
backend_name = "fake_jakarta"
backend = provider.backend(backend_name)
self.assertEqual(backend.name, backend_name)

0 comments on commit 88da374

Please sign in to comment.