pygsti.report.workspaceplots

Classes corresponding to plots within a Workspace context.

Module Contents

Classes

BoxKeyPlot

Plot serving as a key for fiducial rows/columns of each plaquette of a circuit color box plot.

ColorBoxPlot

Plot of colored boxes arranged into plaquettes showing various quanties for each circuit in an analysis.

GateMatrixPlot

Plot of a operation matrix using colored boxes.

MatrixPlot

Plot of a general matrix using colored boxes

PolarEigenvaluePlot

Polar plot of complex eigenvalues

ProjectionsBoxPlot

Plot of matrix of (usually error-generator) projections

ChoiEigenvalueBarPlot

Bar plot of eigenvalues showing red bars for negative values

GramMatrixBarPlot

Bar plot of Gram matrix eigenvalues stacked against those of target

FitComparisonBarPlot

Bar plot showing the overall (aggregate) goodness of fit (along one dimension).

FitComparisonBoxPlot

Box plot showing the overall (aggregate) goodness of fit (along 2 dimensions).

DatasetComparisonSummaryPlot

A grid of grayscale boxes comparing data sets pair-wise.

DatasetComparisonHistogramPlot

Histogram of p-values comparing two data sets

RandomizedBenchmarkingPlot

Plot of RB Decay curve

Functions

_color_boxplot(plt_data, colormap, colorbar=False, box_label_size=0, prec=0, hover_label_fn=None, hover_labels=None)

Create a color box plot.

_nested_color_boxplot(plt_data_list_of_lists, colormap, colorbar=False, box_label_size=0, prec=0, hover_label_fn=None)

Creates a "nested" color box plot.

_summable_color_boxplot(sub_mxs, xlabels, ylabels, xlabel, ylabel, colormap, colorbar=False, box_labels=True, prec=0, hover_info=True, sum_up=False, scale=1.0, bgcolor='white')

A helper function for generating typical nested color box plots used in pyGSTi.

_create_hover_info_fn(circuit_structure, xvals, yvals, sum_up, addl_hover_submxs)

_circuit_color_boxplot(circuit_structure, sub_mxs, colormap, colorbar=False, box_labels=True, prec='compact', hover_info=True, sum_up=False, invert=False, scale=1.0, bgcolor='white', addl_hover_submxs=None)

A wrapper around _summable_color_boxplot() for creating color box plots displaying circuits.

_circuit_color_scatterplot(circuit_structure, sub_mxs, colormap, colorbar=False, hover_info=True, sum_up=False, ylabel='', scale=1.0, addl_hover_submxs=None)

Similar to _circuit_color_boxplot() except a scatter plot is created.

_circuit_color_histogram(circuit_structure, sub_mxs, colormap, ylabel='', scale=1.0)

Similar to _circuit_color_boxplot() except a histogram is created.

_opmatrix_color_boxplot(op_matrix, color_min, color_max, mx_basis=None, mx_basis_y=None, xlabel=None, ylabel=None, box_labels=False, colorbar=None, prec=0, scale=1.0, eb_matrix=None, title=None)

Creates a color box plot for visualizing a single matrix.

_matrix_color_boxplot(matrix, xlabels=None, ylabels=None, xlabel=None, ylabel=None, box_labels=False, thick_line_interval=None, colorbar=None, colormap=None, prec=0, scale=1.0, eb_matrix=None, title=None, grid='black')

Creates a color box plot for visualizing a single matrix.

_mx_fn_from_elements(plaq, x, y, extra)

_mx_fn_blank(plaq, x, y, unused)

_mx_fn_errorrate(plaq, x, y, direct_gst_models)

_mx_fn_directchi2(plaq, x, y, extra)

_mx_fn_directlogl(plaq, x, y, extra)

_mx_fn_dscmp(plaq, x, y, dscomparator)

_mx_fn_dict(plaq, x, y, genericdict)

_mx_fn_driftpv(plaq, x, y, instabilityanalyzertuple)

_mx_fn_drifttvd(plaq, x, y, instabilityanalyzertuple)

_outcome_to_str(x)

_addl_mx_fn_outcomes(plaq, x, y, layout)

Attributes

go_x_axis

pygsti.report.workspaceplots.go_x_axis
pygsti.report.workspaceplots._color_boxplot(plt_data, colormap, colorbar=False, box_label_size=0, prec=0, hover_label_fn=None, hover_labels=None)

Create a color box plot.

Creates a plot.ly heatmap figure composed of colored boxes and possibly labels.

