Fix issue 2084 again (#2119)

* Fix issue 2084 again

* format

* fix test

* fix test
This commit is contained in:
Jun Doi 2024-05-08 12:31:28 +09:00 committed by GitHub
parent 7b9371914d
commit 83c14459c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View File

@ -352,7 +352,7 @@ class AerBackend(Backend, ABC):
def set_max_qubits(self, max_qubits):
"""Set maximun number of qubits to be used for this backend."""
if self._target is not None:
if self._target is None:
self._configuration.n_qubits = max_qubits
def clear_options(self):

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixed issue #2084 again. `backend.set_max_qubits` was not
properly implemented.
Also added test case to test this issue.

View File

@ -270,6 +270,16 @@ class TestSampler(QiskitAerTestCase):
result = Sampler().run(qc, shots=100).result()
self.assertDictAlmostEqual(result.quasi_dists[0], {0: 1})
def test_truncate_large_circuit(self):
"""Test trancate large circuit in transplier"""
sampler = Sampler()
qc = QuantumCircuit(100, 2)
qc.h(98)
qc.cx(98, 99)
qc.measure([98, 99], [0, 1])
result = sampler.run(qc).result()
self.assertIsInstance(result, SamplerResult)
if __name__ == "__main__":
unittest.main()