pygsti.report

pyGSTi Reporting Python Package

Subpackages

Submodules

Package Contents

Classes

Notebook

Python representation of an IPython notebook

Report

The internal model of a report.

_ReportableQty

A computed quantity and possibly its error bars, primarily for use in reports.

_Basis

An ordered set of labeled matrices/vectors.

_DirectSumBasis

A basis that is the direct sum of one or more "component" bases.

_Lbl

A label used to identify a gate, circuit layer, or (sub-)circuit.

GateEigenvalues

Gate eigenvalues

CircuitEigenvalues

Circuit eigenvalues

CircuitHalfDiamondNorm

1/2 diamond norm of difference between productA(circuit) and productB(circuit)

HalfDiamondNorm

Half the diamond distance bewteen model_a.operations[op_label] and model_b.operations[op_label]

Workspace

Central to data analysis, Workspace objects facilitate the building of reports and dashboards.

Functions

_null_fn(*arg)

_project_to_valid_prob(p, tol=1e-09)

_make_reportable_qty_or_dict(f0, df=None, non_markovian_ebs=False)

Just adds special processing with f0 is a dict, where we

evaluate(model_fn, cri=None, verbosity=0)

Evaluate a ModelFunction object using confidence region information

spam_dotprods(rho_vecs, povms)

SPAM dot products (concatenates POVMS)

choi_matrix(gate, mx_basis)

Choi matrix

choi_eigenvalues(gate, mx_basis)

Choi matrix eigenvalues

choi_trace(gate, mx_basis)

Trace of the Choi matrix

rel_circuit_eigenvalues(model_a, model_b, circuit)

Eigenvalues of dot(productB(circuit)^-1, productA(circuit))

circuit_frobenius_diff(model_a, model_b, circuit)

Frobenius distance btwn productA(circuit) and productB(circuit)

circuit_entanglement_infidelity(model_a, model_b, circuit)

Entanglement infidelity btwn productA(circuit) and productB(circuit)

circuit_avg_gate_infidelity(model_a, model_b, circuit)

Average gate infidelity between productA(circuit) and productB(circuit).

circuit_jtrace_diff(model_a, model_b, circuit)

Jamiolkowski trace distance between productA(circuit) and productB(circuit)

circuit_nonunitary_entanglement_infidelity(model_a, model_b, circuit)

Nonunitary entanglement infidelity between productA(circuit) and productB(circuit)

circuit_nonunitary_avg_gate_infidelity(model_a, model_b, circuit)

Nonunitary average gate infidelity between productA(circuit) and productB(circuit).

circuit_eigenvalue_entanglement_infidelity(model_a, model_b, circuit)

Eigenvalue entanglement infidelity between productA(circuit) and productB(circuit).

circuit_eigenvalue_avg_gate_infidelity(model_a, model_b, circuit)

Eigenvalue average gate infidelity between productA(circuit) and productB(circuit).

circuit_eigenvalue_nonunitary_entanglement_infidelity(model_a, model_b, circuit)

Eigenvalue nonunitary entanglement infidelity between productA(circuit) and productB(circuit).

circuit_eigenvalue_nonunitary_avg_gate_infidelity(model_a, model_b, circuit)

Eigenvalue nonunitary average gate infidelity between productA(circuit) and productB(circuit).

circuit_eigenvalue_diamondnorm(model_a, model_b, circuit)

Eigenvalue diamond distance between productA(circuit) and productB(circuit).

circuit_eigenvalue_nonunitary_diamondnorm(model_a, model_b, circuit)

Eigenvalue nonunitary diamond distance between productA(circuit) and productB(circuit).

povm_entanglement_infidelity(model_a, model_b, povmlbl)

POVM entanglement infidelity between model_a and model_b.

povm_jtrace_diff(model_a, model_b, povmlbl)

POVM Jamiolkowski trace distance between model_a and model_b

povm_half_diamond_norm(model_a, model_b, povmlbl)

Half the POVM diamond distance between model_a and model_b.

decomposition(gate)

DEPRECATED: Decompose a 1Q gate into rotations about axes.

upper_bound_fidelity(gate, mx_basis)

Upper bound on entanglement fidelity

closest_ujmx(gate, mx_basis)

Jamiolkowski state of closest unitary to gate

maximum_fidelity(gate, mx_basis)

Fidelity between gate and its closest unitary

maximum_trace_dist(gate, mx_basis)

Jamiolkowski trace distance between gate and its closest unitary

angles_btwn_rotn_axes(model)

Array of angles between the rotation axes of the gates of model.

entanglement_fidelity(a, b, mx_basis)

Entanglement fidelity between a and b

entanglement_infidelity(a, b, mx_basis)

Entanglement infidelity between a and b

closest_unitary_fidelity(a, b, mx_basis)

Entanglement infidelity between closest unitaries to a and b

frobenius_diff(a, b, mx_basis)

Frobenius distance between a and b

jtrace_diff(a, b, mx_basis)

Jamiolkowski trace distance between a and b

std_unitarity(a, b, mx_basis)

a gauge-invariant quantity that behaves like the unitarity

eigenvalue_unitarity(a, b)

a gauge-invariant quantity that behaves like the unitarity

nonunitary_entanglement_infidelity(a, b, mx_basis)

Returns (d^2 - 1)/d^2 * (1 - sqrt(U)), where U is the unitarity of a*b^{-1}

nonunitary_avg_gate_infidelity(a, b, mx_basis)

Returns (d - 1)/d * (1 - sqrt(U)), where U is the unitarity of a*b^{-1}

eigenvalue_nonunitary_entanglement_infidelity(a, b, mx_basis)

Returns (d^2 - 1)/d^2 * (1 - sqrt(U)), where U is the eigenvalue-unitarity of a*b^{-1}

eigenvalue_nonunitary_avg_gate_infidelity(a, b, mx_basis)

Returns (d - 1)/d * (1 - sqrt(U)), where U is the eigenvalue-unitarity of a*b^{-1}

eigenvalue_entanglement_infidelity(a, b, mx_basis)

Eigenvalue entanglement infidelity between a and b

eigenvalue_avg_gate_infidelity(a, b, mx_basis)

Eigenvalue average gate infidelity between a and b

eigenvalue_diamondnorm(a, b, mx_basis)

Eigenvalue diamond distance between a and b

eigenvalue_nonunitary_diamondnorm(a, b, mx_basis)

Eigenvalue nonunitary diamond distance between a and b

avg_gate_infidelity(a, b, mx_basis)

Returns the average gate infidelity between a and b, where b is the "target" operation.

model_model_angles_btwn_axes(a, b, mx_basis)

Angle between the rotation axes of a and b (1-qubit gates)

rel_eigenvalues(a, b, mx_basis)

Eigenvalues of b^{-1} * a

rel_log_tig_eigenvalues(a, b, mx_basis)

Eigenvalues of log(b^{-1} * a)

rel_log_gti_eigenvalues(a, b, mx_basis)

Eigenvalues of log(a * b^{-1})

rel_log_diff_eigenvalues(a, b, mx_basis)

Eigenvalues of log(a) - log(b)

rel_gate_eigenvalues(a, b, mx_basis)

Eigenvalues of b^{-1} * a

errorgen_and_projections(errgen, mx_basis)

Project errgen on all of the standard sets of error generators.

log_tig_and_projections(a, b, mx_basis)

Projections of log(b^{-1}*a).

log_gti_and_projections(a, b, mx_basis)

Projections of log(a*b^{-1}).

log_diff_and_projections(a, b, mx_basis)

Projections of log(a)-log(b).

robust_log_gti_and_projections(model_a, model_b, synthetic_idle_circuits)

Projections of log(A*B^{-1}) using a gauge-robust technique.

general_decomposition(model_a, model_b)

Decomposition of gates in model_a using those in model_b as their targets.

average_gateset_infidelity(model_a, model_b)

Average model infidelity

predicted_rb_number(model_a, model_b)

Prediction of RB number based on estimated (A) and target (B) models

vec_fidelity(a, b, mx_basis)

State fidelity between state vectors a and b

vec_infidelity(a, b, mx_basis)

State infidelity fidelity between state vectors a and b

vec_trace_diff(a, b, mx_basis)

Trace distance between state vectors a and b

vec_as_stdmx(vec, mx_basis)

State vector as a standard density matrix

vec_as_stdmx_eigenvalues(vec, mx_basis)

Eigenvalues of the density matrix corresponding to a state vector

info_of_opfn_by_name(name)

Returns a nice human-readable name and tooltip for a given gate-function abbreviation.

evaluate_opfn_by_name(name, model, target_model, op_label_or_string, confidence_region_info)

Evaluates that gate-function named by the abbreviation name.

instrument_infidelity(a, b, mx_basis)

Infidelity between instruments a and b