Parameters
  • plt_data (numpy array) – A 2D array containing the values to be plotted. None values will show up as white.

  • colormap (Colormap) – The colormap used to determine box color.

  • colorbar (bool, optional) – Whether or not to show the color scale bar.

  • box_label_size (int, optional) – If greater than 0, display static labels on each box with font size equal to box_label_size.

  • prec (int or {'compact','compacthp'}, optional) –

    Precision for box labels. Allowed values are:

    ’compact’ = round to nearest whole number using at most 3 characters ‘compacthp’ = show as much precision as possible using at most 3 characters int >= 0 = fixed precision given by int int < 0 = number of significant figures given by -int

  • hover_label_fn (function, optional) – A function with signature f(z,i,j) where z ==plt_data[i,j] which computes the hover label for the each element of plt_data. Cannot be used with hover_labels.

  • hover_labels (list of lists, optional) – Strings specifying the hover labels for each element of plt_data. E.g. hover_labels[i,j] is the string for the i-th row (y-value) and j-th column (x-value) of the plot.

Returns

plotly.Figure

pygsti.report.workspaceplots._nested_color_boxplot(plt_data_list_of_lists, colormap, colorbar=False, box_label_size=0, prec=0, hover_label_fn=None)

Creates a “nested” color box plot.

Tiles the plaquettes given by plt_data_list_of_lists onto a single heatmap.

Parameters
  • plt_data_list_of_lists (list of lists of numpy arrays) – A complete square 2D list of lists, such that each element is a 2D numpy array of the same size.

  • colormap (Colormap) – The colormap used to determine box color.

  • colorbar (bool, optional) – Whether or not to show the color scale bar.

  • box_label_size (int, optional) – If greater than 0, display static labels on each box with font size equal to box_label_size.

  • prec (int or {'compact','compacthp'}, optional) –

    Precision for box labels. Allowed values are:

    ’compact’ = round to nearest whole number using at most 3 characters ‘compacthp’ = show as much precision as possible using at most 3 characters int >= 0 = fixed precision given by int int < 0 = number of significant figures given by -int

  • hover_label_fn (function, optional) – A function with signature f(z,i,j) where z ==plt_data[i,j] which computes the hover label for the each element of plt_data. Cannot be used with hoverLabels.

Returns

plotly.Figure

pygsti.report.workspaceplots._summable_color_boxplot(sub_mxs, xlabels, ylabels, xlabel, ylabel, colormap, colorbar=False, box_labels=True, prec=0, hover_info=True, sum_up=False, scale=1.0, bgcolor='white')

A helper function for generating typical nested color box plots used in pyGSTi.

Given the list-of-lists, sub_mxs, along with x and y labels for both the “outer” (i.e. the list-indices), this function will produce a nested color box plot with the option of summing over the sub-matrix elements (the “inner” axes).

Parameters
  • sub_mxs (list) – A list of lists of 2D numpy.ndarrays. sub_mxs[iy][ix] specifies the matrix of values or sum (if sum_up == True) displayed in iy-th row and ix-th column of the plot. NaNs indicate elements should not be displayed.

  • xlabels (list) – Labels for the outer x-axis values.

  • ylabels (list) – Labels for the outer y-axis values.

  • xlabel (str) – Outer x-axis label.

  • ylabel (str) – Outer y-axis label.

  • colormap (Colormap) – The colormap used to determine box color.

  • colorbar (bool, optional) – Whether or not to show the color scale bar.

  • box_labels (bool, optional) – Whether to display static value-labels over each box.

  • prec (int or {'compact','compacthp'}, optional) –

    Precision for box labels. Allowed values are:

    ’compact’ = round to nearest whole number using at most 3 characters ‘compacthp’ = show as much precision as possible using at most 3 characters int >= 0 = fixed precision given by int int < 0 = number of significant figures given by -int

  • hover_info (bool or function, optional) – If a boolean, indicates whether to include interactive hover labels. If a function, then must take arguments (val, i, j, ii, jj) if sum_up == False or (val, i, j) if sum_up == True and return a label string, where val is the box value, j and i index xlabels and ylabels, and ii and jj index the row and column index of the sub-matrix element the label is for.

  • sum_up (bool, optional) – False displays each matrix element as it’s own color box True sums the elements of each (x,y) matrix and displays a single color box for the sum.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • bgcolor (str, optional) – Background color for this plot. Can be common color names, e.g. “black”, or string RGB values, e.g. “rgb(255,128,0)”.

Returns

plotly.Figure

pygsti.report.workspaceplots._create_hover_info_fn(circuit_structure, xvals, yvals, sum_up, addl_hover_submxs)
pygsti.report.workspaceplots._circuit_color_boxplot(circuit_structure, sub_mxs, colormap, colorbar=False, box_labels=True, prec='compact', hover_info=True, sum_up=False, invert=False, scale=1.0, bgcolor='white', addl_hover_submxs=None)

A wrapper around _summable_color_boxplot() for creating color box plots displaying circuits.

Generates a plot from the structure of the circuits as contained in a CircuitStructure object.

