Skip to content

Commit

Permalink
Fix unitary synthesis module to get proper error value when it's empt…
Browse files Browse the repository at this point in the history
…y. (Qiskit#9774)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
nkanazawa1989 and mergify[bot] committed Mar 13, 2023
1 parent 6829bb1 commit 2ce129a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions qiskit/transpiler/passes/synthesis/unitary_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
Expand Down

0 comments on commit 2ce129a

Please sign in to comment.