Skip to content

Commit

Permalink
Fix issue 2084 again (#2119)
Browse files Browse the repository at this point in the history
* Fix issue 2084 again

* format

* fix test

* fix test
  • Loading branch information
doichanj authored May 8, 2024
1 parent 7b93719 commit 83c1445
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion qiskit_aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def target(self):

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):
Expand Down
7 changes: 7 additions & 0 deletions releasenotes/notes/fix_issue2084-632a829da1a8dfc5.yaml
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions test/terra/primitives/test_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ def test_multiple_cregs(self):
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()

0 comments on commit 83c1445

Please sign in to comment.