instrument_half_diamond_norm(a, b, mx_basis)

The diamond norm distance between instruments a and b.

evaluate_instrumentfn_by_name(name, model, target_model, inst_label, confidence_region_info)

Evaluates that instrument-function named by the abbreviation name.

empty_volumetric_plot(figsize=None, y_values=None, x_values=None, title=None, xlabel='Depth', ylabel='Width')

Creates an empty volumetric plot with just the axes set.

_get_xy(data, y_values=None, x_values=None)

volumetric_plot(data, y_values=None, x_values=None, title=None, fig=None, ax=None, cmap=my_cmap, color=None, flagQV=False, qv_threshold=None, figsize=(10, 10), scale=1.0, centerscale=1.0, linescale=1.0, pass_threshold=0, show_threshold=0)

Creates a volumetric benchmarking plot.

volumetric_boundary_plot(data, y_values=None, x_values=None, boundary=None, threshold=0.5, missing_data_action='continue', monotonic=True, color='k', linewidth=4, linestyle='-', dashing=None, fig=None, ax=None, figsize=None, title=None, label=None)

Creates a volumetric benchmarking boundary plot, that displays boundary at which the given data

capability_region_plot(vbdataframe, metric='polarization', threshold=1 / _np.e, significance=0.05, figsize=(10, 10), scale=1.0, title=None, colors=None)

Creates a capability regions plot from a VBDataFrame. Default options creates plots like those shown

volumetric_distribution_plot(vbdataframe, metric='polarization', threshold=1 / _np.e, hypothesis_test='standard', significance=0.05, figsize=(10, 10), scale={'min': 1.95, 'mean': 1, 'max': 0.13}, title=None, cmap=my_cmap)

