Skip to content

Commit

Permalink
Aer using Provider ABC
Browse files Browse the repository at this point in the history
  • Loading branch information
1ucian0 committed Jul 1, 2024
1 parent 5124403 commit 884d394
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
""" Test of GenericBackendV2 backend"""

import math
import warnings

from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister, transpile
from qiskit.providers.fake_provider import GenericBackendV2
Expand Down Expand Up @@ -116,7 +117,11 @@ def test_run(self):

backend = GenericBackendV2(num_qubits=5, basis_gates=["cx", "id", "rz", "sx", "x"])
tqc = transpile(qc, backend=backend, optimization_level=3, seed_transpiler=42)
result = backend.run(tqc, seed_simulator=42, shots=1000).result()
with warnings.catch_warnings():
# TODO remove this catch once Aer stops using Provider ABC
# https://github.com/Qiskit/qiskit-aer/pull/2184
warnings.simplefilter("ignore", category=DeprecationWarning)
result = backend.run(tqc, seed_simulator=42, shots=1000).result()
counts = result.get_counts()

self.assertTrue(math.isclose(counts["00000"], 500, rel_tol=0.1))
Expand Down
12 changes: 8 additions & 4 deletions test/python/transpiler/test_sabre_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,19 @@ def test_no_infinite_loop(self, method):

# Assert that the same keys are produced by a simulation - this is a test that the inserted
# swaps route the qubits correctly.
if not optionals.HAS_AER:
return
with warnings.catch_warnings():
# TODO remove Aer stops using Provider Qiskit class
warnings.simplefilter("ignore", category=DeprecationWarning)
if not optionals.HAS_AER:
return

from qiskit_aer import Aer

sim = Aer.get_backend("aer_simulator")
with warnings.catch_warnings():
# TODO remove this catch once Aer stops using QobjDictField
# TODO remove this catch once Aer stops using QobjDictField and Provider ABC
# https://github.com/Qiskit/qiskit-aer/pull/2184
warnings.simplefilter("ignore", category=DeprecationWarning)
sim = Aer.get_backend("aer_simulator")
in_results = sim.run(qc, shots=4096).result().get_counts()
out_results = sim.run(routed, shots=4096).result().get_counts()
self.assertEqual(set(in_results), set(out_results))
Expand Down

0 comments on commit 884d394

Please sign in to comment.