Parameters
  • circuit_structure (CircuitStructure) – Specifies a set of circuits along with their structure, e.g. fiducials, germs, and maximum lengths.

  • sub_mxs (list) – A list of lists of 2D numpy.ndarrays. sub_mxs[iy][ix] specifies the matrix of values or sum (if sum_up == True) displayed in iy-th row and ix-th column of the plot. NaNs indicate elements should not be displayed.

  • colormap (Colormap) – The colormap used to determine box color.

  • colorbar (bool, optional) – Whether or not to show the color scale bar.

  • box_labels (bool, optional) – Whether to display static value-labels over each box.

  • prec (int or {'compact','compacthp'}, optional) –

    Precision for box labels. Allowed values are:

    ’compact’ = round to nearest whole number using at most 3 characters ‘compacthp’ = show as much precision as possible using at most 3 characters int >= 0 = fixed precision given by int int < 0 = number of significant figures given by -int

  • hover_info (bool, optional) – Whether to incude interactive hover labels.

  • sum_up (bool, optional) – False displays each matrix element as it’s own color box True sums the elements of each (x,y) matrix and displays a single color box for the sum.

  • invert (bool, optional) – If True, invert the nesting order of the nested color box plot (applicable only when sum_up == False). E.g. use inner_x_labels and inner_y_labels to label the x and y axes.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • bgcolor (str, optional) – Background color for this plot. Can be common color names, e.g. “black”, or string RGB values, e.g. “rgb(255,128,0)”.

  • addl_hover_submxs (dict, optional) – If not None, a dictionary whose values are lists-of-lists in the same format as sub_mxs which specify additional values to add to the hover-info of the corresponding boxes. The keys of this dictionary are used as labels within the hover-info text.

Returns

plotly.Figure

pygsti.report.workspaceplots._circuit_color_scatterplot(circuit_structure, sub_mxs, colormap, colorbar=False, hover_info=True, sum_up=False, ylabel='', scale=1.0, addl_hover_submxs=None)

Similar to _circuit_color_boxplot() except a scatter plot is created.

Parameters
  • circuit_structure (PlaquetteGridCircuitStructure) – Specifies a set of circuits along with their outer and inner x,y structure, e.g. fiducials, germs, and maximum lengths.

  • sub_mxs (list) – A list of lists of 2D numpy.ndarrays. sub_mxs[iy][ix] specifies the matrix of values or sum (if sum_up == True) displayed in iy-th row and ix-th column of the plot. NaNs indicate elements should not be displayed.

  • colormap (Colormap) – The colormap used to determine box color.

  • colorbar (bool, optional) – Whether or not to show the color scale bar.

  • hover_info (bool, optional) – Whether to incude interactive hover labels.

  • sum_up (bool, optional) – False displays each matrix element as it’s own color box True sums the elements of each (x,y) matrix and displays a single color box for the sum.

  • ylabel (str, optional) – The y-axis label to use.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • addl_hover_submxs (dict, optional) – If not None, a dictionary whose values are lists-of-lists in the same format as sub_mxs which specify additional values to add to the hover-info of the corresponding boxes. The keys of this dictionary are used as labels within the hover-info text.

Returns

plotly.Figure

pygsti.report.workspaceplots._circuit_color_histogram(circuit_structure, sub_mxs, colormap, ylabel='', scale=1.0)

Similar to _circuit_color_boxplot() except a histogram is created.

Parameters
  • circuit_structure (PlaquetteGridCircuitStructure) – Specifies a set of circuits along with their outer and inner x,y structure, e.g. fiducials, germs, and maximum lengths.

  • sub_mxs (list) – A list of lists of 2D numpy.ndarrays. sub_mxs[iy][ix] specifies the matrix of values or sum (if sum_up == True) displayed in iy-th row and ix-th column of the plot. NaNs indicate elements should not be displayed.

  • colormap (Colormap) – The colormap used to determine box color.

  • ylabel (str, optional) – The y-axis label to use.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

Returns

plotly.Figure

pygsti.report.workspaceplots._opmatrix_color_boxplot(op_matrix, color_min, color_max, mx_basis=None, mx_basis_y=None, xlabel=None, ylabel=None, box_labels=False, colorbar=None, prec=0, scale=1.0, eb_matrix=None, title=None)

Creates a color box plot for visualizing a single matrix.

Parameters
  • op_matrix (numpy array) – The matrix to visualize.

  • color_min (float) – Color scale minimum.

  • color_max (float) – Color scale maximum.

  • mx_basis (str or Basis, optional) – The name abbreviation for the basis or a Basis object. Used to label the columns & rows (x- and y-ticklabels). Typically in {“pp”,”gm”,”std”,”qt”}. If you don’t want labels, leave as None.

  • mx_basis_y (str or Basis, optional) – Same as mx_basis but for just the y-ticklabels, overriding mx_basis and allowing the y-ticklabels to be different.

  • xlabel (str, optional) – X-axis label of the plot.

  • ylabel (str, optional) – Y-axis label of the plot.

  • box_labels (bool, optional) – Whether box labels are displayed.

  • colorbar (bool optional) – Whether to display a color bar to the right of the box plot. If None, then a colorbar is displayed when box_labels == False.

  • prec (int or {'compact','compacthp'}, optional) –

    Precision for box labels. Only relevant when box_labels == True. Allowed values are:

    • ’compact’ = round to nearest whole number using at most 3 characters

    • ’compacthp’ = show as much precision as possible using at most 3 characters

    • int >= 0 = fixed precision given by int

    • int < 0 = number of significant figures given by -int

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • eb_matrix (numpy array, optional) – An array, of the same size as op_matrix, which gives error bars to be be displayed in the hover info.

  • title (str, optional) – A title for the plot