Creates volumetric benchmarking plots that display the maximum, mean and minimum of a given figure-of-merit (by

Attributes

_CVXPY_AVAILABLE

FINITE_DIFF_EPS

Spam_dotprods

Choi_matrix

Choi_evals

Choi_trace

Rel_circuit_eigenvalues

Circuit_fro_diff

Circuit_entanglement_infidelity

Circuit_avg_gate_infidelity

Circuit_jt_diff

Circuit_nonunitary_entanglement_infidelity

Circuit_nonunitary_avg_gate_infidelity

Circuit_eigenvalue_entanglement_infidelity

Circuit_eigenvalue_avg_gate_infidelity

Circuit_eigenvalue_nonunitary_entanglement_infidelity

Circuit_eigenvalue_nonunitary_avg_gate_infidelity

Circuit_eigenvalue_diamondnorm

Circuit_eigenvalue_nonunitary_diamondnorm

POVM_entanglement_infidelity

POVM_jt_diff

Upper_bound_fidelity

Closest_ujmx

Maximum_fidelity

Maximum_trace_dist

Angles_btwn_rotn_axes

Entanglement_fidelity

Entanglement_infidelity

Closest_unitary_fidelity

Fro_diff

Jt_diff

Nonunitary_entanglement_infidelity

Nonunitary_avg_gate_infidelity

Eigenvalue_nonunitary_entanglement_infidelity

Eigenvalue_nonunitary_avg_gate_infidelity

Eigenvalue_entanglement_infidelity

Eigenvalue_avg_gate_infidelity

Eigenvalue_diamondnorm

Eigenvalue_nonunitary_diamondnorm

Avg_gate_infidelity

Model_model_angles_btwn_axes

Rel_eigvals

Rel_logTiG_eigvals

Rel_logGTi_eigvals

Rel_logGmlogT_eigvals

Rel_gate_eigenvalues

LogTiG_and_projections

LogGTi_and_projections

LogGmlogT_and_projections

Robust_LogGTi_and_projections

General_decomposition

Average_gateset_infidelity

Predicted_rb_number

Vec_fidelity

Vec_infidelity

Vec_tr_diff

Vec_as_stdmx

Vec_as_stdmx_eigenvalues

Instrument_infidelity

Instrument_half_diamond_norm

blues

class pygsti.report.Notebook(cells=None, notebook_text_files=None)

Bases: object

Python representation of an IPython notebook

Parameters
  • cells (list, optional) – List of NotebookCell objects.

  • notebook_text_files (list, optional) – List of filenames (text files with ‘@@markdown’ or ‘@@code’ designating cells).

DefaultTemplate

The default template notebook to use (a .ipynb file).

Type

str

DefaultTemplate = Empty.ipynb
to_json_dict(self, template_filename=DefaultTemplate)

Using an existing (usually empty) notebook as a template, generate the json for a new notebook.

Parameters

template_filename (str, optional) – Name of an existing notebook file to build from

Returns

dict

save_to(self, output_filename, template_filename=DefaultTemplate)

Save this class to a file as a jupyter notebook

Parameters
  • output_filename (str) – File to save the output jupyter notebook to

  • template_filename (str, optional) – Name of an existing notebook file to build from

Returns

None

add(self, cell)

Add a cell to the notebook

Parameters

cell (NotebookCell object) – Cell to add.

Returns

None

add_block(self, block, cell_type)

Add a block to the notebook

Parameters
  • block (str) – block of either code or markdown

  • cell_type (str) – tag for the cell. Either ‘code’ or ‘markdown’

Returns

None

add_file(self, filename, cell_type)

Read in a cell block from a file

Parameters
  • filename (str) – filename containing either code or markdown

  • cell_type (str) – tag for the cell. Either ‘code’ or ‘markdown’

Returns

None

add_code(self, block)

Add code to notebook

Parameters

block (str) – Block of python code

Returns

None

add_markdown(self, block)

Add markdown to notebook

Parameters

block (str) – Block of markdown (or HTML)

Returns

None

add_code_file(self, filename)

Add a code file to the notebook

Parameters

filename (str) – name of file containing python code

Returns

None

add_markdown_file(self, filename)

Add a markdown file to the notebook

Parameters

filename (str) – name of file containing markdown

Returns

None

add_notebook_text(self, text)

Add custom formatted text to the notebook.

Text contains both python and markdown, with cells differentiated by @@code and @@markdown tags. At least one cell tag must be present for the file to be correctly parsed

Parameters

text (str) – notebook formatted text

Returns

None

add_notebook_text_file(self, filename)

Add a custom formatted text file to the notebook.

Text file contains both python and markdown, with cells differentiated by @@code and @@markdown tags. At least one cell tag must be present for the file to be correctly parsed

Parameters

filename (str) – name of file containing notebook formatted text

Returns

None

add_notebook_text_files(self, filenames)

Add multiple notebook text files to the notebook, in order

Parameters

filenames (list(str)) – names of file containing notebook formatted text

Returns

None

add_notebook_file(self, filename)

Append an .ipynb file to this notebook

Parameters

filename (str) – ipynb file to append

Returns

None

add_notebook_files(self, filenames)

Add multiple notebook files to the notebook, in order

Parameters

filenames (list(str)) – names of file containing ipynb json

Returns

None

launch_new(self, output_filename, template_filename=DefaultTemplate)

Save and then launch this notebook with a new Jupyter server.

Note that this function waits to return until the notebook server exists, and so is difficult to work with.

Parameters
  • output_filename (str) – filename to save this notebook to

  • template_filename (str, optional) – filename to build this notebook from (see save_to)

Returns

None

launch(self, output_filename, template_filename=DefaultTemplate, port='auto')

Save and then launch this notebook

Parameters
  • output_filename (str) – filename to save this notebook to

  • template_filename (str, optional) – filename to build this notebook from (see save_to)

  • port (int, optional) – Port to launch server on.

Returns

None

class pygsti.report.Report(templates, results, sections, flags, global_qtys, report_params, build_defaults=None, pdf_available=True, workspace=None)

The internal model of a report.

This class should never be instantiated directly. Instead, users should use the appropriate factory method in pygsti.report.factory.

Parameters
  • templates (dict (str -> Path-like)) – A map of the available report generation types (html, pdf, notebook) to template paths.

  • results (Results or similar) – The underlying Results-like object used to generate this report.

  • sections (iterable of Section) – Collection of sections to be built into the generated report.

  • flags (set of str) – Set of flags controlling aspects of report generation.

  • global_qtys (dict (str -> any)) – Key-value map of report quantities not tied to any specific section.

  • report_params (dict (str -> any)) – Key-value map of report quantities used when building sections.

  • build_defaults (dict (str -> any), optional) – Default values for the build_options parameter of this instance’s build methods. Defaults to an empty dict.

  • pdf_available (bool, optional) – True if the underlying results can be represented as a static PDF. If this report cannot be represented statically, write_pdf will raise. Defaults to True.

  • workspace (Workspace, optional) – A Workspace used for caching figure computation. By default, a new workspace will be used.

_build(self, build_options=None)

Render all sections to a map of report elements for templating

write_html(self, path, auto_open=False, link_to=None, connected=False, build_options=None, brevity=0, precision=None, resizable=True, autosize='initial', single_file=False, verbosity=0)

Write this report to the disk as a collection of HTML documents.

Parameters
  • path (str or path-like object) – The filesystem path of a directory to write the report to. If the specified directory does not exist, it will be created automatically

  • auto_open (bool, optional) – Whether the output file should be automatically opened in a web browser.

  • link_to (list, optional) – If not None, a list of one or more items from the set {“tex”, “pdf”, “pkl”} indicating whether or not to create and include links to Latex, PDF, and Python pickle files, respectively.

  • connected (bool, optional) – Whether output HTML should assume an active internet connection. If True, then the resulting HTML file size will be reduced because it will link to web resources (e.g. CDN libraries) instead of embedding them.

  • build_options (dict) – Dict of options for building plots. Expected values are defined during construction of this report object.

  • brevity (int, optional) –

    Amount of detail to include in the report. Larger values mean smaller “more briefr” reports, which reduce generation time, load time, and disk space consumption. In particular:

    • 1: Plots showing per-sequences quantities disappear at brevity=1

    • 2: Reference sections disappear at brevity=2

    • 3: Germ-level estimate tables disappear at brevity=3

    • 4: Everything but summary figures disappears at brevity=4

  • precision (int or dict, optional) – The amount of precision to display. A dictionary with keys “polar”, “sci”, and “normal” can separately specify the precision for complex angles, numbers in scientific notation, and everything else, respectively. If an integer is given, it this same value is taken for all precision types. If None, then {‘normal’: 6, ‘polar’: 3, ‘sci’: 0} is used.

  • resizable (bool, optional) – Whether plots and tables are made with resize handles and can be resized within the report.

  • autosize ({'none', 'initial', 'continual'}) – Whether tables and plots should be resized, either initially – i.e. just upon first rendering (“initial”) – or whenever the browser window is resized (“continual”).

  • single_file (bool, optional) – If true, the report will be written to a single HTML document, with external dependencies baked-in. This mode is not recommended for large reports, because this file can grow large enough that major web browsers may struggle to render it.

  • verbosity (int, optional) – Amount of detail to print to stdout.

write_notebook(self, path, auto_open=False, connected=False, verbosity=0)

Write this report to the disk as an IPython notebook

A notebook report allows the user to interact more flexibly with the data underlying the figures, and to easily generate customized variants on the figures. As such, this type of report will be most useful for experts who want to tinker with the standard analysis presented in the static HTML or LaTeX format reports.

Parameters
  • path (str or path-like object) – The filesystem path to write the report to. By convention, this should use the .ipynb file extension.

  • auto_open (bool, optional) – If True, automatically open the report in a web browser after it has been generated.

  • connected (bool, optional) – Whether output notebook should assume an active internet connection. If True, then the resulting file size will be reduced because it will link to web resources (e.g. CDN libraries) instead of embedding them.

  • verbosity (int, optional) – How much detail to send to stdout.

write_pdf(self, path, latex_cmd='pdflatex', latex_flags=None, build_options=None, brevity=0, precision=None, auto_open=False, comm=None, verbosity=0)

Write this report to the disk as a PDF document.

Parameters
  • path (str or path-like object) – The filesystem path to write the report to. By convention, this should use the .pdf file extension.

  • latex_cmd (str, optional) – Shell command to run to compile a PDF document from the generated LaTeX source.

  • latex_flags ([str], optional) – List of flags to pass when calling latex_cmd.

  • build_options (dict) – Dict of options for building plots. Expected values are defined during construction of this report object.

  • brevity (int, optional) –

    Amount of detail to include in the report. Larger values mean smaller “more briefr” reports, which reduce generation time, load time, and disk space consumption. In particular:

    • 1: Plots showing per-sequences quantities disappear at brevity=1

    • 2: Reference sections disappear at brevity=2

    • 3: Germ-level estimate tables disappear at brevity=3

    • 4: Everything but summary figures disappears at brevity=4

  • precision (int or dict, optional) – The amount of precision to display. A dictionary with keys “polar”, “sci”, and “normal” can separately specify the precision for complex angles, numbers in scientific notation, and everything else, respectively. If an integer is given, it this same value is taken for all precision types. If None, then {‘normal’: 6, ‘polar’: 3, ‘sci’: 0} is used.

  • auto_open (bool, optional) – Whether the output file should be automatically opened in a web browser.

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

  • verbosity (int, optional) – Amount of detail to print to stdout.

class pygsti.report._ReportableQty(value, errbar=None, non_markovian_ebs=False)

Bases: object

A computed quantity and possibly its error bars, primarily for use in reports.

Parameters
  • value (object) – The value, usually a float or numpy array.

  • errbar (object, optional) – The (symmetric) error bar on value. If value is an array, errbar has the same shape. None is used to signify “no error bars”.

  • non_markovian_ebs (bool, optional) – Whether these error bars are “non-markovian”-type error bars (it can be useful to keep track of this for formatting).

size

Returns the size of this ReportableQty’s value.

Type

int

__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

__add__(self, x)
__mul__(self, x)
__truediv__(self, x)
__getstate__(self)
__setstate__(self, d)
__copy__(self)
__deepcopy__(self, memo)
log(self)

Returns a ReportableQty that is the logarithm of this one.

Returns

ReportableQty

real(self)

Returns a ReportableQty that is the real part of this one.

Returns

ReportableQty

imag(self)

Returns a ReportableQty that is the imaginary part of this one.

Returns

ReportableQty

absdiff(self, constant_value, separate_re_im=False)

Create a ReportableQty that is the difference between constant_value and this one.

The returned quantity’s value is given by (element-wise in the vector case):

abs(self - constant_value).

Parameters
  • constant_value (float or numpy.ndarray) – The constant value to use.

  • separate_re_im (bool, optional) – When True, two separate real- and imaginary-part ReportableQty objects are returned (applicable to complex-valued quantities).

Returns

ReportableQty or tuple – The output ReportableQty`(s). If `separate_re_im=True then a 2-tuple of (real-part, imaginary-part) quantities is returned. Otherwise a single quantity is returned.

infidelity_diff(self, constant_value)

Creates a ReportableQty that is the difference between constant_value and this one.

The returned quantity’s value is given by (element-wise in the vector case):

1.0 - Re(conjugate(constant_value) * self )

Parameters

constant_value (float or numpy.ndarray) – The constant value to use.

Returns

ReportableQty

mod(self, x)

Creates a ReportableQty that holds this_qty mod x.

That is, the value and error bar (if present) are modulus-divided by x.

Parameters

x (int) – Value to modulus-divide by.

Returns

ReportableQty

hermitian_to_real(self)

Creates a ReportableQty that holds a real “version” of a Hermitian matrix.

Specifically, the returned quantity’s value is the real matrix whose upper/lower triangle contains the real/imaginary parts of the corresponding off-diagonal matrix elements of the Hermitian matrix stored in this ReportableQty.

This is used for display purposes. If this object doesn’t contain a Hermitian matrix, ValueError is raised.

Returns

ReportableQty

reshape(self, *args)

Returns a ReportableQty whose underlying values are reshaped.

Returns

ReportableQty

property size(self)

Returns the size of this ReportableQty’s value.

Returns

int

static from_val(value, non_markovian_ebs=False)

Convert Table values into ReportableQtys or leave them be if they are well-formed types.

Well-formed types include: - strings - figures - :class:`ReportableQty`s

A tuple will be converted to a ReportableQty holding the first field as a value and second field as an error bar. Anything else will be converted to a ReportableQty with no error bars.

Parameters
  • value (object) – The value to convert.

  • non_markovian_ebs (bool, optional) – Whether the error bars are of the “non-markovian”-type.

Returns

ReportableQty

property has_errorbar(self)

Return whether this quantity is storing an error bar (bool).

Returns

bool

scale_inplace(self, factor)

Scale the value and error bar (if present) by factor.

Parameters

factor (float) – The scaling factor.

Returns

None

property value(self)

Returns the quantity’s value

Returns

object – Usually a float or numpy array.

property errorbar(self)

Returns the quantity’s error bar(s)

Returns

object – Usually a float or numpy array.

property value_and_errorbar(self)

Returns the quantity’s value and error bar(s)

Returns

  • value (object) – This object’s value (usually a float or numpy array).

  • error_bar (object) – This object’s value (usually a float or numpy array).

render_with(self, f, specs=None, ebstring='%s +/- %s', nmebstring=None)

Render this ReportableQty using the function f.

Parameters
  • f (function) – The formatter function which separately converts the stored value and error bar (if present) to string quantities that are then formatted using ebstring, nmebstring or just “%s” (if there’s no error bar). This function must have the signature f(val, specs) where val is either the value or error bar and specs is a dictionary given by the next argument.

  • specs (dict, optional) – Additional parameters to pass to the formatter function f.

  • ebstring (str, optional) – format string that describes how to display the value and error bar after they are rendered as string (ebstring should have two `%s`s in it).

  • nmebstring (str, optional) – format string, similar to ebstring, for displaying non-Markovian error bars (if None then ebstring is used).

Returns

str

class pygsti.report._Basis(name, longname, real, sparse)

Bases: pygsti.baseobjs.nicelyserializable.NicelySerializable

An ordered set of labeled matrices/vectors.

The base class for basis objects. A basis in pyGSTi is an abstract notion of a set of labeled elements, or “vectors”. Each basis has a certain size, and has .elements, .labels, and .ellookup members, the latter being a dictionary mapping of labels to elements.

An important point to note that isn’t immediately intuitive is that while Basis object holds elements (in its .elements property) these are not the same as its vectors (given by the object’s vector_elements property). Often times, in what we term a “simple” basis, the you just flatten an element to get the corresponding vector-element. This works for bases where the elements are either vectors (where flattening does nothing) and matrices. By storing elements as distinct from vector_elements, the Basis can capture additional structure of the elements (such as viewing them as matrices) that can be helpful for their display and interpretation. The elements are also sometimes referred to as the “natural elements” because they represent how to display the element in a natrual way. A non-simple basis occurs when vector_elements need to be stored as elements in a larger “embedded” way so that these elements can be displayed and interpeted naturally.

A second important note is that there is assumed to be some underlying “standard” basis underneath all the bases in pyGSTi. The elements in a Basis are always written in this standard basis. In the case of the “std”-named basis in pyGSTi, these elements are just the trivial vector or matrix units, so one can rightly view the “std” pyGSTi basis as the “standard” basis for a that particular dimension.

The arguments below describe the basic properties of all basis objects in pyGSTi. It is important to remember that the vector_elements of a basis are different from its elements (see the Basis docstring), and that dim refers to the vector elements whereas elshape refers to the elements.

For example, consider a 2-element Basis containing the I and X Pauli matrices. The size of this basis is 2, as there are two elements (and two vector elements). Since vector elements are the length-4 flattened Pauli matrices, the dimension (dim) is 4. Since the elements are 2x2 Pauli matrices, the elshape is (2,2).

As another example consider a basis which spans all the diagonal 2x2 matrices. The elements of this basis are the two matrix units with a 1 in the (0,0) or (1,1) location. The vector elements, however, are the length-2 [1,0] and [0,1] vectors obtained by extracting just the diagonal entries from each basis element. Thus, for this basis, size=2, dim=2, and elshape=(2,2) - so the dimension is not just the product of elshape entries (equivalently, elsize).

Parameters
  • name (string) – The name of the basis. This can be anything, but is usually short and abbreviated. There are several types of bases built into pyGSTi that can be constructed by this name.

  • longname (string) – A more descriptive name for the basis.

  • real (bool) – Elements and vector elements are always allowed to have complex entries. This argument indicates whether the coefficients in the expression of an arbitrary vector in this basis must be real. For example, if real=True, then when pyGSTi transforms a vector in some other basis to a vector in this basis, it will demand that the values of that vector (i.e. the coefficients which multiply this basis’s elements to obtain a vector in the “standard” basis) are real.

  • sparse (bool) – Whether the elements of .elements for this Basis are stored (when they are stored at all) as sparse matrices or vectors.

dim

The dimension of the vector space this basis fully or partially spans. Equivalently, the length of the vector_elements of the basis.

Type

int

size

The number of elements (or vector-elements) in the basis.

Type

int

elshape

The shape of each element. Typically either a length-1 or length-2 tuple, corresponding to vector or matrix elements, respectively. Note that vector elements always have shape (dim,) (or (dim,1) in the sparse case).

Type

int

elndim

The number of element dimensions, i.e. len(self.elshape)

Type

int

elsize

The total element size, i.e. product(self.elshape)

Type

int

vector_elements

The “vectors” of this basis, always 1D (sparse or dense) arrays.

Type

list

classmethod cast(cls, name_or_basis_or_matrices, dim=None, sparse=None, classical_name='cl')

Convert various things that can describe a basis into a Basis object.

Parameters
  • name_or_basis_or_matrices (various) –

    Can take on a variety of values to produce different types of bases:

    • None: an empty ExpicitBasis

    • Basis: checked with dim and sparse and passed through.

    • str: BuiltinBasis or DirectSumBasis with the given name.

    • list: an ExplicitBasis if given matrices/vectors or a

      DirectSumBasis if given a (name, dim) pairs.

  • dim (int or StateSpace, optional) – The dimension of the basis to create. Sometimes this can be inferred based on name_or_basis_or_matrices, other times it must be supplied. This is the dimension of the space that this basis fully or partially spans. This is equal to the number of basis elements in a “full” (ordinary) basis. When a StateSpace object is given, a more detailed direct-sum-of-tensor-product-blocks structure for the state space (rather than a single dimension) is described, and a basis is produced for this space. For instance, a DirectSumBasis basis of TensorProdBasis components can result when there are multiple tensor-product blocks and these blocks consist of multiple factors.

  • sparse (bool, optional) – Whether the resulting basis should be “sparse”, meaning that its elements will be sparse rather than dense matrices.

  • classical_name (str, optional) – An alternate builtin basis name that should be used when constructing the bases for the classical sectors of dim, when dim is a StateSpace object.

Returns

Basis

property dim(self)

The dimension of the vector space this basis fully or partially spans. Equivalently, the length of the vector_elements of the basis.

property size(self)

The number of elements (or vector-elements) in the basis.

property elshape(self)

The shape of each element. Typically either a length-1 or length-2 tuple, corresponding to vector or matrix elements, respectively. Note that vector elements always have shape (dim,) (or (dim,1) in the sparse case).

property elndim(self)

The number of element dimensions, i.e. len(self.elshape)

Returns

int

property elsize(self)

The total element size, i.e. product(self.elshape)

Returns

int

is_simple(self)

Whether the flattened-element vector space is the same space as the space this basis’s vectors belong to.

Returns

bool

is_complete(self)

Whether this is a complete basis, i.e. this basis’s vectors span the entire space that they live in.

Returns

bool

is_partial(self)

The negative of :method:`is_complete`, effectively “is_incomplete”.

Returns

bool

property vector_elements(self)

The “vectors” of this basis, always 1D (sparse or dense) arrays.

Returns

list – A list of 1D arrays.

copy(self)

Make a copy of this Basis object.

Returns

Basis

with_sparsity(self, desired_sparsity)

Returns either this basis or a copy of it with the desired sparsity.

If this basis has the desired sparsity it is simply returned. If not, this basis is copied to one that does.

Parameters

desired_sparsity (bool) – The sparsity (True for sparse elements, False for dense elements) that is desired.

Returns

Basis

abstract _copy_with_toggled_sparsity(self)
__str__(self)

Return str(self).

__getitem__(self, index)
__len__(self)
__eq__(self, other)

Return self==value.

create_transform_matrix(self, to_basis)

Get the matrix that transforms a vector from this basis to to_basis.

Parameters

to_basis (Basis or string) – The basis to transform to or a built-in basis name. In the latter case, a basis to transform to is built with the same structure as this basis but with all components constructed from the given name.

Returns

numpy.ndarray (even if basis is sparse)

reverse_transform_matrix(self, from_basis)

Get the matrix that transforms a vector from from_basis to this basis.

The reverse of :method:`create_transform_matrix`.

Parameters

from_basis (Basis or string) – The basis to transform from or a built-in basis name. In the latter case, a basis to transform from is built with the same structure as this basis but with all components constructed from the given name.

Returns

numpy.ndarray (even if basis is sparse)

is_normalized(self)

Check if a basis is normalized, meaning that Tr(Bi Bi) = 1.0.

Available only to bases whose elements are matrices for now.

Returns

bool

property to_std_transform_matrix(self)

Retrieve the matrix that transforms a vector from this basis to the standard basis of this basis’s dimension.

Returns

numpy array or scipy.sparse.lil_matrix – An array of shape (dim, size) where dim is the dimension of this basis (the length of its vectors) and size is the size of this basis (its number of vectors).

property from_std_transform_matrix(self)

Retrieve the matrix that transforms vectors from the standard basis to this basis.

Returns

numpy array or scipy sparse matrix – An array of shape (size, dim) where dim is the dimension of this basis (the length of its vectors) and size is the size of this basis (its number of vectors).

property to_elementstd_transform_matrix(self)

Get transformation matrix from this basis to the “element space”.

Get the matrix that transforms vectors in this basis (with length equal to the dim of this basis) to vectors in the “element space” - that is, vectors in the same standard basis that the elements of this basis are expressed in.

Returns

numpy array – An array of shape (element_dim, size) where element_dim is the dimension, i.e. size, of the elements of this basis (e.g. 16 if the elements are 4x4 matrices) and size is the size of this basis (its number of vectors).

property from_elementstd_transform_matrix(self)

Get transformation matrix from “element space” to this basis.

Get the matrix that transforms vectors in the “element space” - that is, vectors in the same standard basis that the elements of this basis are expressed in - to vectors in this basis (with length equal to the dim of this basis).

Returns

numpy array – An array of shape (size, element_dim) where element_dim is the dimension, i.e. size, of the elements of this basis (e.g. 16 if the elements are 4x4 matrices) and size is the size of this basis (its number of vectors).

create_equivalent(self, builtin_basis_name)

Create an equivalent basis with components of type builtin_basis_name.

Create a Basis that is equivalent in structure & dimension to this basis but whose simple components (perhaps just this basis itself) is of the builtin basis type given by builtin_basis_name.

Parameters

builtin_basis_name (str) – The name of a builtin basis, e.g. “pp”, “gm”, or “std”. Used to construct the simple components of the returned basis.

Returns

Basis

create_simple_equivalent(self, builtin_basis_name=None)

Create a basis of type builtin_basis_name whose elements are compatible with this basis.

Create a simple basis and one without components (e.g. a TensorProdBasis, is a simple basis w/components) of the builtin type specified whose dimension is compatible with the elements of this basis. This function might also be named “element_equivalent”, as it returns the builtin_basis_name-analogue of the standard basis that this basis’s elements are expressed in.

Parameters

builtin_basis_name (str, optional) – The name of the built-in basis to use. If None, then a copy of this basis is returned (if it’s simple) or this basis’s name is used to try to construct a simple and component-free version of the same builtin-basis type.

Returns

Basis

is_compatible_with_state_space(self, state_space)

Checks whether this basis is compatible with a given state space.

Parameters

state_space (StateSpace) – the state space to check.

Returns

bool

class pygsti.report._DirectSumBasis(component_bases, name=None, longname=None)

Bases: LazyBasis

A basis that is the direct sum of one or more “component” bases.

Elements of this basis are the union of the basis elements on each component, each embedded into a common block-diagonal structure where each component occupies its own block. Thus, when there is more than one component, a DirectSumBasis is not a simple basis because the size of its elements is larger than the size of its vector space (which corresponds to just the diagonal blocks of its elements).

Parameters
  • component_bases (iterable) – A list of the component bases. Each list elements may be either a Basis object or a tuple of arguments to :function:`Basis.cast`, e.g. (‘pp’,4).

  • name (str, optional) – The name of this basis. If None, the names of the component bases joined with “+” is used.

  • longname (str, optional) – A longer description of this basis. If None, then a long name is automatically generated.

vector_elements

The “vectors” of this basis, always 1D (sparse or dense) arrays.

Type

list

_to_nice_serialization(self)
classmethod _from_nice_serialization(cls, state)
property dim(self)

The dimension of the vector space this basis fully or partially spans. Equivalently, the length of the vector_elements of the basis.

property size(self)

The number of elements (or vector-elements) in the basis.

property elshape(self)

The shape of each element. Typically either a length-1 or length-2 tuple, corresponding to vector or matrix elements, respectively. Note that vector elements always have shape (dim,) (or (dim,1) in the sparse case).

__hash__(self)

Return hash(self).

_lazy_build_vector_elements(self)
_lazy_build_elements(self)
_lazy_build_labels(self)
_copy_with_toggled_sparsity(self)
__eq__(self, other)

Return self==value.

property vector_elements(self)

The “vectors” of this basis, always 1D (sparse or dense) arrays.

Returns

list

property to_std_transform_matrix(self)

Retrieve the matrix that transforms a vector from this basis to the standard basis of this basis’s dimension.

Returns

numpy array or scipy.sparse.lil_matrix – An array of shape (dim, size) where dim is the dimension of this basis (the length of its vectors) and size is the size of this basis (its number of vectors).

property to_elementstd_transform_matrix(self)

Get transformation matrix from this basis to the “element space”.

Get the matrix that transforms vectors in this basis (with length equal to the dim of this basis) to vectors in the “element space” - that is, vectors in the same standard basis that the elements of this basis are expressed in.

Returns

numpy array – An array of shape (element_dim, size) where element_dim is the dimension, i.e. size, of the elements of this basis (e.g. 16 if the elements are 4x4 matrices) and size is the size of this basis (its number of vectors).

create_equivalent(self, builtin_basis_name)

Create an equivalent basis with components of type builtin_basis_name.

Create a Basis that is equivalent in structure & dimension to this basis but whose simple components (perhaps just this basis itself) is of the builtin basis type given by builtin_basis_name.

Parameters

builtin_basis_name (str) – The name of a builtin basis, e.g. “pp”, “gm”, or “std”. Used to construct the simple components of the returned basis.

Returns

DirectSumBasis

create_simple_equivalent(self, builtin_basis_name=None)

Create a basis of type builtin_basis_name whose elements are compatible with this basis.

Create a simple basis and one without components (e.g. a TensorProdBasis, is a simple basis w/components) of the builtin type specified whose dimension is compatible with the elements of this basis. This function might also be named “element_equivalent”, as it returns the builtin_basis_name-analogue of the standard basis that this basis’s elements are expressed in.

Parameters

builtin_basis_name (str, optional) – The name of the built-in basis to use. If None, then a copy of this basis is returned (if it’s simple) or this basis’s name is used to try to construct a simple and component-free version of the same builtin-basis type.

Returns

Basis

class pygsti.report._Lbl

Bases: object

A label used to identify a gate, circuit layer, or (sub-)circuit.

A label consisting of a string along with a tuple of integers or sector-names specifying which qubits, or more generally, parts of the Hilbert space that is acted upon by an object so-labeled.

property depth(self)

The depth of this label, viewed as a sub-circuit.

property reps(self)

Number of repetitions (of this label’s components) that this label represents.

property has_nontrivial_components(self)
collect_args(self)
strip_args(self)
expand_subcircuits(self)

Expand any sub-circuits within this label.

Returns a list of component labels which doesn’t include any CircuitLabel labels. This effectively expands any “boxes” or “exponentiation” within this label.

Returns

tuple – A tuple of component Labels (none of which should be :class:`CircuitLabel`s).

pygsti.report._CVXPY_AVAILABLE
pygsti.report.FINITE_DIFF_EPS = 1e-07
pygsti.report._null_fn(*arg)
pygsti.report._project_to_valid_prob(p, tol=1e-09)
pygsti.report._make_reportable_qty_or_dict(f0, df=None, non_markovian_ebs=False)

Just adds special processing with f0 is a dict, where we return a dict or ReportableQtys rather than a single ReportableQty of the dict.

pygsti.report.evaluate(model_fn, cri=None, verbosity=0)

Evaluate a ModelFunction object using confidence region information

Parameters
  • model_fn (ModelFunction) – The function to evaluate

  • cri (ConfidenceRegionFactoryView, optional) – View for computing confidence intervals.

  • verbosity (int, optional) – Amount of detail to print to stdout.

Returns

ReportableQty or dict – If model_fn does returns a dict of ReportableQty objects, otherwise a single ReportableQty.

pygsti.report.spam_dotprods(rho_vecs, povms)

SPAM dot products (concatenates POVMS)

Parameters
  • rho_vecs (list) – A list of State objects.

  • povms (list) – A list of POVM objects.

Returns

numpy.ndarray – A 2D array of shape (len(rho_vecs), num_evecs) where num_evecs is the total number of effect vectors in all of povms.

pygsti.report.Spam_dotprods
pygsti.report.choi_matrix(gate, mx_basis)

Choi matrix

Parameters
  • gate (numpy.ndarray) – the transfer-matrix specifying a gate’s action.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that gate is in.

Returns

numpy.ndarray

pygsti.report.Choi_matrix
pygsti.report.choi_eigenvalues(gate, mx_basis)

Choi matrix eigenvalues

Parameters
  • gate (numpy.ndarray) – the transfer-matrix specifying a gate’s action.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that gate is in.

Returns

numpy.ndarray

pygsti.report.Choi_evals
pygsti.report.choi_trace(gate, mx_basis)

Trace of the Choi matrix

Parameters
  • gate (numpy.ndarray) – the transfer-matrix specifying a gate’s action.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that gate is in.

Returns

float

pygsti.report.Choi_trace
class pygsti.report.GateEigenvalues(model, oplabel)

Bases: pygsti.report.modelfunction.ModelFunction

Gate eigenvalues

Parameters
  • model (Model) – Model gate is contained within.

  • oplabel (Label) – The gate’s label within model.

evaluate(self, model)

Evaluate at model

Parameters

model (Model) – A model nearby in parameter space.

Returns

numpy.ndarray

evaluate_nearby(self, nearby_model)

Evaluate at a nearby model

Parameters

nearby_model (Model) – A model nearby in parameter space.

Returns

numpy.ndarray

class pygsti.report.CircuitEigenvalues(model, circuit)

Bases: pygsti.report.modelfunction.ModelFunction

Circuit eigenvalues

Parameters
  • model (Model) – Model used to evaluate circuit.

  • circuit (Circuit) – The circuit whose process matrix we want the eigenvalues of.

evaluate(self, model)

Evaluate at model

Parameters

model (Model) – Model to evaluate at.

Returns

numpy.ndarray

evaluate_nearby(self, nearby_model)

Evaluate at nearby model

Parameters

nearby_model (Model) – A model nearby in parameter space.

Returns

numpy.ndarray

pygsti.report.rel_circuit_eigenvalues(model_a, model_b, circuit)

Eigenvalues of dot(productB(circuit)^-1, productA(circuit))

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

numpy.ndarray

pygsti.report.Rel_circuit_eigenvalues
pygsti.report.circuit_frobenius_diff(model_a, model_b, circuit)

Frobenius distance btwn productA(circuit) and productB(circuit)

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_fro_diff
pygsti.report.circuit_entanglement_infidelity(model_a, model_b, circuit)

Entanglement infidelity btwn productA(circuit) and productB(circuit)

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_entanglement_infidelity
pygsti.report.circuit_avg_gate_infidelity(model_a, model_b, circuit)

Average gate infidelity between productA(circuit) and productB(circuit).

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_avg_gate_infidelity
pygsti.report.circuit_jtrace_diff(model_a, model_b, circuit)

Jamiolkowski trace distance between productA(circuit) and productB(circuit)

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_jt_diff
class pygsti.report.CircuitHalfDiamondNorm(model_a, model_b, circuit)

Bases: pygsti.report.modelfunction.ModelFunction

1/2 diamond norm of difference between productA(circuit) and productB(circuit)

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

evaluate(self, model)

Evaluate this function at model

Parameters

model (Model) – Model to evaluate at.

Returns

float

evaluate_nearby(self, nearby_model)

Evaluate at a nearby model

Parameters

nearby_model (Model) – A model nearby in parameter space.

Returns

float

pygsti.report.circuit_nonunitary_entanglement_infidelity(model_a, model_b, circuit)

Nonunitary entanglement infidelity between productA(circuit) and productB(circuit)

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_nonunitary_entanglement_infidelity
pygsti.report.circuit_nonunitary_avg_gate_infidelity(model_a, model_b, circuit)

Nonunitary average gate infidelity between productA(circuit) and productB(circuit).

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_nonunitary_avg_gate_infidelity
pygsti.report.circuit_eigenvalue_entanglement_infidelity(model_a, model_b, circuit)

Eigenvalue entanglement infidelity between productA(circuit) and productB(circuit).

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_eigenvalue_entanglement_infidelity
pygsti.report.circuit_eigenvalue_avg_gate_infidelity(model_a, model_b, circuit)

Eigenvalue average gate infidelity between productA(circuit) and productB(circuit).

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_eigenvalue_avg_gate_infidelity
pygsti.report.circuit_eigenvalue_nonunitary_entanglement_infidelity(model_a, model_b, circuit)

Eigenvalue nonunitary entanglement infidelity between productA(circuit) and productB(circuit).

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_eigenvalue_nonunitary_entanglement_infidelity
pygsti.report.circuit_eigenvalue_nonunitary_avg_gate_infidelity(model_a, model_b, circuit)

Eigenvalue nonunitary average gate infidelity between productA(circuit) and productB(circuit).

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_eigenvalue_nonunitary_avg_gate_infidelity
pygsti.report.circuit_eigenvalue_diamondnorm(model_a, model_b, circuit)

Eigenvalue diamond distance between productA(circuit) and productB(circuit).

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_eigenvalue_diamondnorm
pygsti.report.circuit_eigenvalue_nonunitary_diamondnorm(model_a, model_b, circuit)

Eigenvalue nonunitary diamond distance between productA(circuit) and productB(circuit).

Parameters
  • model_a (Model) – The first model (to evaluate productA)

  • model_b (Model) – The second model (to evaluate productB)

  • circuit (Circuit) – The circuit.

Returns

float

pygsti.report.Circuit_eigenvalue_nonunitary_diamondnorm
pygsti.report.povm_entanglement_infidelity(model_a, model_b, povmlbl)

POVM entanglement infidelity between model_a and model_b.

Equal to 1 - entanglement_fidelity(POVM_MAP) where POVM_MAP is the extension of the POVM from the classical space of k-outcomes to the space of (diagonal) k by k density matrices.

Parameters
  • model_a (Model) – The first model.

  • model_b (Model) – The second model.

  • povmlbl (Label) – The POVM label (must be present in both models).

Returns

float

pygsti.report.POVM_entanglement_infidelity
pygsti.report.povm_jtrace_diff(model_a, model_b, povmlbl)

POVM Jamiolkowski trace distance between model_a and model_b

Equal to Jamiolkowski_trace_distance(POVM_MAP) where POVM_MAP is the extension of the POVM from the classical space of k-outcomes to the space of (diagonal) k by k density matrices.

Parameters
  • model_a (Model) – The first model.

  • model_b (Model) – The second model.

  • povmlbl (Label) – The POVM label (must be present in both models).

Returns

float

pygsti.report.POVM_jt_diff
pygsti.report.povm_half_diamond_norm(model_a, model_b, povmlbl)

Half the POVM diamond distance between model_a and model_b.

Equal to half_diamond_dist(POVM_MAP) where POVM_MAP is the extension of the POVM from the classical space of k-outcomes to the space of (diagonal) k by k density matrices.

Parameters
  • model_a (Model) – The first model.

  • model_b (Model) – The second model.

  • povmlbl (Label) – The POVM label (must be present in both models).

Returns

float

pygsti.report.decomposition(gate)

DEPRECATED: Decompose a 1Q gate into rotations about axes.

Parameters

gate (numpy.ndarray) – the transfer-matrix specifying a gate’s action.

Returns

ReportableQty

pygsti.report.upper_bound_fidelity(gate, mx_basis)

Upper bound on entanglement fidelity

Parameters
  • gate (numpy.ndarray) – the transfer-matrix specifying a gate’s action.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that gate is in.

Returns

float

pygsti.report.Upper_bound_fidelity
pygsti.report.closest_ujmx(gate, mx_basis)

Jamiolkowski state of closest unitary to gate

Parameters
  • gate (numpy.ndarray) – the transfer-matrix specifying a gate’s action.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that gate is in.

Returns

float

pygsti.report.Closest_ujmx
pygsti.report.maximum_fidelity(gate, mx_basis)

Fidelity between gate and its closest unitary

Parameters
  • gate (numpy.ndarray) – the transfer-matrix specifying a gate’s action.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that gate is in.

Returns

float

pygsti.report.Maximum_fidelity
pygsti.report.maximum_trace_dist(gate, mx_basis)

Jamiolkowski trace distance between gate and its closest unitary

Parameters
  • gate (numpy.ndarray) – the transfer-matrix specifying a gate’s action.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that gate is in.

Returns

float

pygsti.report.Maximum_trace_dist
pygsti.report.angles_btwn_rotn_axes(model)

Array of angles between the rotation axes of the gates of model.

Parameters

model (Model) – The model to process.

Returns

numpy.ndarray – Of size (nOperations,nGate) where nOperations=len(model.operations)

pygsti.report.Angles_btwn_rotn_axes
pygsti.report.entanglement_fidelity(a, b, mx_basis)

Entanglement fidelity between a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Entanglement_fidelity
pygsti.report.entanglement_infidelity(a, b, mx_basis)

Entanglement infidelity between a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Entanglement_infidelity
pygsti.report.closest_unitary_fidelity(a, b, mx_basis)

Entanglement infidelity between closest unitaries to a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Closest_unitary_fidelity
pygsti.report.frobenius_diff(a, b, mx_basis)

Frobenius distance between a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Fro_diff
pygsti.report.jtrace_diff(a, b, mx_basis)

Jamiolkowski trace distance between a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Jt_diff
class pygsti.report.HalfDiamondNorm(model_a, model_b, oplabel)

Bases: pygsti.report.modelfunction.ModelFunction

Half the diamond distance bewteen model_a.operations[op_label] and model_b.operations[op_label]

Parameters
  • model_a (Model) – The first model.

  • model_b (Model) – The second model.

  • oplabel (Label) – The operation (gate) label to compare.

evaluate(self, model)

Evaluate at model_a = model

Parameters

model (Model) – Model to evaluate at.

Returns

float

evaluate_nearby(self, nearby_model)

Evaluates at a nearby model

Parameters

nearby_model (Model) – A model nearby in parameter space.

Returns

float

pygsti.report.std_unitarity(a, b, mx_basis)

a gauge-invariant quantity that behaves like the unitarity

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.eigenvalue_unitarity(a, b)

a gauge-invariant quantity that behaves like the unitarity

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

Returns

float

pygsti.report.nonunitary_entanglement_infidelity(a, b, mx_basis)

Returns (d^2 - 1)/d^2 * (1 - sqrt(U)), where U is the unitarity of a*b^{-1}

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Nonunitary_entanglement_infidelity
pygsti.report.nonunitary_avg_gate_infidelity(a, b, mx_basis)

Returns (d - 1)/d * (1 - sqrt(U)), where U is the unitarity of a*b^{-1}

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Nonunitary_avg_gate_infidelity
pygsti.report.eigenvalue_nonunitary_entanglement_infidelity(a, b, mx_basis)

Returns (d^2 - 1)/d^2 * (1 - sqrt(U)), where U is the eigenvalue-unitarity of a*b^{-1}

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Eigenvalue_nonunitary_entanglement_infidelity
pygsti.report.eigenvalue_nonunitary_avg_gate_infidelity(a, b, mx_basis)

Returns (d - 1)/d * (1 - sqrt(U)), where U is the eigenvalue-unitarity of a*b^{-1}

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Eigenvalue_nonunitary_avg_gate_infidelity
pygsti.report.eigenvalue_entanglement_infidelity(a, b, mx_basis)

Eigenvalue entanglement infidelity between a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Eigenvalue_entanglement_infidelity
pygsti.report.eigenvalue_avg_gate_infidelity(a, b, mx_basis)

Eigenvalue average gate infidelity between a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Eigenvalue_avg_gate_infidelity
pygsti.report.eigenvalue_diamondnorm(a, b, mx_basis)

Eigenvalue diamond distance between a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Eigenvalue_diamondnorm
pygsti.report.eigenvalue_nonunitary_diamondnorm(a, b, mx_basis)

Eigenvalue nonunitary diamond distance between a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Eigenvalue_nonunitary_diamondnorm
pygsti.report.avg_gate_infidelity(a, b, mx_basis)

Returns the average gate infidelity between a and b, where b is the “target” operation.

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Avg_gate_infidelity
pygsti.report.model_model_angles_btwn_axes(a, b, mx_basis)

Angle between the rotation axes of a and b (1-qubit gates)

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Model_model_angles_btwn_axes
pygsti.report.rel_eigenvalues(a, b, mx_basis)

Eigenvalues of b^{-1} * a

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

numpy.ndarray

pygsti.report.Rel_eigvals
pygsti.report.rel_log_tig_eigenvalues(a, b, mx_basis)

Eigenvalues of log(b^{-1} * a)

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

numpy.ndarray

pygsti.report.Rel_logTiG_eigvals
pygsti.report.rel_log_gti_eigenvalues(a, b, mx_basis)

Eigenvalues of log(a * b^{-1})

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

numpy.ndarray

pygsti.report.Rel_logGTi_eigvals
pygsti.report.rel_log_diff_eigenvalues(a, b, mx_basis)

Eigenvalues of log(a) - log(b)

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

numpy.ndarray

pygsti.report.Rel_logGmlogT_eigvals
pygsti.report.rel_gate_eigenvalues(a, b, mx_basis)

Eigenvalues of b^{-1} * a

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

numpy.ndarray

pygsti.report.Rel_gate_eigenvalues
pygsti.report.errorgen_and_projections(errgen, mx_basis)

Project errgen on all of the standard sets of error generators.

Parameters
  • errgen (numpy.ndarray) – The error generator.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that errgen is in.

Returns

dict – Dictionary of ‘error generator’, ‘X projections’, and ‘X projection power’ keys, where X is ‘hamiltonian’, ‘stochastic’, and ‘affine’.

pygsti.report.log_tig_and_projections(a, b, mx_basis)

Projections of log(b^{-1}*a).

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

dict – A dictionary of quantities with keys ‘error generator’, ‘X projections’, and ‘X projection power’, where X is ‘hamiltonian’, ‘stochastic’, and ‘affine’.

pygsti.report.LogTiG_and_projections
pygsti.report.log_gti_and_projections(a, b, mx_basis)

Projections of log(a*b^{-1}).

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

dict – A dictionary of quantities with keys ‘error generator’, ‘X projections’, and ‘X projection power’, where X is ‘hamiltonian’, ‘stochastic’, and ‘affine’.

pygsti.report.LogGTi_and_projections
pygsti.report.log_diff_and_projections(a, b, mx_basis)

Projections of log(a)-log(b).

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

dict – A dictionary of quantities with keys ‘error generator’, ‘X projections’, and ‘X projection power’, where X is ‘hamiltonian’, ‘stochastic’, and ‘affine’.

pygsti.report.LogGmlogT_and_projections
pygsti.report.robust_log_gti_and_projections(model_a, model_b, synthetic_idle_circuits)

Projections of log(A*B^{-1}) using a gauge-robust technique.

Parameters
  • model_a (Model) – The first model (A gates).

  • model_b (Model) – The second model (B gates).

  • synthetic_idle_circuits (list) – Circuits that encode synthetic idles.

Returns

dict – A dictionary of quantities with keys ‘G error generator’, ‘G X projections’, and ‘G X projection power’, where G is a operation label and X is ‘hamiltonian’, ‘stochastic’, and ‘affine’.

pygsti.report.Robust_LogGTi_and_projections
pygsti.report.general_decomposition(model_a, model_b)

Decomposition of gates in model_a using those in model_b as their targets.

This function uses a generalized decomposition algorithm that can gates acting on a Hilbert space of any dimension.

Parameters
  • model_a (Model) – The model.

  • model_b (Model) – The target model.

Returns

dict

pygsti.report.General_decomposition
pygsti.report.average_gateset_infidelity(model_a, model_b)

Average model infidelity

Parameters
  • model_a (Model) – The first model.

  • model_b (Model) – The second model.

Returns

float

pygsti.report.Average_gateset_infidelity
pygsti.report.predicted_rb_number(model_a, model_b)

Prediction of RB number based on estimated (A) and target (B) models

Parameters
  • model_a (Model) – The first model.

  • model_b (Model) – The second model.

Returns

float

pygsti.report.Predicted_rb_number
pygsti.report.vec_fidelity(a, b, mx_basis)

State fidelity between state vectors a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Vec_fidelity
pygsti.report.vec_infidelity(a, b, mx_basis)

State infidelity fidelity between state vectors a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Vec_infidelity
pygsti.report.vec_trace_diff(a, b, mx_basis)

Trace distance between state vectors a and b

Parameters
  • a (numpy.ndarray) – The first process (transfer) matrix.

  • b (numpy.ndarray) – The second process (transfer) matrix.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Vec_tr_diff
pygsti.report.vec_as_stdmx(vec, mx_basis)

State vector as a standard density matrix

Parameters
  • vec (numpy.ndarray) – state vector as a 1D dense array.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that vec is in.

Returns

numpy.ndarray – A 2D array (matrix) that is vec in the standard basis.

pygsti.report.Vec_as_stdmx
pygsti.report.vec_as_stdmx_eigenvalues(vec, mx_basis)

Eigenvalues of the density matrix corresponding to a state vector

Parameters
  • vec (numpy.ndarray) – state vector as a 1D dense array.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that vec is in.

Returns

numpy.ndarray

pygsti.report.Vec_as_stdmx_eigenvalues
pygsti.report.info_of_opfn_by_name(name)

Returns a nice human-readable name and tooltip for a given gate-function abbreviation.

Parameters

name (str) –

An appreviation for a gate-function name. Allowed values are:

  • ”inf” : entanglement infidelity

  • ”agi” : average gate infidelity

  • ”trace” : 1/2 trace distance

  • ”diamond” : 1/2 diamond norm distance

  • ”nuinf” : non-unitary entanglement infidelity

  • ”nuagi” : non-unitary entanglement infidelity

  • ”evinf” : eigenvalue entanglement infidelity

  • ”evagi” : eigenvalue average gate infidelity

  • ”evnuinf” : eigenvalue non-unitary entanglement infidelity

  • ”evnuagi” : eigenvalue non-unitary entanglement infidelity

  • ”evdiamond” : eigenvalue 1/2 diamond norm distance

  • ”evnudiamond” : eigenvalue non-unitary 1/2 diamond norm distance

  • ”frob” : frobenius distance

  • ”unmodeled” : unmodeled “wildcard” budget

Returns

  • nicename (str)

  • tooltip (str)

pygsti.report.evaluate_opfn_by_name(name, model, target_model, op_label_or_string, confidence_region_info)

Evaluates that gate-function named by the abbreviation name.

Parameters
  • name (str) – An appreviation for a operation-function name. Allowed values are the same as those of info_of_opfn_by_name().

  • model (Model) – The model used by the operation-function.

  • target_model (Model) – The target model.

  • op_label_or_string (str or Circuit or tuple) – The operation label or sequence of labels to compare. If a sequence of labels is given, then the “virtual gate” computed by taking the product of the specified gate matrices is compared.

  • confidence_region_info (ConfidenceRegion, optional) – If not None, specifies a confidence-region used to compute error intervals.

Returns

ReportableQty

pygsti.report.instrument_infidelity(a, b, mx_basis)

Infidelity between instruments a and b

Parameters
  • a (Instrument) – The first instrument.

  • b (Instrument) – The second instrument.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Instrument_infidelity
pygsti.report.instrument_half_diamond_norm(a, b, mx_basis)

The diamond norm distance between instruments a and b.

Parameters
  • a (Instrument) – The first instrument.

  • b (Instrument) – The second instrument.

  • mx_basis (Basis or {'pp', 'gm', 'std'}) – the basis that a and b are in.

Returns

float

pygsti.report.Instrument_half_diamond_norm
pygsti.report.evaluate_instrumentfn_by_name(name, model, target_model, inst_label, confidence_region_info)

Evaluates that instrument-function named by the abbreviation name.

Parameters
  • name (str) – An appreviation for a operation-function name. Allowed values are the same as those of info_of_opfn_by_name().

  • model (Model) – The model used by the operation-function.

  • target_model (Model) – The target model.

  • inst_label (Label) – The instrument label to compare.

  • confidence_region_info (ConfidenceRegion, optional) – If not None, specifies a confidence-region used to compute error intervals.

Returns

ReportableQty

class pygsti.report.Workspace(cachefile=None)

Bases: object

Central to data analysis, Workspace objects facilitate the building of reports and dashboards.

In particular, they serve as a:

  • factory for tables, plots, and other types of output

  • cache manager to optimize the construction of such output

  • serialization manager for saving and loading analysis variables

Workspace objects are typically used either 1) within an ipython notebook to interactively build a report/dashboard, or 2) within a script to build a hardcoded (“fixed”) report/dashboard.

