Skip to content

Commit

Permalink
Add a decompose() call to circuit library table in docs (#7819)
Browse files Browse the repository at this point in the history
For the purpose of documentation many of the circuit library classes
were using the circuit_library_widget to provide a visualization of
the circuit, a QASM definition, and some basic high level statistics
about the circuit. However, since #6634 and #6659 all the circuit
library elements are wrapped in an outer Instruction object. This
makes the top level object appear as a logical block in the circuit.
This has the unindended side effect of causing the widget output to not
be super useful, primarily it would should a single logical block for
each element and the circuit statistics would be for the single element
as opposed to its implementation. This commit address this by adding a
single decompose() call around all the statistics and drawing calls
inside the widget code. Since we're consistently wrapping every circuit
library element the widget will always need to do this now, so instead
of calling it directly in the library docstring it's better to just do
this in the widget itself.
  • Loading branch information
mtreinish authored Mar 25, 2022
1 parent ceceb49 commit a540794
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions qiskit/tools/jupyter/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def circuit_data_table(circuit: QuantumCircuit) -> wid.HTML:
Output widget.
"""

circuit = circuit.decompose()
ops = circuit.count_ops()

num_nl = circuit.num_nonlocal_gates()

html = "<table>"
Expand Down Expand Up @@ -214,6 +214,6 @@ def circuit_library_widget(circuit: QuantumCircuit) -> None:
top = circuit_diagram_widget()

with top.children[0]:
display(circuit.draw(output="mpl"))
display(circuit.decompose().draw(output="mpl"))

display(wid.VBox(children=[top, bottom], layout=wid.Layout(width="100%", height="auto")))

0 comments on commit a540794

Please sign in to comment.