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

More plots for layer errors #1988

Merged
merged 28 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c524f55
swarm
SamFerracin Oct 21, 2024
df94994
fixes
SamFerracin Oct 21, 2024
e9cad6c
style
SamFerracin Oct 22, 2024
0486fb8
Merge branch 'main' of https://github.com/Qiskit/qiskit-ibm-runtime i…
SamFerracin Oct 22, 2024
148b37a
first tests
SamFerracin Oct 22, 2024
28386de
more tests
SamFerracin Oct 22, 2024
3c5aa85
all tests
SamFerracin Oct 22, 2024
b000565
done
SamFerracin Oct 22, 2024
e412117
Merge branch 'main' into more-plots
SamFerracin Oct 22, 2024
8f7b282
Merge branch 'main' of https://github.com/Qiskit/qiskit-ibm-runtime i…
SamFerracin Oct 27, 2024
254fa00
better swarm plots
SamFerracin Oct 28, 2024
d181a87
some improvements
SamFerracin Oct 29, 2024
e7e5ead
black
SamFerracin Oct 29, 2024
a1ec570
conflicts
SamFerracin Oct 30, 2024
1c1af48
tests
SamFerracin Oct 30, 2024
d18a314
improvements
SamFerracin Oct 31, 2024
33d3f46
removed bar plots
SamFerracin Oct 31, 2024
9afdbe9
black
SamFerracin Oct 31, 2024
7da10e3
Merge branch 'more-plots' of https://github.com/SamFerracin/qiskit-ib…
SamFerracin Oct 31, 2024
fd4d540
Merge branch 'main' of https://github.com/Qiskit/qiskit-ibm-runtime i…
SamFerracin Oct 31, 2024
847a31c
style
SamFerracin Oct 31, 2024
3093f2f
fixes
SamFerracin Oct 31, 2024
0ac9db4
Merge branch 'main' into more-plots
SamFerracin Nov 5, 2024
dd023a7
Merge branch 'main' into more-plots
SamFerracin Nov 5, 2024
64768b5
CR
SamFerracin Nov 5, 2024
dc2e326
Merge branch 'more-plots' of https://github.com/SamFerracin/qiskit-ib…
SamFerracin Nov 5, 2024
d314467
reno
SamFerracin Nov 5, 2024
94e5517
Update release-notes/unreleased/1988.feat.rst
SamFerracin Nov 5, 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
146 changes: 134 additions & 12 deletions qiskit_ibm_runtime/utils/noise_learner_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,140 @@ def draw_map(
from ..visualization import draw_layer_error_map

return draw_layer_error_map(
self,
embedding,
colorscale,
color_no_data,
color_out_of_scale,
num_edge_segments,
edge_width,
height,
highest_rate,
background_color,
radius,
width,
layer_error=self,
embedding=embedding,
colorscale=colorscale,
color_no_data=color_no_data,
color_out_of_scale=color_out_of_scale,
num_edge_segments=num_edge_segments,
edge_width=edge_width,
height=height,
highest_rate=highest_rate,
background_color=background_color,
radius=radius,
width=width,
)

def draw_1q_bar_plot(
SamFerracin marked this conversation as resolved.
Show resolved Hide resolved
self,
qubits: Optional[list[int]] = None,
generators: Optional[list[str]] = None,
colors: Optional[list[str]] = None,
grouping: str = "qubit",
height: int = 500,
width: int = 800,
) -> go.Figure:
r"""
Draw a bar plot containing all the one-body terms in this layer error.

Args:
qubits: The qubits to include in the bar plot. If ``None``, all the qubits in the given
``layer_error`` are included.
generators: The (one-qubit) generators to include in the bar plot, e.g. ``("X", "Z")``. If
``None``, all the generators in the given ``layer_error`` are included.
colors: A list of colors for the bars in the plot, or ``None`` if these colors are to be
chosen automatically.
grouping: How to group the bars. Available values are:
* ``"qubits"``: Group by qubit.
* ``"generator"``: Group the bar by generator.
height: The height of the returned figure.
width: The width of the returned figure.
"""
# pylint: disable=import-outside-toplevel, cyclic-import

from ..visualization import draw_layer_error_1q_bar_plot

return draw_layer_error_1q_bar_plot(
layer_error=self,
qubits=qubits,
generators=generators,
colors=colors,
grouping=grouping,
height=height,
width=width,
)

def draw_2q_bar_plot(
self,
edges: Optional[list[tuple[int, int]]] = None,
generators: Optional[list[str]] = None,
colors: Optional[list[str]] = None,
grouping: str = "edge",
height: int = 500,
width: int = 800,
) -> go.Figure:
r"""
Draw a bar plot containing all the two-body terms in this layer error.

Args:
edges: The edges (specified as pairs of qubit labels) to include in the bar plot. If
``None``, all the edges in the given ``layer_error`` are included.
generators: The (two-qubit) generators to include in the bar plot, e.g.
``("XY", "ZZ")``. If ``None``, all the generators in the given ``layer_error`` are
included.
colors: A list of colors for the bars in the plot, or ``None`` if these colors are to
be chosen automatically.
grouping: How to group the bars. Available values are:
* ``"edge"``: Group by edge.
* ``"generator"``: Group the bar by generator.
height: The height of the returned figure.
width: The width of the returned figure.
"""
# pylint: disable=import-outside-toplevel, cyclic-import

from ..visualization import draw_layer_error_2q_bar_plot

return draw_layer_error_2q_bar_plot(
layer_error=self,
edges=edges,
generators=generators,
colors=colors,
grouping=grouping,
height=height,
width=width,
)

def draw_layer_errors_swarm(
self,
other_layer_errors: Optional[list[LayerError]] = None,
colors: Optional[list[str]] = None,
bin_size: Optional[Union[int, float]] = None,
opacities: Union[float, list[float]] = 0.4,
names: Optional[list[str]] = None,
height: int = 500,
width: int = 800,
) -> go.Figure:
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.

Args:
other_layer_errors: A list of other layer errors to draw in the same plot.
colors: A list of colors for the markers in the plot, or ``None`` if these colors are to be
chosen automatically.
bin_size: The size of the bins that the rates are placed into prior to calculating the
offsets. If ``None``, it automatically calculates the ``bin_size`` so that all the
rates are placed in ``10`` consecutive bins.
opacities: A list of opacities for the markers.
names: The names of the various layers as displayed in the legend. If ``None``, default
names are assigned based on the layers' position inside the ``layer_errors`` list.
height: The height of the returned figure.
width: The width of the returned figure.
"""
# pylint: disable=import-outside-toplevel, cyclic-import

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],
colors=colors,
bin_size=bin_size,
opacities=opacities,
names=names,
height=height,
width=width,
)

def _json(self) -> dict:
Expand Down
7 changes: 6 additions & 1 deletion qiskit_ibm_runtime/visualization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@
draw_layer_error_map
"""

from .draw_layer_error_map import draw_layer_error_map
from .draw_layer_error import (
draw_layer_error_map,
draw_layer_error_1q_bar_plot,
draw_layer_error_2q_bar_plot,
draw_layer_errors_swarm,
)
Loading