Returns

plotly.Figure

pygsti.report.workspaceplots._matrix_color_boxplot(matrix, xlabels=None, ylabels=None, xlabel=None, ylabel=None, box_labels=False, thick_line_interval=None, colorbar=None, colormap=None, prec=0, scale=1.0, eb_matrix=None, title=None, grid='black')

Creates a color box plot for visualizing a single matrix.

Parameters
  • matrix (numpy array) – The matrix to visualize.

  • xlabels (list, optional) – List of (str) box labels along the x-axis.

  • ylabels (list, optional) – List of (str) box labels along the y-axis.

  • xlabel (str, optional) – X-axis label of the plot.

  • ylabel (str, optional) – Y-axis label of the plot.

  • box_labels (bool, optional) – Whether box labels are displayed.

  • thick_line_interval (int, optional) – If not None, the interval at thicker (darker) lines should be placed. For example, if 2 then every other grid line will be thick.

  • colorbar (bool optional) – Whether to display a color bar to the right of the box plot. If None, then a colorbar is displayed when box_labels == False.

  • colormap (Colormap, optional) – An a color map object used to convert the numerical matrix values into colors.

  • prec (int or {'compact','compacthp'}, optional) –

    Precision for box labels. Only relevant when box_labels == True. Allowed values are:

    • ’compact’ = round to nearest whole number using at most 3 characters

    • ’compacthp’ = show as much precision as possible using at most 3 characters

    • int >= 0 = fixed precision given by int

    • int < 0 = number of significant figures given by -int

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • eb_matrix (numpy array, optional) – An array, of the same size as matrix, which gives error bars to be be displayed in the hover info.

  • title (str, optional) – A title for the plot

  • grid ({"white","black",None}) – What color grid lines, if any, to add to the plot. Advanced usage allows the addition of :N where N is an integer giving the line width.

Returns

plotly.Figure

class pygsti.report.workspaceplots.BoxKeyPlot(ws, prep_fiducials, meas_fiducials, xlabel='Preparation fiducial', ylabel='Measurement fiducial', scale=1.0)

Bases: pygsti.report.workspace.WorkspacePlot

Plot serving as a key for fiducial rows/columns of each plaquette of a circuit color box plot.

This plot shows the layout of a single sub-block of a goodness-of-fit box plot (such as those produced by ColorBoxPlot)

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • prep_fiducials (list of Circuits) – Preparation fiducials.

  • meas_fiducials (list of Circuits) – Measurement fiducials.

  • xlabel (str, optional) – X-axis label

  • ylabel (str, optional) – Y-axis label

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

_create(self, prep_fiducials, meas_fiducials, xlabel, ylabel, scale)
class pygsti.report.workspaceplots.ColorBoxPlot(ws, plottype, circuits, dataset, model, sum_up=False, box_labels=False, hover_info=True, invert=False, prec='compact', linlg_pcntle=0.05, direct_gst_models=None, dscomparator=None, stabilityanalyzer=None, mdc_store=None, submatrices=None, typ='boxes', scale=1.0, comm=None, wildcard=None, colorbar=False, bgcolor='white', genericdict=None, genericdict_threshold=None)

Bases: pygsti.report.workspace.WorkspacePlot