Parameters

cachefile (str, optional) – filename with cached workspace results

save_cache(self, cachefile, show_unpickled=False)

Save this Workspace’s cache to a file.

Parameters
  • cachefile (str) – The filename to save the cache to.

  • show_unpickled (bool, optional) – Whether to print quantities (keys) of cache that could not be saved because they were not pickle-able.

Returns

None

load_cache(self, cachefile)

Load this Workspace’s cache from cachefile.

Parameters

cachefile (str) – The filename to load the cache from.

Returns

None

__getstate__(self)
__setstate__(self, state_dict)
_makefactory(self, cls, autodisplay)
_register_components(self, autodisplay)
init_notebook_mode(self, connected=False, autodisplay=False)

Initialize this Workspace for use in an iPython notebook environment.

This function should be called prior to using the Workspace when working within an iPython notebook.

Parameters
  • connected (bool , optional) – Whether to assume you are connected to the internet. If you are, then setting this to True allows initialization to rely on web- hosted resources which will reduce the overall size of your notebook.

  • autodisplay (bool , optional) – Whether to automatically display workspace objects after they are created.

Returns

None

switched_compute(self, fn, *args)

Calls a compute function with special handling of SwitchedValue arguments.

This is similar to calling fn, given its name and arguments, when some or all of those arguments are SwitchedValue objects.

