Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib drawer: fix bug #1437 and add tests #1438

Merged
Merged
Changes from 2 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
0f9e89a
fix bug #1437
sergiomtzlosa Sep 5, 2024
511d399
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 6, 2024
fbe4569
removed inline matplotlib from docs
sergiomtzlosa Sep 7, 2024
34e942d
Merge branch 'matplotlib-circuit-drawer' of https://github.com/sergio…
sergiomtzlosa Sep 7, 2024
a60f4b7
first test for ui
sergiomtzlosa Sep 8, 2024
b14cf28
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 8, 2024
27f48b4
dummy test for ui
sergiomtzlosa Sep 9, 2024
e8e06c5
more test for ui
sergiomtzlosa Sep 9, 2024
732baf9
review test for UI
sergiomtzlosa Sep 9, 2024
24a403b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 9, 2024
a50663e
fixed test
sergiomtzlosa Sep 9, 2024
2708076
created test for gates barrier cluster
sergiomtzlosa Sep 9, 2024
115974b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 9, 2024
3468e77
added test comments
sergiomtzlosa Sep 9, 2024
3608d95
added more test for severael cases
sergiomtzlosa Sep 9, 2024
7038b5a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 9, 2024
b39b574
added more test for more cases
sergiomtzlosa Sep 9, 2024
35ed0e4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 9, 2024
b5bca09
edition of test
sergiomtzlosa Sep 9, 2024
6728184
test for a bigger circuit
sergiomtzlosa Sep 9, 2024
dea7bb8
test for layered circuit
sergiomtzlosa Sep 9, 2024
2d9ce54
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 9, 2024
e7d7914
test for layered circuit
sergiomtzlosa Sep 9, 2024
91e21ec
Merge branch 'matplotlib-circuit-drawer' of https://github.com/sergio…
sergiomtzlosa Sep 9, 2024
4d4f55e
review check style and tests
sergiomtzlosa Sep 9, 2024
30ef970
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 9, 2024
58200dd
test review for input parameters
sergiomtzlosa Sep 9, 2024
3c4b2b8
test review for input parameters
sergiomtzlosa Sep 9, 2024
f129cc0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 9, 2024
f477992
test review for plotting function
sergiomtzlosa Sep 9, 2024
df196f0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 9, 2024
a99c8e7
test styles for plotting
sergiomtzlosa Sep 9, 2024
0af7fb9
code cleaning and new tests
sergiomtzlosa Sep 9, 2024
048f3ad
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 9, 2024
a66a33b
code cleaning for drawing functions
sergiomtzlosa Sep 9, 2024
6adae29
test for target and control qubits in gates
sergiomtzlosa Sep 9, 2024
19ae050
reformat code to check control and target qubits along new tests
sergiomtzlosa Sep 9, 2024
f61e340
test to cover label rendering
sergiomtzlosa Sep 10, 2024
6795aab
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 10, 2024
2d2c7d6
test to cover label rendering
sergiomtzlosa Sep 10, 2024
827dc96
better assertion clause for plots
sergiomtzlosa Sep 10, 2024
bb3e9f6
test update to check barrier gates
sergiomtzlosa Sep 10, 2024
f7b962b
Merge branch 'master' into matplotlib-circuit-drawer
scarrazza Sep 11, 2024
30e91b2
remove duplicated test
sergiomtzlosa Sep 12, 2024
0960ea5
new UI test based on matching matplotlib figures with images
sergiomtzlosa Sep 13, 2024
aef64b4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 13, 2024
d489a1a
set backend to matplotlib and save arrays to file for matching
sergiomtzlosa Sep 18, 2024
dee7157
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 18, 2024
51cd75d
set backend to matplotlib and save arrays to file for matching
sergiomtzlosa Sep 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/qibo/ui/mpldrawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,13 @@ def _make_cluster_gates(gates_items):
return cluster_gates


def _process_gates(array_gates):
def _process_gates(array_gates, nqubits):
"""
Transforms the list of gates given by the Qibo circuit into a list of gates with a suitable structre to print on screen with matplotlib.

Args:
array_gates (list): List of gates provided by the Qibo circuit.
nqubits (int): Number of circuit qubits

Returns:
list: List of suitable gates to plot with matplotlib.
Expand Down Expand Up @@ -601,7 +602,7 @@ def _process_gates(array_gates):
item += ("q_" + str(qbit),)
gates_plot.append(item)
elif init_label == "ENTANGLEMENTENTROPY":
for qbit in list(range(circuit.nqubits)):
for qbit in list(range(nqubits)):
item = (init_label,)
item += ("q_" + str(qbit),)
gates_plot.append(item)
Expand Down Expand Up @@ -718,9 +719,11 @@ def plot_circuit(circuit, scale=0.6, cluster_gates=True, style=None):
fgates = None

if cluster_gates:
fgates = _make_cluster_gates(_process_gates(gate.gates))
fgates = _make_cluster_gates(
_process_gates(gate.gates, circuit.nqubits)
)
else:
fgates = _process_gates(gate.gates)
fgates = _process_gates(gate.gates, circuit.nqubits)

l_gates = len(gate.gates)
equal_qbits = False
Expand All @@ -736,7 +739,7 @@ def plot_circuit(circuit, scale=0.6, cluster_gates=True, style=None):
else:
all_gates.append(gate)

gates_plot = _process_gates(all_gates)
gates_plot = _process_gates(all_gates, circuit.nqubits)

if cluster_gates and len(gates_plot) > 0:
gates_cluster = _make_cluster_gates(gates_plot)
Expand Down
Loading