Plot of colored boxes arranged into plaquettes showing various quanties for each circuit in an analysis.

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • plottype ({"chi2","logl","tvd","blank","errorrate","dscmp",) – “driftdetector”, “driftsize”} Specifies the type of plot. “errorate” requires that direct_gst_models be set.

  • circuits (CircuitList or list of Circuits) – Specifies the set of circuits, usually along with their structure, e.g. fiducials, germs, and maximum lengths.

  • dataset (DataSet) – The data used to specify frequencies and counts.

  • model (Model) – The model used to specify the probabilities and SPAM labels.

  • sum_up (bool, optional) – False displays each matrix element as it’s own color box True sums the elements of each (x,y) matrix and displays a single color box for the sum.

  • box_labels (bool, optional) – Whether box labels are displayed. It takes much longer to generate the figure when this is set to True.

  • hover_info (bool, optional) – Whether to include interactive hover labels.

  • invert (bool, optional) – If True, invert the nesting order of the color box plot (applicable only when sum_up == False).

  • prec (int, optional) –

    Precision for box labels. Allowed values are:

    ’compact’ = round to nearest whole number using at most 3 characters ‘compacthp’ = show as much precision as possible using at most 3 characters int >= 0 = fixed precision given by int int < 0 = number of significant figures given by -int

  • linlg_pcntle (float, optional) – Specifies the (1 - linlg_pcntle) percentile to compute for the boxplots

  • direct_gst_models (dict, optional) – A dictionary of “direct” Models used when displaying certain plot types. Keys are circuits and values are corresponding gate sets (see plottype above).

  • dscomparator (DataComparator, optional) – The data set comparator used to produce the “dscmp” plot type.

  • stabilityanalyzer (StabilityAnalyzer or 3-tuple, optional) – Only used to produce the “driftdetector” and “driftsize” boxplot. If a StabilityAnalyzer, then this contains the results of the drift / stability analysis to be displayed. For non-expert users, this is the best option. If a tuple, then the first element of the tuple is this StabilityAnalyzer object, and the second and third elements of the tuple label which instability detection results to display (a StabilityAnalyzer can contain multiple distinct tests for instability). The second element is the “detectorkey”, which can be None (the default), or a string specifying which of the drift detection results to use for the plot. If it is None, then the default set of results are used. The third element of the tuple is either None, or a tuple that specifies which “level” of tests to use from the drift detection run (specified by the detectorkey), e.g., per-circuit with outcomes averaged or per-circuit per-outcome.

  • submatrices (dict, optional) – A dictionary whose keys correspond to other potential plot types and whose values are each a list-of-lists of the sub matrices to plot, corresponding to the used x and y values of the structure of circuits.

  • typ ({"boxes","scatter","histogram"}) – Which type of plot to make: the standard grid of “boxes”, a “scatter” plot of the values vs. sequence length, or a “histogram” of all the values.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • comm (mpi4py.MPI.Comm, optional) – When not None, an MPI communicator for distributing the computation across multiple processors.

  • wildcard (WildcardBudget) – A wildcard budget to apply to the objective function that increases the goodness of fit by adjusting (by an amount measured in TVD) the probabilities produced by model before comparing with the frequencies in dataset. Currently, this functionality is only supported for plottype == “logl”.

  • colorbar (bool, optional) – Whether to include a colorbar.

  • bgcolor (str, optional) – Background color for this plot. Can be common color names, e.g. “black”, or string RGB values, e.g. “rgb(255,128,0)”.

_create(self, plottypes, circuits, dataset, model, prec, sum_up, box_labels, hover_info, invert, linlg_pcntle, direct_gst_models, dscomparator, stabilityanalyzer, mdc_store, submatrices, typ, scale, comm, wildcard, colorbar, bgcolor, genericdict, genericdict_threshold)
pygsti.report.workspaceplots._mx_fn_from_elements(plaq, x, y, extra)
pygsti.report.workspaceplots._mx_fn_blank(plaq, x, y, unused)
pygsti.report.workspaceplots._mx_fn_errorrate(plaq, x, y, direct_gst_models)
pygsti.report.workspaceplots._mx_fn_directchi2(plaq, x, y, extra)
pygsti.report.workspaceplots._mx_fn_directlogl(plaq, x, y, extra)
pygsti.report.workspaceplots._mx_fn_dscmp(plaq, x, y, dscomparator)
pygsti.report.workspaceplots._mx_fn_dict(plaq, x, y, genericdict)
pygsti.report.workspaceplots._mx_fn_driftpv(plaq, x, y, instabilityanalyzertuple)
pygsti.report.workspaceplots._mx_fn_drifttvd(plaq, x, y, instabilityanalyzertuple)
pygsti.report.workspaceplots._outcome_to_str(x)
pygsti.report.workspaceplots._addl_mx_fn_outcomes(plaq, x, y, layout)
class pygsti.report.workspaceplots.GateMatrixPlot(ws, op_matrix, color_min=- 1.0, color_max=1.0, mx_basis=None, xlabel=None, ylabel=None, box_labels=False, colorbar=None, prec=0, mx_basis_y=None, scale=1.0, eb_matrix=None)

Bases: pygsti.report.workspace.WorkspacePlot

Plot of a operation matrix using colored boxes.