Caching is employed to avoid duplicating function evaluations which have the same arguments. Note that the function itself doesn’t need to deal with SwitchValue objects, as this routine resolves such objects into a series of function evaluations using the underlying value(s) within the SwitchValue. This routine is primarily used internally for the computation of tables and plots.

if any of the arguments is an instance of NotApplicable then fn is not evaluated and the instance is returned as the evaluation result. If multiple arguments are NotApplicable instances, the first is used as the result.

Parameters

fn (function) – The function to evaluate

Returns

  • fn_values (list) – The function return values for all relevant sets of arguments. Denote the length of this list by N.

  • switchboards (list) – A list of all the relevant Switchboards used during the function evaluation. Denote the length of this list by M.

  • switchboard_switch_indices (list) – A list of length M whose elements are tuples containing the 0-based indices of the relevant switches (i.e. those used by any of the arguments) for each switchboard (element of switchboards).

  • switchpos_map (dict) – A dictionary whose keys are switch positions, and whose values are integers between 0 and N which index the element of fn_values corresponding to the given switch positions. Each “switch positions” key is a tuple of length M whose elements (one per switchboard) are tuples of 0-based switch-position indices indicating the position of the relevant switches of that switchboard. Thus, len(key[i]) = len(switchboard_switch_indices[i]), where key is a dictionary key.

