Skip to content

Commit

Permalink
fixing swap visualization bug
Browse files Browse the repository at this point in the history
  • Loading branch information
EliasLF committed Nov 3, 2023
1 parent a454158 commit 9fdb76e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/mqt/qmap/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def compile( # noqa: A001
arch: str | Arch | Architecture | Backend | None,
calibration: str | BackendProperties | Target | None = None,
method: str | Method = "heuristic",
consider_fidelity: bool = False,
initial_layout: str | InitialLayout = "dynamic",
layering: str | Layering = "individual_gates",
lookaheads: int | None = 15,
Expand Down
4 changes: 2 additions & 2 deletions src/mqt/qmap/visualization/search_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from typing_extensions import Self

from mqt.qmap.visualization.visualize_search_graph import Position, SearchNode, visualize_search_graph
from mqt.qmap.visualization.visualize_search_graph import SearchNode, visualize_search_graph

if TYPE_CHECKING:
from ipywidgets import Widget
Expand Down Expand Up @@ -54,7 +54,7 @@ def close(self) -> None:
def visualize_search_graph(
self,
layer: int | Literal["interactive"] = "interactive", # 'interactive' (slider menu) | index
architecture_node_positions: MutableMapping[int, Position] | None = None,
architecture_node_positions: MutableMapping[int, tuple[float, float]] | None = None,
architecture_layout: Literal["dot", "neato", "fdp", "sfdp", "circo", "twopi", "osage", "patchwork"] = "sfdp",
search_node_layout: Literal[
"walker", "dot", "neato", "fdp", "sfdp", "circo", "twopi", "osage", "patchwork"
Expand Down
14 changes: 7 additions & 7 deletions src/mqt/qmap/visualization/visualize_search_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ class _SwapArrowProps(TypedDict):
from plotly.subplots import make_subplots
from walkerlayout import WalkerLayouting

# TODO: show_swaps not working!


@dataclass
class _TwoQbitMultiplicity:
Expand Down Expand Up @@ -705,6 +703,7 @@ def _visualize_layout(
arch_node_positions: MutableMapping[int, Position],
initial_layout: list[int],
considered_qubit_colors: MutableMapping[int, str],
show_swaps: bool,
swap_arrow_offset: float,
arch_x_arrow_spacing: float,
arch_y_arrow_spacing: float,
Expand All @@ -727,7 +726,7 @@ def _visualize_layout(
)
stats = go.layout.Annotation(**plotly_settings["stats_legend"])
annotations: list[go.layout.Annotation] = []
if len(swaps) > 0:
if show_swaps and len(swaps) > 0:
annotations = _draw_swap_arrows(
arch_node_positions,
initial_layout,
Expand Down Expand Up @@ -875,7 +874,7 @@ def _load_layer_data(
]
shuffle(considered_qubits_color_codes)
considered_qubit_colors: dict[int, str] = {}
for q in considered_qubit_colors:
for q in considered_qubit_color_groups:
considered_qubit_colors[q] = considered_qubits_color_codes[considered_qubit_color_groups[q]]

return ( # type: ignore[return-value]
Expand Down Expand Up @@ -1591,8 +1590,8 @@ def visualize_search_graph(
# 'architecture_xaxis': settings for plotly.graph_objects.layout.XAxis
# 'architecture_yaxis': settings for plotly.graph_objects.layout.YAxis
# }
# TODO: show archticture edge labels (and control text?)
# TODO: control hover text of search (especially for multiple points per node!) and architecture nodes?
# TODO: show archticture edge labels (and make text adjustable)
# TODO: make hover text of search (especially for multiple points per node!) and architecture nodes adjustable
) -> Widget:
"""Creates a widget to visualize a search graph.
Expand Down Expand Up @@ -1950,6 +1949,7 @@ def visualize_search_node_layout(
architecture_node_positions, # type: ignore[arg-type]
initial_layout,
considered_qubit_colors,
show_swaps,
swap_arrow_offset,
arch_x_arrow_spacing, # type: ignore[arg-type]
arch_y_arrow_spacing, # type: ignore[arg-type]
Expand Down Expand Up @@ -2125,7 +2125,7 @@ def update_layer(new_layer: int) -> None:
layer_slider = interactive(
update_layer,
new_layer=IntSlider(
min=0, max=number_of_layers, step=1, value=0, description="Layer:", layout=Layout(width=f"{width-80}px")
min=0, max=number_of_layers-1, step=1, value=0, description="Layer:", layout=Layout(width=f"{width-80}px")
),
)

Expand Down

0 comments on commit 9fdb76e

Please sign in to comment.