More specific than MatrixPlot because of basis formatting for x and y labels.

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • op_matrix (ndarray) – The operation matrix data to display.

  • color_min (float, optional) – Minimum value of the color scale.

  • color_max (float, optional) – Maximum value of the color scale.

  • mx_basis (str or Basis object, optional) – The basis, often of op_matrix, used to create the x-labels (and y-labels when mx_basis_y is None). Typically in {“pp”,”gm”,”std”,”qt”}. If you don’t want labels, leave as None.

  • xlabel (str, optional) – A x-axis label for the plot.

  • ylabel (str, optional) – A y-axis label for the plot.

  • box_labels (bool, optional) – Whether box labels are displayed.

  • colorbar (bool optional) – Whether to display a color bar to the right of the box plot. If None, then a colorbar is displayed when box_labels == False.

  • prec (int or {'compact','compacthp'}, optional) –

    Precision for box labels. Only relevant when box_labels == True. Allowed values are:

    • ’compact’ = round to nearest whole number using at most 3 characters

    • ’compacthp’ = show as much precision as possible using at most 3 characters

    • int >= 0 = fixed precision given by int

    • int < 0 = number of significant figures given by -int

  • mx_basis_y (str or Basis object, optional) – The basis, used to create the y-labels (for rows) when these are different from the x-labels. Typically in {“pp”,”gm”,”std”,”qt”}. If you don’t want labels, leave as None.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • eb_matrix (numpy array, optional) – An array, of the same size as op_matrix, which gives error bars to be be displayed in the hover info.

_create(self, op_matrix, color_min, color_max, mx_basis, xlabel, ylabel, box_labels, colorbar, prec, mx_basis_y, scale, eb_matrix)
class pygsti.report.workspaceplots.MatrixPlot(ws, matrix, color_min=- 1.0, color_max=1.0, xlabels=None, ylabels=None, xlabel=None, ylabel=None, box_labels=False, colorbar=None, colormap=None, prec=0, scale=1.0, grid='black')

Bases: pygsti.report.workspace.WorkspacePlot

Plot of a general matrix using colored boxes

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • matrix (ndarray) – The operation matrix data to display.

  • color_min (float) – Color scale minimum.

  • color_max (float) – Color scale maximum.

  • xlabels (list, optional) – List of (str) box labels along the x-axis.

  • ylabels (list, optional) – List of (str) box labels along the y-axis.

  • xlabel (str, optional) – A x-axis label for the plot.

  • ylabel (str, optional) – A y-axis label for the plot.

  • box_labels (bool, optional) – Whether box labels are displayed.

  • colorbar (bool optional) – Whether to display a color bar to the right of the box plot. If None, then a colorbar is displayed when box_labels == False.

  • colormap (Colormap, optional) – A color map object used to convert the numerical matrix values into colors.

  • prec (int or {'compact','compacthp'}, optional) –

    Precision for box labels. Only relevant when box_labels == True. Allowed values are:

    • ’compact’ = round to nearest whole number using at most 3 characters

    • ’compacthp’ = show as much precision as possible using at most 3 characters

    • int >= 0 = fixed precision given by int

    • int < 0 = number of significant figures given by -int

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • grid ({"white","black",None}) – What color grid lines, if any, to add to the plot. Advanced usage allows the addition of :N where N is an integer giving the line width.

_create(self, matrix, color_min, color_max, xlabels, ylabels, xlabel, ylabel, box_labels, colorbar, colormap, prec, scale, grid)
class pygsti.report.workspaceplots.PolarEigenvaluePlot(ws, evals_list, colors, labels=None, scale=1.0, amp=None, center_text=None)

Bases: pygsti.report.workspace.WorkspacePlot

Polar plot of complex eigenvalues

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • evals_list (list) – A list of eigenvalue arrays to display.

  • colors (list) – A corresponding list of color names to use for arrays given by evals_list (must have len(colors) == len(evals_list)). Colors can be standard names, e.g. “blue”, or rgb strings such as “rgb(23,92,64)”.

  • labels (list, optional) – A list of labels, one for each element of evals_list to be placed in the plot legend.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • amp (float, optional) – An amount to amplify (raise to the exponent amp) each set of eigenvalues. (Amplified eigenvalues are shown in the same color but with smaller markers.) If amp is None, no amplification is performed.

  • center_text (str, optional) – Text to be placed at the very center of the polar plot (sometimes useful to use as a title).

_create(self, evals_list, colors, labels, scale, amp, center_text)
class pygsti.report.workspaceplots.ProjectionsBoxPlot(ws, projections, projection_basis, color_min=None, color_max=None, box_labels=False, colorbar=None, prec='compacthp', scale=1.0, eb_matrix=None, title=None)

Bases: pygsti.report.workspace.WorkspacePlot