pygsti.report.blues
pygsti.report.empty_volumetric_plot(figsize=None, y_values=None, x_values=None, title=None, xlabel='Depth', ylabel='Width')

Creates an empty volumetric plot with just the axes set.

Parameters
  • figsize (tuple or None, optional) – The figure size.

  • y_values (list or None, optional) – The y-axis values, typically corresponding to circuit widths.

  • x_values (list or None, optional) – The x-axis values, typically corresponding to circuit depths.

  • title (string or None, optional) – Plot title

  • xlabel (string, optional) – x-axis label

  • ylabel (string, optional) – y-axis label.

Returns

fig, ax (matplolib fig and ax.)

pygsti.report._get_xy(data, y_values=None, x_values=None)
pygsti.report.volumetric_plot(data, y_values=None, x_values=None, title=None, fig=None, ax=None, cmap=my_cmap, color=None, flagQV=False, qv_threshold=None, figsize=(10, 10), scale=1.0, centerscale=1.0, linescale=1.0, pass_threshold=0, show_threshold=0)

Creates a volumetric benchmarking plot.

pygsti.report.volumetric_boundary_plot(data, y_values=None, x_values=None, boundary=None, threshold=0.5, missing_data_action='continue', monotonic=True, color='k', linewidth=4, linestyle='-', dashing=None, fig=None, ax=None, figsize=None, title=None, label=None)

