Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
SamFerracin committed Oct 31, 2024
1 parent 1c1af48 commit d18a314
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
5 changes: 3 additions & 2 deletions qiskit_ibm_runtime/execution_span/execution_spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ def sort(self, inplace: bool = True) -> "ExecutionSpans":

def draw(
self, name: str = None, normalize_y: bool = False, line_width: int = 4
) -> "PlotlyFigure":
) -> PlotlyFigure:
"""Draw these execution spans.
.. note::
To draw multiple sets of execution spans at once, for example coming from multiple
jobs, consider calling :func:`~.draw_execution_spans` directly.
jobs, consider calling :meth:`~qiskit_ibm_runtime.visualization.draw_execution_spans`
directly.
Args:
name: The name of this set of spans.
Expand Down
17 changes: 11 additions & 6 deletions qiskit_ibm_runtime/utils/noise_learner_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def draw_1q_bar_plot(
grouping: str = "qubit",
height: int = 500,
width: int = 800,
) -> go.Figure:
) -> PlotlyFigure:
r"""
Draw a bar plot containing all the one-body terms in this layer error.
Expand Down Expand Up @@ -347,7 +347,7 @@ def draw_2q_bar_plot(
grouping: str = "edge",
height: int = 500,
width: int = 800,
) -> go.Figure:
) -> PlotlyFigure:
r"""
Draw a bar plot containing all the two-body terms in this layer error.
Expand Down Expand Up @@ -381,7 +381,6 @@ def draw_2q_bar_plot(

def draw_layer_errors_swarm(
self,
other_layer_errors: Optional[list[LayerError]] = None,
num_bodies: Optional[int] = None,
max_rate: Optional[float] = None,
min_rate: Optional[float] = None,
Expand All @@ -391,17 +390,21 @@ def draw_layer_errors_swarm(
opacities: Union[float, list[float]] = 0.4,
names: Optional[list[str]] = None,
x_coo: Optional[list[float]] = None,
marker_size: Optional[float] = None,
height: int = 500,
width: int = 800,
) -> go.Figure:
) -> PlotlyFigure:
r"""
Draw a swarm plot of the rates in this layer error.
This function plots the ll rates along a vertical axes, offsetting the rates along the ``x``
axis so that they do not overlap with each other.
.. note::
To draw multiple layer errors at once, consider calling
:meth:`~qiskit_ibm_runtime.visualization.draw_execution_spans` directly.
Args:
other_layer_errors: A list of other layer errors to draw in the same plot.
num_bodies: The weight of the generators to include in the plot, or ``None`` if all the
generators should be included.
max_rate: The largest rate to include in the plot, or ``None`` if no upper limit should be
Expand All @@ -418,6 +421,7 @@ def draw_layer_errors_swarm(
names are assigned based on the layers' position inside the ``layer_errors`` list.
x_coo: The ``x``-axis coordinates of the vertical axes that the markers are drawn around, or
``None`` if these axes should be placed at regular intervals.
marker_size: The size of the marker in the plot.
height: The height of the returned figure.
width: The width of the returned figure.
"""
Expand All @@ -426,7 +430,7 @@ def draw_layer_errors_swarm(
from ..visualization import draw_layer_errors_swarm

return draw_layer_errors_swarm(
layer_errors=[self] + list(other_layer_errors) if other_layer_errors else [self],
layer_errors=[self],
num_bodies=num_bodies,
max_rate=max_rate,
min_rate=min_rate,
Expand All @@ -436,6 +440,7 @@ def draw_layer_errors_swarm(
opacities=opacities,
names=names,
x_coo=x_coo,
marker_size=marker_size,
height=height,
width=width,
)
Expand Down
6 changes: 4 additions & 2 deletions qiskit_ibm_runtime/visualization/draw_layer_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ def draw_layer_errors_swarm(
opacities: Union[float, list[float]] = 0.4,
names: Optional[list[str]] = None,
x_coo: Optional[list[float]] = None,
marker_size: Optional[float] = None,
height: int = 500,
width: int = 800,
) -> PlotlyFigure:
Expand Down Expand Up @@ -494,6 +495,7 @@ def draw_layer_errors_swarm(
names are assigned based on the layers' position inside the ``layer_errors`` list.
x_coo: The ``x``-axis coordinates of the vertical axes that the markers are drawn around, or
``None`` if these axes should be placed at regular intervals.
marker_size: The size of the marker in the plot.
height: The height of the returned figure.
width: The width of the returned figure.
Expand All @@ -505,7 +507,7 @@ def draw_layer_errors_swarm(
"""
go = plotly_module(".graph_objects")

colors = colors if colors else [None] * len(layer_errors)
colors = colors if colors else ["dodgerblue"] * len(layer_errors)
if len(colors) != len(layer_errors):
raise ValueError(f"Expected {len(layer_errors)} colors, found {len(colors)}.")

Expand Down Expand Up @@ -573,7 +575,7 @@ def draw_layer_errors_swarm(
x=xs,
hovertemplate=hoverinfo,
mode="markers",
marker={"color": colors[l_error_idx], "opacity": opacities[l_error_idx]},
marker={"color": colors[l_error_idx], "opacity": opacities[l_error_idx], "size": marker_size},
name=names[l_error_idx],
showlegend=False,
)
Expand Down
2 changes: 0 additions & 2 deletions test/unit/visualization/test_draw_layer_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

"""Tests for the classes used to instantiate noise learner results."""

from unittest import skipIf

from qiskit import QuantumCircuit
from qiskit.quantum_info import PauliList
from qiskit_aer import AerSimulator
Expand Down

0 comments on commit d18a314

Please sign in to comment.