Skip to content

Commit 0047a81

Browse files
committed
Remove bugged tests in backend v1 primitives implementation
Two primitives tests were returning incorrect results after being rewritten to use IfElseOp instead of c_if. This is likely pointing to a bug in the primitive implementation or an aer bug. But since those classes are deprecated and the tests will be removed as part of the larger backend v1 primitive implementation removal in Qiskit#13877 anyway this commit opts to just delete these tests now.
1 parent bb50647 commit 0047a81

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

test/python/primitives/test_backend_estimator.py

-23
Original file line numberDiff line numberDiff line change
@@ -483,29 +483,6 @@ def test_circuit_with_measurement(self):
483483
result = estimator.run(bell, observable).result()
484484
self.assertAlmostEqual(result.values[0], 1, places=1)
485485

486-
@unittest.skipUnless(optionals.HAS_AER, "qiskit-aer is required to run this test")
487-
def test_dynamic_circuit(self):
488-
"""Test estimator with a dynamic circuit"""
489-
from qiskit_aer import AerSimulator
490-
491-
qc = QuantumCircuit(2, 1)
492-
with qc.for_loop(range(5)):
493-
qc.h(0)
494-
qc.cx(0, 1)
495-
qc.measure(1, 0)
496-
with qc.if_test((0, True)):
497-
qc.break_loop()
498-
499-
observable = SparsePauliOp("IZ")
500-
501-
backend = AerSimulator()
502-
backend.set_options(seed_simulator=15)
503-
with self.assertWarns(DeprecationWarning):
504-
estimator = BackendEstimator(backend, skip_transpilation=True)
505-
estimator.set_transpile_options(seed_transpiler=15)
506-
result = estimator.run(qc, observable).result()
507-
self.assertAlmostEqual(float(result.values[0]), -1.0, places=1)
508-
509486

510487
if __name__ == "__main__":
511488
unittest.main()

test/python/primitives/test_backend_sampler.py

-23
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from qiskit.providers.basic_provider import BasicSimulator
2727
from qiskit.providers.fake_provider import Fake7QPulseV1, GenericBackendV2
2828
from qiskit.transpiler import PassManager
29-
from qiskit.utils import optionals
3029
from test import QiskitTestCase # pylint: disable=wrong-import-order
3130
from test import combine # pylint: disable=wrong-import-order
3231
from test.python.transpiler._dummy_passes import DummyAP # pylint: disable=wrong-import-order
@@ -383,28 +382,6 @@ def test_primitive_job_size_limit_backend_v1(self):
383382
self.assertDictAlmostEqual(result.quasi_dists[0], {0: 1}, 0.1)
384383
self.assertDictAlmostEqual(result.quasi_dists[1], {1: 1}, 0.1)
385384

386-
@unittest.skipUnless(optionals.HAS_AER, "qiskit-aer is required to run this test")
387-
def test_circuit_with_dynamic_circuit(self):
388-
"""Test BackendSampler with QuantumCircuit with a dynamic circuit"""
389-
from qiskit_aer import Aer
390-
391-
qc = QuantumCircuit(2, 1)
392-
393-
with qc.for_loop(range(5)):
394-
qc.h(0)
395-
qc.cx(0, 1)
396-
qc.measure(0, 0)
397-
with qc.if_test((0, True)):
398-
qc.break_loop()
399-
400-
with self.assertWarns(DeprecationWarning):
401-
backend = Aer.get_backend("aer_simulator")
402-
sampler = BackendSampler(backend, skip_transpilation=True)
403-
sampler.set_options(seed_simulator=15)
404-
sampler.set_transpile_options(seed_transpiler=15)
405-
result = sampler.run(qc).result()
406-
self.assertDictAlmostEqual(result.quasi_dists[0], {0: 0.021484375, 1: 0.978515625})
407-
408385
def test_sequential_run(self):
409386
"""Test sequential run."""
410387
backend = GenericBackendV2(7, basis_gates=["cx", "u1", "u2", "u3"], seed=42)

0 commit comments

Comments
 (0)