Environment
- PyQASM version: 0.4.0
- Python version: 3.13.2
- Operating system: MacOS 15.5
What happened?
pyqasm draw method raises error for circuits with decomposable gates.
import pyqasm
qasm = """
OPENQASM 3.0;
qubit[2] q1;
qreg q[3];
creg c[3];
ccx q[0], q[1], q1[0];
crx (0.1) q[0], q[1];
rccx q[0], q[1], q1[0];
"""
qc = pyqasm.loads(qasm)
qc.validate()
pyqasm.draw(qc)
Error: AttributeError: 'numpy.ndarray' object has no attribute 'set_ylim'
Suggestions (Optional)
When we have decomposable gates, the circuit visualization code is creating multiple subplots to show the decomposed operations. In these cases, matplotlib's plt.subplots() is returning a NumPy array of axes instead of a list of matplotlib Axes objects. Our code was trying to call set_ylim() on this NumPy array instead of on individual Axes objects.
We need to ensure that we're always working with a list of matplotlib Axes objects, regardless of whether we have one or multiple subplots.
Environment
What happened?
pyqasm
drawmethod raises error for circuits with decomposable gates.Suggestions (Optional)
When we have decomposable gates, the circuit visualization code is creating multiple subplots to show the decomposed operations. In these cases, matplotlib's
plt.subplots()is returning a NumPy array of axes instead of a list of matplotlib Axes objects. Our code was trying to callset_ylim()on this NumPy array instead of on individual Axes objects.We need to ensure that we're always working with a list of matplotlib Axes objects, regardless of whether we have one or multiple subplots.