Omit QuantumCircuit as a parameter when drawing ControlFlowOps. (#7345)

Most ControlFlowOps have at least one param of type QuantumCircuit
which qiskit.visualization.utils.get_param_str will attempt to
stringify and display as an instruction parameter. This largely
doesn't work, since the circuit's string will contain newlines, so
instead draw ControlFlowOps with only their name.

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
This commit is contained in:
Kevin Krsulich 2021-12-02 13:42:48 -05:00 committed by GitHub
parent 9ba51b5cc9
commit e77acc6aaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -25,6 +25,7 @@ from qiskit.circuit import (
Gate,
Instruction,
Measure,
ControlFlowOp,
)
from qiskit.circuit.library import PauliEvolutionGate
from qiskit.circuit.tools import pi_check
@ -129,6 +130,9 @@ def get_param_str(op, drawer, ndigits=3):
if not hasattr(op, "params") or any(isinstance(param, np.ndarray) for param in op.params):
return ""
if isinstance(op, ControlFlowOp):
return ""
if isinstance(op, Delay):
param_list = [f"{op.params[0]}[{op.unit}]"]
else: