pygsti.objects.GateSet

class pygsti.objects.GateSet(default_param='full', prep_prefix='rho', effect_prefix='E', gate_prefix='G', remainder_label='remainder', identity_label='identity')

Encapsulates a set of gate, state preparation, and POVM effect operations.

A GateSet stores a set of labeled Gate objects and provides dictionary-like access to their matrices. State preparation and POVM effect operations are represented as column vectors.

__init__(default_param='full', prep_prefix='rho', effect_prefix='E', gate_prefix='G', remainder_label='remainder', identity_label='identity')

Initialize a gate set.

Parameters:
  • default_param ({“full”, “TP”, “static”}, optional) – Specifies the default gate and SPAM vector parameterization type. “full” : by default gates and vectors are fully parameterized. “TP” : by default the first row of gates and the first element of vectors is not parameterized and fixed so gate set is trace- preserving. “static” : by default gates and vectors are not parameterized.
  • effect_prefix, gate_prefix (prep_prefix,) – Key prefixes designating state preparations, POVM effects, and gates, respectively. These prefixes allow the GateSet to determine what type of object a each key corresponds to.
  • remainder_label (string, optional) – The special string used within SPAM label values to indicate special behavior, either the use of a “complement” POVM vector or a SPAM label which generates probabilities such that the sum of all SPAM label probabilities equals one.
  • identity_label (string, optional) – The special string which acts as the key to get and set the identity vector.

Methods

__init__([default_param, prep_prefix, ...]) Initialize a gate set.
bulk_dpr(spamLabel, evalTree[, returnPr, ...]) Compute the derivatives of the probabilities generated by a each gate sequence given by evalTree, where initialization & measurement operations are always the same and are together specified by spamLabel.
bulk_dprobs(evalTree[, returnPr, clipTo, ...]) Construct a dictionary containing the bulk-probability- derivatives for every spam label (each possible initialization & measurement pair) for each gate sequence given by evalTree.
bulk_dproduct(evalTree[, flat, ...]) Compute the derivative of a many gate strings at once.
bulk_evaltree(gatestring_list) Create an evaluation tree for all the gate strings in gatestring_list.
bulk_fill_dprobs(mxToFill, spam_label_rows, ...) Identical to bulk_dprobs(...) except results are placed into rows of a pre-allocated array instead of being returned in a dictionary.
bulk_fill_hprobs(mxToFill, spam_label_rows) Identical to bulk_hprobs(...) except results are placed into rows of a pre-allocated array instead of being returned in a dictionary.
bulk_fill_probs(mxToFill, spam_label_rows, ...) Identical to bulk_probs(...) except results are placed into rows of a pre-allocated array instead of being returned in a dictionary.
bulk_hpr(spamLabel, evalTree[, returnPr, ...]) Compute the 2nd derivatives of the probabilities generated by a each gate sequence given by evalTree, where initialization & measurement operations are always the same and are together specified by spamLabel.
bulk_hprobs(evalTree[, returnPr, ...]) Construct a dictionary containing the bulk-probability- Hessians for every spam label (each possible initialization & measurement pair) for each gate sequence given by evalTree.
bulk_hprobs_by_column(spam_label_rows, evalTree) Constructs a generator that computes the 2nd derivatives of the probabilities generated by a each gate sequence given by evalTree column-by-column.
bulk_hproduct(evalTree[, flat, ...]) Return the Hessian of many gate string products at once.
bulk_pr(spamLabel, evalTree[, clipTo, ...]) Compute the probabilities of the gate sequences given by evalTree, where initialization & measurement operations are always the same and are together specified by spamLabel.
bulk_probs(evalTree[, clipTo, check, comm]) Construct a dictionary containing the bulk-probabilities for every spam label (each possible initialization & measurement pair) for each gate sequence given by evalTree.
bulk_product(evalTree[, bScale, comm]) Compute the products of many gate strings at once.
copy() Copy this gateset
decrease_dimension(newDimension) Shrink the spam vectors and gate matrices of gateset to a specified dimension, and return the resulting gate set.
depolarize([gate_noise, spam_noise, ...]) Apply depolarization uniformly or randomly to this gateset’s gate and/or SPAM elements, and return the result, without modifying the original (this) gateset.
deriv_wrt_params() Construct a matrix whose columns are the vectorized derivatives of all the gateset’s raw matrix and vector elements (placed in a vector) with respect to each single gateset parameter.
diamonddist(otherGateSet[, transformMx]) Compute the diamond-norm distance between this gateset and otherGateSet, defined as the maximum of the diamond-norm distances between each corresponding gate, including spam gates.
dpr(spamLabel, gatestring[, returnPr, clipTo]) Compute the derivative of a probability generated by a gate string and spam label as a 1 x M numpy array, where M is the number of gateset parameters.
dprobs(gatestring[, returnPr, clipTo]) Construct a dictionary containing the probability derivatives of every spam label for a given gate string.
dproduct(gatestring[, flat]) Compute the derivative of a specified sequence of gate labels.
frobeniusdist(otherGateSet[, transformMx, ...]) Compute the weighted frobenius norm of the difference between this gateset and otherGateSet.
from_vector(v) The inverse of to_vector.
get_basis_dimension() Get the dimension of the basis matrices, or more generally, the structure of the density matrix space as a list of integer dimensions.
get_basis_name() Returns the name abbreviation of the basis, essentially identifying its type.
get_dimension() Get the dimension of the gateset, which equals d when the gate matrices have shape d x d and spam vectors have shape d x 1.
get_effect_labels() Get all the effect vector labels present in a SPAM label.
get_effects() Get an list of all the POVM effect vectors.
get_nongauge_projector([nonGaugeMixMx]) Construct a projector onto the non-gauge parameter space, useful for isolating the gauge degrees of freedom from the non-gauge degrees of freedom.
get_prep_labels() Get the labels of state preparation vectors.
get_preps() Get an list of all the state prepartion vectors.
get_reverse_spam_defs() Get a reverse-lookup dictionary for spam labels.
get_spam_labels() Get a list of all the spam labels.
get_spamgate(spamLabel) Construct the SPAM gate associated with a given spam label.
get_vector_offsets() Returns the offsets of individual components in the vectorized gateset according to the optional parameters.
hpr(spamLabel, gatestring[, returnPr, ...]) Compute the Hessian of a probability generated by a gate string and spam label as a 1 x M x M array, where M is the number of gateset parameters.
hprobs(gatestring[, returnPr, returnDeriv, ...]) Construct a dictionary containing the probability derivatives of every spam label for a given gate string.
hproduct(gatestring[, flat]) Compute the hessian of a specified sequence of gate labels.
increase_dimension(newDimension) Enlarge the spam vectors and gate matrices of gateset to a specified dimension, and return the resulting inflated gateset.
iter_effects()
returns:an iterator over all (effectLabel,vector) pairs
iter_gates()
returns:an iterator over all (gateLabel,gate) pairs
iter_preps()
returns:an iterator over all (prepLabel,vector) pairs
jtracedist(otherGateSet[, transformMx]) Compute the Jamiolkowski trace distance between this gateset and otherGateSet, defined as the maximum of the trace distances between each corresponding gate, including spam gates.
kick([absmag, bias, seed]) Kick gateset by adding to each gate a random matrix with values uniformly distributed in the interval [bias-absmag,bias+absmag], and return the resulting “kicked” gate set.
num_effects() Get the number of effect vectors, including a “complement” effect
num_elements() Return the number of total gate matrix and spam vector elements in this gateset.
num_gauge_params() Return the number of gauge parameters when vectorizing this gateset according to the optional parameters.
num_nongauge_params() Return the number of non-gauge parameters when vectorizing this gateset according to the optional parameters.
num_params() Return the number of free parameters when vectorizing this gateset.
num_preps() Get the number of state preparation vectors
pr(spamLabel, gatestring[, clipTo, bUseScaling]) Compute the probability of the given gate sequence, where initialization & measurement operations are together specified by spamLabel.
print_info() Print to stdout relevant information about this gateset, including the Choi matrices and their eigenvalues.
probs(gatestring[, clipTo]) Construct a dictionary containing the probabilities of every spam label given a gate string.
product(gatestring[, bScale]) Compute the product of a specified sequence of gate labels.
randomize_with_unitary(scale[, seed]) Apply a random unitary to each element of a gateset, and return the result, without modifying the original (this) gateset.
reset_basis() “Forgets” the basis name and dimension by setting
rotate([rotate, max_rotate, seed]) Apply rotation uniformly or randomly to this gateset, and return the result, without modifying the original (this) gateset.
set_all_parameterizations(parameterization_type) Convert all gates and SPAM vectors to a specific parameterization type.
set_basis(basisName, basisDimension) Sets the basis name and dimension.
to_vector() Returns the gateset vectorized according to the optional parameters.
tpdist() Compute the “distance” between this gateset and the space of trace-preserving (TP) maps, defined as the sqrt of the sum-of-squared deviations among the first row of all gate matrices and the first element of all state preparations.
transform(S[, Si]) Update each of the gate matrices G in this gateset with inv(S) * G * S,

Attributes

dim The dimension of the gateset, which equals d when the gate matrices have shape d x d and spam vectors have shape d x 1.
povm_identity