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

Update gate_map.py to allow nonstandard coupling graph sizes #7494

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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: 13 additions & 0 deletions qiskit/visualization/gate_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ def plot_gate_map(
num_qubits = config.n_qubits
coupling_map = config.coupling_map
qubit_coordinates = qubit_coordinates_map.get(num_qubits)

# try to adjust num_qubits to match the next highest hardcoded grid size
if qubit_coordinates is None:
if any([num_qubits < key for key in qubit_coordinates_map.keys()]):
num_qubits_roundup = max(qubit_coordinates_map.keys())
for key in qubit_coordinates_map.keys():
if key < num_qubits_roundup and key > num_qubits:
num_qubits_roundup = key
qubit_coordinates = qubit_coordinates_map.get(num_qubits_roundup)

return plot_coupling_map(
num_qubits,
qubit_coordinates,
Expand Down Expand Up @@ -545,6 +555,9 @@ def plot_coupling_map(

# Add circles for qubits
for var, idx in enumerate(grid_data):
# add check if num_qubits had been rounded up
if var >= num_qubits:
break
_idx = [idx[1], -idx[0]]
ax.add_artist(
mpatches.Ellipse(
Expand Down