From c1297b1d22f3098f0eb71f46a82e692a0be96778 Mon Sep 17 00:00:00 2001 From: Gadi Date: Tue, 18 Jun 2019 17:06:36 +0300 Subject: [PATCH 01/11] Initial version of the noise model inserter --- .../aer/noise/utils/noise_model_inserter.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 qiskit/providers/aer/noise/utils/noise_model_inserter.py diff --git a/qiskit/providers/aer/noise/utils/noise_model_inserter.py b/qiskit/providers/aer/noise/utils/noise_model_inserter.py new file mode 100644 index 0000000000..a9f2c1f323 --- /dev/null +++ b/qiskit/providers/aer/noise/utils/noise_model_inserter.py @@ -0,0 +1,37 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2019. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. +""" +Noise model inserter module +The goal of this module is to add QuantumError gates (Kraus gates) to a circuit +based on a given noise model. The resulting circuit cannot be ran on a quantum computer +but can be handled correctly by simulators +""" + +def add_errors(circuit, noise_model): + """ + This function gets a circuit and a noise model and returns a new circuit + with the errors from the noise model inserted as Kraus gates in the new circuit + Args: + circuit (QuantumCircuit): The circuit to add the errors to + noise_model (NoiseModel): The noise model containing the errors to add + Returns: + QuantumCircuit: The new circuit with the added Kraus gates + """ + error_dict = dict([(name, qubit_dict) for (name, qubit_dict) in noise_model._default_quantum_errors.items()]) + result_circuit = circuit.copy(name=circuit.name + '_with_errors') + result_circuit.data = [] + for inst, qargs, cargs in circuit.data: + result_circuit.data.append((inst, qargs, cargs)) + if inst.name in error_dict.keys(): + error = error_dict[inst.name] + result_circuit.append(error.to_instruction(), qargs) + return result_circuit \ No newline at end of file From b5fa11a99e52ec366180bd417c0c9a294346d90b Mon Sep 17 00:00:00 2001 From: Gadi Date: Wed, 19 Jun 2019 10:17:44 +0300 Subject: [PATCH 02/11] Style --- qiskit/providers/aer/noise/utils/noise_model_inserter.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qiskit/providers/aer/noise/utils/noise_model_inserter.py b/qiskit/providers/aer/noise/utils/noise_model_inserter.py index a9f2c1f323..053bca7af6 100644 --- a/qiskit/providers/aer/noise/utils/noise_model_inserter.py +++ b/qiskit/providers/aer/noise/utils/noise_model_inserter.py @@ -16,6 +16,7 @@ but can be handled correctly by simulators """ + def add_errors(circuit, noise_model): """ This function gets a circuit and a noise model and returns a new circuit @@ -26,7 +27,8 @@ def add_errors(circuit, noise_model): Returns: QuantumCircuit: The new circuit with the added Kraus gates """ - error_dict = dict([(name, qubit_dict) for (name, qubit_dict) in noise_model._default_quantum_errors.items()]) + errors = noise_model._default_quantum_errors.items() + error_dict = {name: qubit_dict for (name, qubit_dict) in errors} result_circuit = circuit.copy(name=circuit.name + '_with_errors') result_circuit.data = [] for inst, qargs, cargs in circuit.data: @@ -34,4 +36,4 @@ def add_errors(circuit, noise_model): if inst.name in error_dict.keys(): error = error_dict[inst.name] result_circuit.append(error.to_instruction(), qargs) - return result_circuit \ No newline at end of file + return result_circuit From f861d23ecb8d0e1b9e3870cec1e27d2ba45f2b1d Mon Sep 17 00:00:00 2001 From: Gadi Date: Tue, 16 Jul 2019 12:17:08 +0300 Subject: [PATCH 03/11] Initial testing --- qiskit/providers/aer/noise/utils/__init__.py | 1 + test/terra/noise/test_noise_inserter.py | 71 ++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 test/terra/noise/test_noise_inserter.py diff --git a/qiskit/providers/aer/noise/utils/__init__.py b/qiskit/providers/aer/noise/utils/__init__.py index deae225482..c214cbf0e2 100644 --- a/qiskit/providers/aer/noise/utils/__init__.py +++ b/qiskit/providers/aer/noise/utils/__init__.py @@ -18,3 +18,4 @@ from .noise_transformation import NoiseTransformer from .noise_transformation import approximate_quantum_error from .noise_transformation import approximate_noise_model +from .noise_model_inserter import add_errors \ No newline at end of file diff --git a/test/terra/noise/test_noise_inserter.py b/test/terra/noise/test_noise_inserter.py new file mode 100644 index 0000000000..9561eeaa35 --- /dev/null +++ b/test/terra/noise/test_noise_inserter.py @@ -0,0 +1,71 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2018, 2019. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. +""" +noise_model_inserter module tests +""" + +from qiskit import QuantumRegister, QuantumCircuit +from qiskit.providers.aer.noise.utils import add_errors +from qiskit.providers.aer.noise import NoiseModel +from qiskit.providers.aer.noise.errors.standard_errors import pauli_error +import unittest + +class TestNoiseInserter(unittest.TestCase): + def test_no_noise(self): + qr = QuantumRegister(3, 'qr') + circuit = QuantumCircuit(qr) + circuit.x(qr[0]) + circuit.y(qr[1]) + circuit.z(qr[2]) + + target_circuit = QuantumCircuit(qr) + target_circuit.x(qr[0]) + target_circuit.y(qr[1]) + target_circuit.z(qr[2]) + + noise_model = NoiseModel() #empty + + result_circuit = add_errors(circuit, noise_model) + + self.assertEqual(target_circuit, result_circuit) + + def test_simple_noise(self): + qr = QuantumRegister(3, 'qr') + circuit = QuantumCircuit(qr) + circuit.x(qr[0]) + circuit.y(qr[1]) + circuit.z(qr[2]) + + error_x = pauli_error([('Y', 0.25), ('I', 0.75)]) + error_y = pauli_error([('X', 0.35), ('Z', 0.65)]) + noise_model = NoiseModel() + noise_model.add_all_qubit_quantum_error(error_x, 'x') + noise_model.add_all_qubit_quantum_error(error_y, 'y') + + target_circuit = QuantumCircuit(qr) + target_circuit.x(qr[0]) + target_circuit.append(error_x.to_instruction(), [qr[0]]) + target_circuit.y(qr[1]) + target_circuit.append(error_y.to_instruction(), [qr[1]]) + target_circuit.z(qr[2]) + + result_circuit = add_errors(circuit, noise_model) + + self.assertEqual(target_circuit, result_circuit) + +if __name__ == '__main__': + qr = QuantumRegister(1, 'qr') + circuit = QuantumCircuit(qr) + error = pauli_error([('X', 0.25), ('I', 0.75)]) + circuit.append(error.to_instruction(), [qr[0]]) + circuit == circuit + #unittest.main() \ No newline at end of file From 77da1f67c59862dbb3ef0949785bb2c3764626df Mon Sep 17 00:00:00 2001 From: Gadi Date: Wed, 17 Jul 2019 09:13:38 +0300 Subject: [PATCH 04/11] Tests fix --- test/terra/noise/test_noise_inserter.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/terra/noise/test_noise_inserter.py b/test/terra/noise/test_noise_inserter.py index 9561eeaa35..971ab19d89 100644 --- a/test/terra/noise/test_noise_inserter.py +++ b/test/terra/noise/test_noise_inserter.py @@ -63,9 +63,4 @@ def test_simple_noise(self): self.assertEqual(target_circuit, result_circuit) if __name__ == '__main__': - qr = QuantumRegister(1, 'qr') - circuit = QuantumCircuit(qr) - error = pauli_error([('X', 0.25), ('I', 0.75)]) - circuit.append(error.to_instruction(), [qr[0]]) - circuit == circuit - #unittest.main() \ No newline at end of file + unittest.main() \ No newline at end of file From 2588a1ffbae5e5dca0173b155346b47756f889c7 Mon Sep 17 00:00:00 2001 From: Gadi Date: Thu, 18 Jul 2019 14:16:49 +0300 Subject: [PATCH 05/11] Transpilation is now working (but optional) --- .../aer/noise/utils/noise_model_inserter.py | 12 ++++++--- test/terra/noise/test_noise_inserter.py | 26 ++++++++++++++++++- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/qiskit/providers/aer/noise/utils/noise_model_inserter.py b/qiskit/providers/aer/noise/utils/noise_model_inserter.py index 053bca7af6..de94dfbeea 100644 --- a/qiskit/providers/aer/noise/utils/noise_model_inserter.py +++ b/qiskit/providers/aer/noise/utils/noise_model_inserter.py @@ -15,9 +15,9 @@ based on a given noise model. The resulting circuit cannot be ran on a quantum computer but can be handled correctly by simulators """ +import qiskit.compiler - -def add_errors(circuit, noise_model): +def add_errors(circuit, noise_model, transpile = False): """ This function gets a circuit and a noise model and returns a new circuit with the errors from the noise model inserted as Kraus gates in the new circuit @@ -29,9 +29,13 @@ def add_errors(circuit, noise_model): """ errors = noise_model._default_quantum_errors.items() error_dict = {name: qubit_dict for (name, qubit_dict) in errors} - result_circuit = circuit.copy(name=circuit.name + '_with_errors') + if transpile: + transpiled_circuit = qiskit.compiler.transpile(circuit, basis_gates=noise_model.basis_gates) + else: + transpiled_circuit = circuit + result_circuit = circuit.copy(name=transpiled_circuit.name + '_with_errors') result_circuit.data = [] - for inst, qargs, cargs in circuit.data: + for inst, qargs, cargs in transpiled_circuit.data: result_circuit.data.append((inst, qargs, cargs)) if inst.name in error_dict.keys(): error = error_dict[inst.name] diff --git a/test/terra/noise/test_noise_inserter.py b/test/terra/noise/test_noise_inserter.py index 971ab19d89..b04b345531 100644 --- a/test/terra/noise/test_noise_inserter.py +++ b/test/terra/noise/test_noise_inserter.py @@ -17,6 +17,7 @@ from qiskit.providers.aer.noise.utils import add_errors from qiskit.providers.aer.noise import NoiseModel from qiskit.providers.aer.noise.errors.standard_errors import pauli_error +from qiskit.qasm import pi import unittest class TestNoiseInserter(unittest.TestCase): @@ -62,5 +63,28 @@ def test_simple_noise(self): self.assertEqual(target_circuit, result_circuit) + def test_transpiling(self): + qr = QuantumRegister(3, 'qr') + circuit = QuantumCircuit(qr) + circuit.x(qr[0]) + circuit.y(qr[1]) + circuit.z(qr[2]) + + error_x = pauli_error([('Y', 0.25), ('I', 0.75)]) + error_y = pauli_error([('X', 0.35), ('Z', 0.65)]) + noise_model = NoiseModel() + noise_model.add_all_qubit_quantum_error(error_x, 'x') + noise_model.add_all_qubit_quantum_error(error_y, 'u1') + + target_circuit = QuantumCircuit(qr) + target_circuit.x(qr[0]) + target_circuit.append(error_x.to_instruction(), [qr[0]]) + target_circuit.u3(pi, pi / 2, pi / 2, qr[1]) + target_circuit.u1(pi, qr[2]) + target_circuit.append(error_y.to_instruction(), [qr[2]]) + + result_circuit = add_errors(circuit, noise_model, transpile=True) + self.assertEqual(target_circuit, result_circuit) + if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() From 5c90ea754a4d329e2a032b77edbd79ce2ec89d4d Mon Sep 17 00:00:00 2001 From: Gadi Date: Thu, 18 Jul 2019 14:43:21 +0300 Subject: [PATCH 06/11] Style --- qiskit/providers/aer/noise/utils/__init__.py | 2 +- qiskit/providers/aer/noise/utils/noise_model_inserter.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/qiskit/providers/aer/noise/utils/__init__.py b/qiskit/providers/aer/noise/utils/__init__.py index c214cbf0e2..71500a2c16 100644 --- a/qiskit/providers/aer/noise/utils/__init__.py +++ b/qiskit/providers/aer/noise/utils/__init__.py @@ -18,4 +18,4 @@ from .noise_transformation import NoiseTransformer from .noise_transformation import approximate_quantum_error from .noise_transformation import approximate_noise_model -from .noise_model_inserter import add_errors \ No newline at end of file +from .noise_model_inserter import add_errors diff --git a/qiskit/providers/aer/noise/utils/noise_model_inserter.py b/qiskit/providers/aer/noise/utils/noise_model_inserter.py index de94dfbeea..db9ef35e06 100644 --- a/qiskit/providers/aer/noise/utils/noise_model_inserter.py +++ b/qiskit/providers/aer/noise/utils/noise_model_inserter.py @@ -17,7 +17,8 @@ """ import qiskit.compiler -def add_errors(circuit, noise_model, transpile = False): + +def add_errors(circuit, noise_model, transpile=False): """ This function gets a circuit and a noise model and returns a new circuit with the errors from the noise model inserted as Kraus gates in the new circuit From bd5e1f2c27af36bcb7108c671404ab7bed295a4c Mon Sep 17 00:00:00 2001 From: Gadi Date: Sun, 21 Jul 2019 12:57:58 +0300 Subject: [PATCH 07/11] Documentation --- qiskit/providers/aer/noise/utils/noise_model_inserter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qiskit/providers/aer/noise/utils/noise_model_inserter.py b/qiskit/providers/aer/noise/utils/noise_model_inserter.py index db9ef35e06..4178cc0e29 100644 --- a/qiskit/providers/aer/noise/utils/noise_model_inserter.py +++ b/qiskit/providers/aer/noise/utils/noise_model_inserter.py @@ -25,6 +25,7 @@ def add_errors(circuit, noise_model, transpile=False): Args: circuit (QuantumCircuit): The circuit to add the errors to noise_model (NoiseModel): The noise model containing the errors to add + transpile (Boolean): Should the circuit be transpiled into the noise model basis gates Returns: QuantumCircuit: The new circuit with the added Kraus gates """ From 72210203ad4bd445cc05a9c505b7328987f0a399 Mon Sep 17 00:00:00 2001 From: Gadi Date: Tue, 30 Jul 2019 11:19:14 +0300 Subject: [PATCH 08/11] Handling multiple circuits at once --- .../aer/noise/utils/noise_model_inserter.py | 35 +++++++++------- test/terra/noise/test_noise_inserter.py | 42 +++++++++++++++++-- 2 files changed, 58 insertions(+), 19 deletions(-) diff --git a/qiskit/providers/aer/noise/utils/noise_model_inserter.py b/qiskit/providers/aer/noise/utils/noise_model_inserter.py index 4178cc0e29..29078fea64 100644 --- a/qiskit/providers/aer/noise/utils/noise_model_inserter.py +++ b/qiskit/providers/aer/noise/utils/noise_model_inserter.py @@ -18,28 +18,33 @@ import qiskit.compiler -def add_errors(circuit, noise_model, transpile=False): +def insert_noise(circuits, noise_model, transpile=False): """ This function gets a circuit and a noise model and returns a new circuit - with the errors from the noise model inserted as Kraus gates in the new circuit + with the noises from the noise model inserted as Kraus gates in the new circuit Args: - circuit (QuantumCircuit): The circuit to add the errors to + circuit (QuantumCircuit or list[QuantumCircuit]): The circuits to add noises to noise_model (NoiseModel): The noise model containing the errors to add transpile (Boolean): Should the circuit be transpiled into the noise model basis gates Returns: QuantumCircuit: The new circuit with the added Kraus gates """ + is_circuits_list = isinstance(circuits, list) or isinstance(circuits, tuple) + circuits = circuits if is_circuits_list else [circuits] + result_circuits = [] errors = noise_model._default_quantum_errors.items() error_dict = {name: qubit_dict for (name, qubit_dict) in errors} - if transpile: - transpiled_circuit = qiskit.compiler.transpile(circuit, basis_gates=noise_model.basis_gates) - else: - transpiled_circuit = circuit - result_circuit = circuit.copy(name=transpiled_circuit.name + '_with_errors') - result_circuit.data = [] - for inst, qargs, cargs in transpiled_circuit.data: - result_circuit.data.append((inst, qargs, cargs)) - if inst.name in error_dict.keys(): - error = error_dict[inst.name] - result_circuit.append(error.to_instruction(), qargs) - return result_circuit + for circuit in circuits: + if transpile: + transpiled_circuit = qiskit.compiler.transpile(circuit, basis_gates=noise_model.basis_gates) + else: + transpiled_circuit = circuit + result_circuit = circuit.copy(name=transpiled_circuit.name + '_with_errors') + result_circuit.data = [] + for inst, qargs, cargs in transpiled_circuit.data: + result_circuit.data.append((inst, qargs, cargs)) + if inst.name in error_dict.keys(): + error = error_dict[inst.name] + result_circuit.append(error.to_instruction(), qargs) + result_circuits.append(result_circuit) + return result_circuits if is_circuits_list else result_circuits[0] diff --git a/test/terra/noise/test_noise_inserter.py b/test/terra/noise/test_noise_inserter.py index b04b345531..b72a4a5d2a 100644 --- a/test/terra/noise/test_noise_inserter.py +++ b/test/terra/noise/test_noise_inserter.py @@ -14,7 +14,7 @@ """ from qiskit import QuantumRegister, QuantumCircuit -from qiskit.providers.aer.noise.utils import add_errors +from qiskit.providers.aer.noise.utils import insert_noise from qiskit.providers.aer.noise import NoiseModel from qiskit.providers.aer.noise.errors.standard_errors import pauli_error from qiskit.qasm import pi @@ -35,7 +35,7 @@ def test_no_noise(self): noise_model = NoiseModel() #empty - result_circuit = add_errors(circuit, noise_model) + result_circuit = insert_noise(circuit, noise_model) self.assertEqual(target_circuit, result_circuit) @@ -59,7 +59,7 @@ def test_simple_noise(self): target_circuit.append(error_y.to_instruction(), [qr[1]]) target_circuit.z(qr[2]) - result_circuit = add_errors(circuit, noise_model) + result_circuit = insert_noise(circuit, noise_model) self.assertEqual(target_circuit, result_circuit) @@ -83,8 +83,42 @@ def test_transpiling(self): target_circuit.u1(pi, qr[2]) target_circuit.append(error_y.to_instruction(), [qr[2]]) - result_circuit = add_errors(circuit, noise_model, transpile=True) + result_circuit = insert_noise(circuit, noise_model, transpile=True) self.assertEqual(target_circuit, result_circuit) + def test_multiple_inputs(self): + qr = QuantumRegister(1, 'qr') + circuit1 = QuantumCircuit(qr) + circuit1.x(qr[0]) + + circuit2 = QuantumCircuit(qr) + circuit2.y(qr[0]) + + circuits_list = [circuit1, circuit2] + circuits_tuple = (circuit1, circuit2) + + noise_model = NoiseModel() + error_x = pauli_error([('Y', 0.25), ('I', 0.75)]) + error_y = pauli_error([('X', 0.35), ('Z', 0.65)]) + noise_model.add_all_qubit_quantum_error(error_x, 'x') + noise_model.add_all_qubit_quantum_error(error_y, 'y') + + target_circuit1 = QuantumCircuit(qr) + target_circuit1.x(qr[0]) + target_circuit1.append(error_x.to_instruction(), [qr[0]]) + + target_circuit2 = QuantumCircuit(qr) + target_circuit2.y(qr[0]) + target_circuit2.append(error_y.to_instruction(), [qr[0]]) + + target_circuits = [target_circuit1, target_circuit2] + result_circuits = insert_noise(circuits_list, noise_model) + self.assertEqual(target_circuits, result_circuits) + + target_circuits = [target_circuit1, target_circuit2] + result_circuits = insert_noise(circuits_tuple, noise_model) + self.assertEqual(target_circuits, result_circuits) + + if __name__ == '__main__': unittest.main() From 89f32f27a6fc8fd7c40ab41dbbf660cbabd24352 Mon Sep 17 00:00:00 2001 From: Gadi Date: Tue, 30 Jul 2019 11:44:26 +0300 Subject: [PATCH 09/11] Small fixes and changelog --- CHANGELOG.md | 2 ++ qiskit/providers/aer/noise/utils/__init__.py | 2 +- qiskit/providers/aer/noise/utils/noise_model_inserter.py | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10a4f26257..7dc2f11275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ Changelog](http://keepachangelog.com/en/1.0.0/). Added ----- +- Noise model inserter module + Changed ------- diff --git a/qiskit/providers/aer/noise/utils/__init__.py b/qiskit/providers/aer/noise/utils/__init__.py index 71500a2c16..94afb7581e 100644 --- a/qiskit/providers/aer/noise/utils/__init__.py +++ b/qiskit/providers/aer/noise/utils/__init__.py @@ -18,4 +18,4 @@ from .noise_transformation import NoiseTransformer from .noise_transformation import approximate_quantum_error from .noise_transformation import approximate_noise_model -from .noise_model_inserter import add_errors +from .noise_model_inserter import insert_noise diff --git a/qiskit/providers/aer/noise/utils/noise_model_inserter.py b/qiskit/providers/aer/noise/utils/noise_model_inserter.py index 29078fea64..7d354ce764 100644 --- a/qiskit/providers/aer/noise/utils/noise_model_inserter.py +++ b/qiskit/providers/aer/noise/utils/noise_model_inserter.py @@ -36,10 +36,11 @@ def insert_noise(circuits, noise_model, transpile=False): error_dict = {name: qubit_dict for (name, qubit_dict) in errors} for circuit in circuits: if transpile: - transpiled_circuit = qiskit.compiler.transpile(circuit, basis_gates=noise_model.basis_gates) + transpiled_circuit = qiskit.compiler.transpile(circuit, + basis_gates=noise_model.basis_gates) else: transpiled_circuit = circuit - result_circuit = circuit.copy(name=transpiled_circuit.name + '_with_errors') + result_circuit = circuit.copy(name=transpiled_circuit.name + '_with_noise') result_circuit.data = [] for inst, qargs, cargs in transpiled_circuit.data: result_circuit.data.append((inst, qargs, cargs)) From 12e993de71f91da00837948fec7d4e9f8eda315f Mon Sep 17 00:00:00 2001 From: Gadi Date: Tue, 30 Jul 2019 11:51:01 +0300 Subject: [PATCH 10/11] Style --- qiskit/providers/aer/noise/utils/noise_model_inserter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/providers/aer/noise/utils/noise_model_inserter.py b/qiskit/providers/aer/noise/utils/noise_model_inserter.py index 7d354ce764..18453817b1 100644 --- a/qiskit/providers/aer/noise/utils/noise_model_inserter.py +++ b/qiskit/providers/aer/noise/utils/noise_model_inserter.py @@ -23,7 +23,7 @@ def insert_noise(circuits, noise_model, transpile=False): This function gets a circuit and a noise model and returns a new circuit with the noises from the noise model inserted as Kraus gates in the new circuit Args: - circuit (QuantumCircuit or list[QuantumCircuit]): The circuits to add noises to + circuits (QuantumCircuit or list[QuantumCircuit]): The circuits to add noises to noise_model (NoiseModel): The noise model containing the errors to add transpile (Boolean): Should the circuit be transpiled into the noise model basis gates Returns: From 8773fcf15b0455b72a0c082362f757bdf741a424 Mon Sep 17 00:00:00 2001 From: Gadi Date: Tue, 30 Jul 2019 11:58:38 +0300 Subject: [PATCH 11/11] Small style improvement --- qiskit/providers/aer/noise/utils/noise_model_inserter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/providers/aer/noise/utils/noise_model_inserter.py b/qiskit/providers/aer/noise/utils/noise_model_inserter.py index 18453817b1..168452c4e9 100644 --- a/qiskit/providers/aer/noise/utils/noise_model_inserter.py +++ b/qiskit/providers/aer/noise/utils/noise_model_inserter.py @@ -29,7 +29,7 @@ def insert_noise(circuits, noise_model, transpile=False): Returns: QuantumCircuit: The new circuit with the added Kraus gates """ - is_circuits_list = isinstance(circuits, list) or isinstance(circuits, tuple) + is_circuits_list = isinstance(circuits, (list, tuple)) circuits = circuits if is_circuits_list else [circuits] result_circuits = [] errors = noise_model._default_quantum_errors.items()