From 83c14459c76da0f868a004b9f2318beb490672d9 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Wed, 8 May 2024 12:31:28 +0900 Subject: [PATCH] Fix issue 2084 again (#2119) * Fix issue 2084 again * format * fix test * fix test --- qiskit_aer/backends/aerbackend.py | 2 +- releasenotes/notes/fix_issue2084-632a829da1a8dfc5.yaml | 7 +++++++ test/terra/primitives/test_sampler.py | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix_issue2084-632a829da1a8dfc5.yaml diff --git a/qiskit_aer/backends/aerbackend.py b/qiskit_aer/backends/aerbackend.py index ed8059a57b..9d8f14e946 100644 --- a/qiskit_aer/backends/aerbackend.py +++ b/qiskit_aer/backends/aerbackend.py @@ -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): diff --git a/releasenotes/notes/fix_issue2084-632a829da1a8dfc5.yaml b/releasenotes/notes/fix_issue2084-632a829da1a8dfc5.yaml new file mode 100644 index 0000000000..6fd3439247 --- /dev/null +++ b/releasenotes/notes/fix_issue2084-632a829da1a8dfc5.yaml @@ -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. + diff --git a/test/terra/primitives/test_sampler.py b/test/terra/primitives/test_sampler.py index 0bb0bb1bb6..2ecc27c528 100644 --- a/test/terra/primitives/test_sampler.py +++ b/test/terra/primitives/test_sampler.py @@ -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()