Plot of matrix of (usually error-generator) projections

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • projections (ndarray) – A 1-dimensional array of length equal to the numer of elements in the given basis (usually equal to the gate dimension). Ordering of the values is assumed to correspond to the ordering given by the routines in pygsti.tools, (e.g. pp_matrices() when projection_basis equals “pp”).

  • projection_basis ({'std', 'gm', 'pp', 'qt'}) – The basis is used to construct the error generators onto which the gate error generator is projected. Allowed values are Matrix-unit (std), Gell-Mann (gm), Pauli-product (pp) and Qutrit (qt).

  • color_min (float, optional) – Minimum value of the color scale. If None, then computed automatically from the data range.

  • color_max (float, optional) – Maximum value of the color scale. If None, then computed automatically from the data range.

  • box_labels (bool, optional) – Whether box labels are displayed.

  • colorbar (bool optional) – Whether to display a color bar to the right of the box plot. If None, then a colorbar is displayed when box_labels == False.

  • prec (int or {'compact','compacthp'}, optional) –

    Precision for box labels. Only relevant when box_labels == True. Allowed values are:

    • ’compact’ = round to nearest whole number using at most 3 characters

    • ’compacthp’ = show as much precision as possible using at most 3 characters

    • int >= 0 = fixed precision given by int

    • int < 0 = number of significant figures given by -int

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • eb_matrix (numpy array, optional) – An array, of the same size as projections, which gives error bars to be be displayed in the hover info.

  • title (str, optional) – A title for the plot

_create(self, projections, projection_basis, color_min, color_max, box_labels, colorbar, prec, scale, eb_matrix, title)
class pygsti.report.workspaceplots.ChoiEigenvalueBarPlot(ws, evals, errbars=None, scale=1.0)

Bases: pygsti.report.workspace.WorkspacePlot

Bar plot of eigenvalues showing red bars for negative values

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • evals (ndarray) – An array containing the eigenvalues to plot.

  • errbars (ndarray, optional) – An array containing the lengths of the error bars to place on each bar of the plot.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

_create(self, evals, errbars, scale)
class pygsti.report.workspaceplots.GramMatrixBarPlot(ws, dataset, target, maxlen=10, fixed_lists=None, scale=1.0)

Bases: pygsti.report.workspace.WorkspacePlot

Bar plot of Gram matrix eigenvalues stacked against those of target

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • dataset (DataSet) – The DataSet

  • target (Model) – A target model which is used for it’s mapping of SPAM labels to SPAM specifiers and for Gram matrix comparision.

  • maxlen (integer, optional) – The maximum length string used when searching for the maximal (best) Gram matrix. It’s useful to make this at least twice the maximum length fiducial sequence.

  • fixed_lists ((prep_fiducials, meas_fiducials), optional) – 2-tuple of circuit lists, specifying the preparation and measurement fiducials to use when constructing the Gram matrix, and thereby bypassing the search for such lists.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

_create(self, dataset, target, maxlen, fixed_lists, scale)
class pygsti.report.workspaceplots.FitComparisonBarPlot(ws, x_names, circuits_by_x, model_by_x, dataset_by_x, objfn_builder='logl', x_label='L', np_by_x=None, scale=1.0, comm=None, wildcard=None)

Bases: pygsti.report.workspace.WorkspacePlot

Bar plot showing the overall (aggregate) goodness of fit (along one dimension).

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • x_names (list) – List of x-values. Typically these are the integer maximum lengths or exponents used to index the different iterations of GST, but they can also be strings.

  • circuits_by_x (list of (CircuitLists or lists of Circuits)) – Specifies the set of circuits used at each x-value.

  • model_by_x (list of Models) – `Model`s corresponding to each x-value.

  • dataset_by_x (DataSet or list of DataSets) – The data sets to compare each model against. If a single DataSet is given, then it is used for all comparisons.

  • objfn_builder (ObjectiveFunctionBuilder or {"logl", "chi2"}, optional) – The objective function to use, or one of the given strings to use a defaut log-likelihood or chi^2 function.

  • x_label (str, optional) – A label for the ‘x’ variable which indexes the different models. This string will be the x-label of the resulting bar plot.

  • np_by_x (list of ints, optional) – A list of parameter counts to use for each x. If None, then the number of non-gauge parameters for each model is used.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • comm (mpi4py.MPI.Comm, optional) – When not None, an MPI communicator for distributing the computation across multiple processors.

  • wildcard (WildcardBudget) – A wildcard budget to apply to the objective function (objective), which increases the goodness of fit by adjusting (by an amount measured in TVD) the probabilities produced by a model before comparing with the frequencies in dataset. Currently, this functionality is only supported for objective == “logl”.

_create(self, x_names, circuits_by_x, model_by_x, dataset_by_x, objfn_builder, x_label, np_by_x, scale, comm, wildcard)
class pygsti.report.workspaceplots.FitComparisonBoxPlot(ws, xs, ys, circuits_by_y_then_x, model_by_y_then_x, dataset_by_y_then_x, objfn_builder='logl', x_label=None, y_label=None, scale=1.0, comm=None, wildcard=None)

Bases: pygsti.report.workspace.WorkspacePlot

