pygsti.report.plothelpers

Helper Functions for generating plots

Module Contents

Functions

small_eigenvalue_err_rate(sigma, direct_gst_models)

Compute per-gate error rate.

_eformat(f, prec)

Formatting routine for writing compact representations of

_num_non_nan(array)

_all_same(items)

_compute_num_boxes_dof(sub_mxs, sum_up, element_dof)

A helper function to compute the number of boxes, and corresponding

_compute_sub_mxs(gss, model, sub_mx_creation_fn, dataset=None, sub_mx_creation_fn_extra_arg=None)

dscompare_llr_matrices(gsplaq, dscomparator)

Computes matrix of 2*log-likelihood-ratios comparing the data of dscomparator.

genericdict_matrices(gsplaq, genericdict)

drift_neglog10pvalue_matrices(gsplaq, drifttuple)

Computes matrix of -log10(pvalues) for testing the stable-circuit ("no drift") null hypothesis in each circuit.

drift_maxtvd_matrices(gsplaq, drifttuple)

Computes matrix of max-tvds for quantifying the size of any detected drift.

rated_n_sigma(dataset, model, circuits, objfn_builder, np=None, wildcard=None, return_all=False, comm=None)

Computes the number of standard deviations of model violation between model and data.

pygsti.report.plothelpers.small_eigenvalue_err_rate(sigma, direct_gst_models)

Compute per-gate error rate.

The per-gate error rate, extrapolated from the smallest eigvalue of the Direct GST estimate of the given circuit sigma.

Parameters
  • sigma (Circuit or tuple of operation labels) – The gate sequence that is used to estimate the error rate

  • direct_gst_models (dictionary of Models) – A dictionary with keys = circuits and values = Models.

Returns

float – the approximate per-gate error rate.

pygsti.report.plothelpers._eformat(f, prec)

Formatting routine for writing compact representations of numbers in plot boxes

pygsti.report.plothelpers._num_non_nan(array)
pygsti.report.plothelpers._all_same(items)
pygsti.report.plothelpers._compute_num_boxes_dof(sub_mxs, sum_up, element_dof)

A helper function to compute the number of boxes, and corresponding number of degrees of freedom, for the GST chi2/logl boxplots.

pygsti.report.plothelpers._compute_sub_mxs(gss, model, sub_mx_creation_fn, dataset=None, sub_mx_creation_fn_extra_arg=None)
pygsti.report.plothelpers.dscompare_llr_matrices(gsplaq, dscomparator)

Computes matrix of 2*log-likelihood-ratios comparing the data of dscomparator.

Parameters
Returns

numpy array of shape ( len(effect_strs), len(prep_strs) ) – log-likelihood-ratio values corresponding to the circuits where a base circuit is sandwiched between the each prep-fiducial and effect-fiducial pair.

pygsti.report.plothelpers.genericdict_matrices(gsplaq, genericdict)
pygsti.report.plothelpers.drift_neglog10pvalue_matrices(gsplaq, drifttuple)

Computes matrix of -log10(pvalues) for testing the stable-circuit (“no drift”) null hypothesis in each circuit.

This uses the “max power in spectra” test.

Parameters
  • gsplaq (CircuitPlaquette) – Obtained via :method:`CircuitStructure.get_plaquette`, this object specifies which matrix indices should be computed and which circuits they correspond to.

  • drifttuple (2-tuple) – The first element of the tuple is a StabilityAnalyzer. The second element is a tuple that specifies the hypothesis test(s) from which to extract the p-values. This can be None, and then the default is used.

Returns

numpy array of shape ( len(effect_strs), len(prep_strs) ) – -log10(pvalues) for testing the “no drift” null hypothesis, using the “max power in spectra” test, on the relevant sequences. This circuits correspond to the circuits where a base circuit is sandwiched between the each prep-fiducial and effect-fiducial pair.

pygsti.report.plothelpers.drift_maxtvd_matrices(gsplaq, drifttuple)

Computes matrix of max-tvds for quantifying the size of any detected drift.

Parameters
  • gsplaq (CircuitPlaquette) – Obtained via :method:`CircuitStructure.get_plaquette`, this object specifies which matrix indices should be computed and which circuits they correspond to.

  • drifttuple (2-tuple) – The first element of the tuple is a StabilityAnalyzer. The second element is a tuple that specifies the estimatorkey, and the third element is an estimator name, that specifies the estimates to use (both can be None, and then the default is used).

Returns

numpy array of shape ( len(effect_strs), len(prep_strs) ) – The max tvd for quantifying deviations from the data mean. This circuits correspond to the circuits where a base circuit is sandwiched between the each prep-fiducial and effect-fiducial pair.

pygsti.report.plothelpers.rated_n_sigma(dataset, model, circuits, objfn_builder, np=None, wildcard=None, return_all=False, comm=None)

Computes the number of standard deviations of model violation between model and data.

Function compares the data in dataset with the model model at the “points” (circuits) specified by circuits.

Parameters
  • dataset (DataSet) – The data set.

  • model (Model) – The model (model).

  • circuits (CircuitList or list of Circuits) – The circuits to use when computing the model violation. A CircuitList object may be given to include additional information (e.g. aliases) along with the list of circuits.

  • objfn_builder (ObjectiveFunctionBuilder) – Builds the objective function to be used to compute the model violation.

  • np (int, optional) – The number of free parameters in the model. If None, then model.num_nongauge_params is used.

  • 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 model before comparing with the frequencies in dataset. Currently, this functionality is only supported for objective == “logl”.

  • return_all (bool, optional) – Returns additional information such as the raw and expected model violation (see below).

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

Returns

  • Nsig (float) – The number of sigma of model violaition

  • rating (int) – A 1-5 rating (e.g. “number of stars”) used to indicate the rough abililty of the model to fit the data (better fit = higher rating).

  • modelViolation (float) – The raw value of the objective function. Only returned when return_all==True.

  • expectedViolation (float) – The expected value of the objective function. Only returned when return_all==True.

  • Ns, np (int) – The number of dataset and model parameters, respectively. Only returned when return_all==True.