Creates a volumetric benchmarking boundary plot, that displays boundary at which the given data drops below the specified threshold

pygsti.report.capability_region_plot(vbdataframe, metric='polarization', threshold=1 / _np.e, significance=0.05, figsize=(10, 10), scale=1.0, title=None, colors=None)

Creates a capability regions plot from a VBDataFrame. Default options creates plots like those shown in Fig. 3 of “Measuring the Capabilities of Quantum Computers” arXiv:2008.11294.

pygsti.report.volumetric_distribution_plot(vbdataframe, metric='polarization', threshold=1 / _np.e, hypothesis_test='standard', significance=0.05, figsize=(10, 10), scale={'min': 1.95, 'mean': 1, 'max': 0.13}, title=None, cmap=my_cmap)

Creates volumetric benchmarking plots that display the maximum, mean and minimum of a given figure-of-merit (by default, circuit polarization) as a function of circuit shape. This function can be used to create figures like those shown in Fig. 1 of “Measuring the Capabilities of Quantum Computers” arXiv:2008.11294.

Parameters
  • vbdataframe (VBDataFrame) – A VBDataFrame object containing the data to be plotted in a VB plot.

  • metric (string, optional) – The quantity to plot. Default is ‘polarization’ as used and defined in arXiv:2008.11294. The plot will show the maximum, mean, and minimum of this metric at each circuit shape.

  • threshold (float, optional) – The threshold for “success” for the figure-of-merit defined by metric. This threshold is used to compute the three “success” boundaries that are shown in the plot.

  • hypothesis_test (string, optional) –

    The type of statistical significance adjustment to apply to the boundaries. The options are - ‘standard’: this reproduces the method used and described in arXiv:2008.11294 (see the

    appendices for details). With this option, there will be a difference between the boundary for the minimum and maximum polarization only if there is statistically significant evidence in the data for this.

    • ’none’: no statistical significance adjustment: all three boundaries show the point at which

      relevant statistic (maximum, mean, minimum) drops below the threshold.

  • significance (float, optional) – The statistical significance in the hypothesis tests. Only used in hypothesis_test is not ‘none’.

  • figsize (tuple, optional) – The figure size

  • scale (dict, optional) – The scale for the three concentric squares, showing the maximum, mean and minimum.

  • title (sting, optional) – The figure title.

  • cmap (ColorMap, optional) – A matplotlib colormap.

Returns

fig, ax (matplolib fig and ax.)