Box plot showing the overall (aggregate) goodness of fit (along 2 dimensions).

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • xs (list) – List of X-values (converted to strings).

  • ys (list) – List of Y-values (converted to strings).

  • circuits_by_y_then_x (list of lists of PlaquetteGridCircuitStructure objects) – Specifies the circuits used at each Y and X value, indexed as circuits_by_y_then_x[iY][iX], where iX and iY are X and Y indices, respectively.

  • model_by_y_then_x (list of lists of Models) – `Model`s corresponding to each X and Y value.

  • dataset_by_y_then_x (list of lists of DataSets) – `DataSet`s corresponding to each X and Y value.

  • objfn_builder (ObjectiveFunctionBuilder or {"logl", "chi2"}, optional) – The objective function to use, or one of the given strings to use a defaut log-likelihood or chi^2 function.

  • x_label (str, optional) – Label for the ‘X’ variable which indexes different models. This string will be the x-label of the resulting box plot.

  • y_label (str, optional) – Label for the ‘Y’ variable which indexes different models. This string will be the y-label of the resulting box plot.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

  • comm (mpi4py.MPI.Comm, optional) – When not None, an MPI communicator for distributing the computation across multiple processors.

  • wildcard (WildcardBudget) – A wildcard budget to apply to the objective function (objective), which increases the goodness of fit by adjusting (by an amount measured in TVD) the probabilities produced by a model before comparing with the frequencies in dataset. Currently, this functionality is only supported for objective == “logl”.

_create(self, xs, ys, circuits_by_yx, model_by_yx, dataset_by_yx, objfn_builder, x_label, y_label, scale, comm, wildcard)
class pygsti.report.workspaceplots.DatasetComparisonSummaryPlot(ws, dslabels, dsc_dict, scale=1.0)

Bases: pygsti.report.workspace.WorkspacePlot

A grid of grayscale boxes comparing data sets pair-wise.

This class creates a plot showing the total 2*deltaLogL values for each pair of :class:`DataSet`s out of some number of total `DataSet`s.

Background: For every pair of data sets, the likelihood is computed for two different models: 1) the model in which a single set of probabilities (one per gate sequence, obtained by the combined outcome frequencies) generates both data sets, and 2) the model in which each data is generated from different sets of probabilities. Twice the ratio of these log-likelihoods can be compared to the value that is expected when model 1) is valid. This plot shows the difference between the expected and actual twice-log-likelihood ratio in units of standard deviations. Zero or negative values indicate the data sets appear to be generated by the same underlying probabilities. Large positive values indicate the data sets appear to be generated by different underlying probabilities.

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • dslabels (list) – A list of data set labels, specifying the ordering and the number of data sets.

  • dsc_dict (dict) – A dictionary of DataComparator objects whose keys are 2-tuples of integers such that the value associated with (i,j) is a DataComparator object that compares the i-th and j-th data sets (as indexed by dslabels.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

_create(self, dslabels, dsc_dict, scale)
class pygsti.report.workspaceplots.DatasetComparisonHistogramPlot(ws, dsc, nbins=50, frequency=True, log=True, display='pvalue', scale=1.0)

Bases: pygsti.report.workspace.WorkspacePlot

Histogram of p-values comparing two data sets

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • dsc (DataComparator) – The data set comparator, which holds and compares the data.

  • nbins (int, optional) – Bins in the histogram.

  • frequency (bool, optional) – Whether the frequencies (instead of the counts) are used. TODO: more detail.

  • log (bool, optional) – Whether to set a log-scale on the x-axis or not.

  • display ({'pvalue', 'llr'}, optional) – What quantity to display (in histogram).

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

_create(self, dsc, nbins, frequency, log, display, scale)
class pygsti.report.workspaceplots.RandomizedBenchmarkingPlot(ws, rb_r, fitkey=None, decay=True, success_probabilities=True, ylim=None, xlim=None, showpts=True, legend=True, title=None, scale=1.0)

Bases: pygsti.report.workspace.WorkspacePlot

Plot of RB Decay curve

Parameters
  • ws (Workspace) – The containing (parent) workspace.

  • rb_r (RandomizedBenchmarkingResults) – The RB results object containing all the relevant RB data.

  • fitkey (dict key, optional) – The key of the self.fits dictionary to plot the fit for. If None, will look for a ‘full’ key (the key for a full fit to A + Bp^m if the standard analysis functions are used) and plot this if possible. It otherwise checks that there is only one key in the dict and defaults to this. If there are multiple keys and none of them are ‘full’, fitkey must be specified when decay is True.

  • decay (bool, optional) – Whether to plot a fit, or just the data.

  • success_probabilities (bool, optional) – Whether to plot the success probabilities distribution, as a “box & whisker” plot.

  • ylim (tuple, optional) – The y limits for the figure.

  • xlim (tuple, optional) – The x limits for the figure.

  • showpts (bool, optional) – When success_probabilities == True, whether individual points should be shown along with a “box & whisker”.

  • legend (bool, optional) – Whether to show a legend.

  • title (str, optional) – A title to put on the figure.

  • scale (float, optional) – Scaling factor to adjust the size of the final figure.

_create(self, rb_r, fitkey, decay, success_probabilities, ylim, xlim, showpts, legend, title, scale)