Skip to content

Commit

Permalink
Fix unitary synthesis module to get proper error value when it's empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkanazawa1989 committed Mar 10, 2023
1 parent 332f4b2 commit 868419c
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 868419c

Please sign in to comment.