From 868419cb07c690132394a3c7939c80de2ef4629c Mon Sep 17 00:00:00 2001 From: Naoki Kanazawa Date: Fri, 10 Mar 2023 03:09:15 +0900 Subject: [PATCH] Fix unitary synthesis module to get proper error value when it's empty. --- .../transpiler/passes/synthesis/unitary_synthesis.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qiskit/transpiler/passes/synthesis/unitary_synthesis.py b/qiskit/transpiler/passes/synthesis/unitary_synthesis.py index 898998d08c63..48bd0b0f8b38 100644 --- a/qiskit/transpiler/passes/synthesis/unitary_synthesis.py +++ b/qiskit/transpiler/passes/synthesis/unitary_synthesis.py @@ -660,7 +660,10 @@ def is_controlled(gate): if props is None: basis_2q_fidelity = 1.0 else: - basis_2q_fidelity = 1 - getattr(props, "error", 0.0) + error = getattr(props, "error", 0.0) + if error is None: + error = 0.0 + basis_2q_fidelity = 1 - error if approximation_degree is not None: basis_2q_fidelity *= approximation_degree decomposer = TwoQubitBasisDecomposer( @@ -682,7 +685,10 @@ def is_controlled(gate): if props is None: basis_2q_fidelity[strength] = 1.0 else: - basis_2q_fidelity[strength] = 1 - getattr(props, "error", 0.0) + error = getattr(props, "error", 0.0) + if error is None: + error = 0.0 + basis_2q_fidelity[strength] = 1 - error # rewrite XX of the same strength in terms of it embodiment = XXEmbodiments[type(v)] if len(embodiment.parameters) == 1: