Skip to content

Commit

Permalink
Fix reverse_bits with registerless bits in all 3 circuit drawers (#7319)
Browse files Browse the repository at this point in the history
  • Loading branch information
enavarro51 authored Feb 11, 2022
1 parent a6aa300 commit 1ae663d
Show file tree
Hide file tree
Showing 15 changed files with 773 additions and 491 deletions.
50 changes: 19 additions & 31 deletions qiskit/visualization/circuit_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,24 +307,20 @@ def _text_circuit_drawer(
qubits, clbits, nodes = utils._get_layered_instructions(
circuit, reverse_bits=reverse_bits, justify=justify, idle_wires=idle_wires
)

if with_layout:
layout = circuit._layout
else:
layout = None
global_phase = circuit.global_phase if hasattr(circuit, "global_phase") else None
text_drawing = _text.TextDrawing(
qubits,
clbits,
nodes,
reverse_bits=reverse_bits,
layout=layout,
layout=None,
initial_state=initial_state,
cregbundle=cregbundle,
global_phase=global_phase,
global_phase=None,
encoding=encoding,
qregs=circuit.qregs,
cregs=circuit.cregs,
qregs=None,
cregs=None,
with_layout=with_layout,
circuit=circuit,
)
text_drawing.plotbarriers = plot_barriers
text_drawing.line_length = fold
Expand Down Expand Up @@ -497,12 +493,6 @@ def _generate_latex_source(
qubits, clbits, nodes = utils._get_layered_instructions(
circuit, reverse_bits=reverse_bits, justify=justify, idle_wires=idle_wires
)
if with_layout:
layout = circuit._layout
else:
layout = None

global_phase = circuit.global_phase if hasattr(circuit, "global_phase") else None
qcimg = _latex.QCircuitImage(
qubits,
clbits,
Expand All @@ -511,12 +501,14 @@ def _generate_latex_source(
style=style,
reverse_bits=reverse_bits,
plot_barriers=plot_barriers,
layout=layout,
layout=None,
initial_state=initial_state,
cregbundle=cregbundle,
global_phase=global_phase,
qregs=circuit.qregs,
cregs=circuit.cregs,
global_phase=None,
qregs=None,
cregs=None,
with_layout=with_layout,
circuit=circuit,
)
latex = qcimg.latex()
if filename:
Expand Down Expand Up @@ -583,15 +575,9 @@ def _matplotlib_circuit_drawer(
qubits, clbits, nodes = utils._get_layered_instructions(
circuit, reverse_bits=reverse_bits, justify=justify, idle_wires=idle_wires
)
if with_layout:
layout = circuit._layout
else:
layout = None

if fold is None:
fold = 25

global_phase = circuit.global_phase if hasattr(circuit, "global_phase") else None
qcd = _matplotlib.MatplotlibDrawer(
qubits,
clbits,
Expand All @@ -600,14 +586,16 @@ def _matplotlib_circuit_drawer(
style=style,
reverse_bits=reverse_bits,
plot_barriers=plot_barriers,
layout=layout,
layout=None,
fold=fold,
ax=ax,
initial_state=initial_state,
cregbundle=cregbundle,
global_phase=global_phase,
qregs=circuit.qregs,
cregs=circuit.cregs,
calibrations=circuit.calibrations,
global_phase=None,
calibrations=None,
qregs=None,
cregs=None,
with_layout=with_layout,
circuit=circuit,
)
return qcd.draw(filename)
Loading

0 comments on commit 1ae663d

Please sign in to comment.