pygsti.baseobjs.errorgenbasis
Defines the ElementaryErrorgenBasis class and supporting functionality.
Module Contents
Classes
A basis for error-generator space defined by a set of elementary error generators. |
|
This basis object contains the information necessary for building, |
|
This basis object contains the information necessary for building, |
- class pygsti.baseobjs.errorgenbasis.ElementaryErrorgenBasis(doc_id=None)
Bases:
pygsti.baseobjs.nicelyserializable.NicelySerializableA basis for error-generator space defined by a set of elementary error generators.
Elements are ordered (have definite indices) and labeled. Intersection and union can be performed as a set.
- label_indices(labels, ok_if_missing=False)
Return a list of indices into this basis’s label list for the specifed list of ElementaryErrorgenLabels.
Parameters
- labelslist of ElementaryErrorgenLabel
A list of elementary error generator labels to extract the indices of.
- ok_if_missingbool
If True, then returns None instead of an integer when the given label is not present
- class pygsti.baseobjs.errorgenbasis.ExplicitElementaryErrorgenBasis(state_space, labels, basis_1q=None)
Bases:
ElementaryErrorgenBasisThis basis object contains the information necessary for building, storing and accessing a set of explicitly represented basis elements for a user specified set of of elementary error generators.
Instantiate a new explicit elementary error generator basis.
Parameters
- state_spaceStateSpace
An object describing the struture of the entire state space upon which the elements of this error generator basis act.
- labelslist or tuple of ElementaryErrorgenLabel
A list of elementary error generator labels for which basis elements will be constructed.
- basis1qBasis or str, optional (default None)
A Basis object, or str which can be cast to one corresponding to the single-qubit basis elements which comprise the basis element labels for the values of the ElementaryErrorgenLabels in labels.
- property labels
- property elemgen_supports
Returns a tuple of tuples, each corresponding to the support of the elementary error generators in this basis, returned in the same order as they appear in labels.
- property elemgen_dual_matrices
Returns a tuple of matrices, each corresponding to the of the matrix representation of the dual elementary error generators in this basis, returned in the same order as they appear in labels.
- property elemgen_matrices
Returns a tuple of matrices, each corresponding to the of the matrix representation of the elementary error generators in this basis, returned in the same order as they appear in labels.
- property elemgen_supports_and_dual_matrices
Returns a tuple of tuples, each containing a tuple of support and a dual matrix representation each corresponding to an elementary error generator in this basis, returned in the same order as they appear in labels.
- property elemgen_supports_and_matrices
Returns a tuple of tuples, each containing a tuple of support and a matrix representation each corresponding to an elementary error generator in this basis, returned in the same order as they appear in labels.
- state_space
- sslbls
- classmethod from_nice_serialization(state)
Create and initialize an object from a “nice” serialization.
A “nice” serialization here means one created by a prior call to to_nice_serialization using this class or a subclass of it. Nice serializations adhere to additional rules (e.g. that dictionary keys must be strings) that make them amenable to common file formats (e.g. JSON).
The state argument is typically a dictionary containing ‘module’ and ‘state’ keys specifying the type of object that should be created. This type must be this class or a subclass of it.
Parameters
- stateobject
An object, usually a dictionary, representing the object to de-serialize.
Returns
object
- label_index(label, ok_if_missing=False)
Return the index of the specified elementary error generator label in this basis’ labels list.
Parameters
- labelElementaryErrorgenLabel
Elementary error generator label to return index for.
- ok_if_missingbool
If True, then returns None instead of an integer when the given label is not present.
- create_subbasis(sslbl_overlap)
Create a sub-basis of this basis by including only the elements that overlap the given support (state space labels)
Parameters
- sslbl_overlaplist of sslbls
A list of state space labels corresponding to qudits the support of an error generator must overlap with (i.e. the support must include at least one of these qudits) in order to be included in this subbasis.
- union(other_basis)
Create a new ExplicitElementaryErrorgenBasis corresponding to the union of this basis with another.
Parameters
- other_basisElementaryErrorgenBasis
ElementaryErrorgenBasis to construct the union with.
- intersection(other_basis)
Create a new ExplicitElementaryErrorgenBasis corresponding to the intersection of this basis with another.
Parameters
- other_basisElementaryErrorgenBasis
ElementaryErrorgenBasis to construct the intersection with.
- difference(other_basis)
Create a new ExplicitElementaryErrorgenBasis corresponding to the difference of this basis with another. (i.e. A basis consisting of the labels contained in this basis but not the other)
Parameters
- other_basisElementaryErrorgenBasis
ElementaryErrorgenBasis to construct the difference with.
- class pygsti.baseobjs.errorgenbasis.CompleteElementaryErrorgenBasis(basis_1q, state_space, elementary_errorgen_types=('H', 'S', 'C', 'A'), max_weights=None, sslbl_overlap=None, default_label_type='global')
Bases:
ElementaryErrorgenBasisThis basis object contains the information necessary for building, storing and accessing a set of explicitly represented basis elements for a basis of elementary error generators spanned by the elementary error generators of given type(s) (e.g. “Hamiltonian” and/or “other”).
Parameters
- basis_1qBasis or str
A Basis object, or str which can be cast to one corresponding to the single-qubit basis elements which comprise the basis element labels for the values of the ElementaryErrorgenLabels in labels.
- state_spaceStateSpace
An object describing the struture of the entire state space upon which the elements of this error generator basis act.
- elementary_errorgen_typestuple of str, optional (default (‘H’, ‘S’, ‘C’, ‘A’))
Tuple of strings designating elementary error generator types to include in this basis.
- max_weightsdict, optional (default None)
A dictionary containing the maximum weight for each of the different error generator types to include in the constructed basis. If None then there is no maximum weight. If specified, any error generator types without entries will have no maximum weight associated with them.
- sslbl_overlaplist of sslbls, optional (default None)
A list of state space labels corresponding to qudits the support of an error generator must overlap with (i.e. the support must include at least one of these qudits) in order to be included in this basis.
- default_label_typestr, optional (default ‘global’)
String specifying the type of error generator label to use by default. i.e. the type of label returned by labels. This also impacts the construction of the error generator matrices. Supported options are ‘global’ or ‘local’, which correspond to GlobalElementaryErrorgenLabel and LocalElementaryErrorgenLabel, respectively.
- property labels
Tuple of either GlobalElementaryErrorgenLabel or LocalElementaryErrorgenLabel objects for this basis, with which one determined by the default_label_type specified on basis construction.
For specific label types see the global_labels and local_labels methods.
- property elemgen_supports
Returns a tuple of tuples, each corresponding to the support of the elementary error generators in this basis, returned in the same order as they appear in labels.
- property elemgen_dual_matrices
Returns a tuple of matrices, each corresponding to the of the matrix representation of the dual elementary error generators in this basis, returned in the same order as they appear in labels.
- property elemgen_matrices
Returns a tuple of matrices, each corresponding to the of the matrix representation of the elementary error generators in this basis, returned in the same order as they appear in labels.
- property elemgen_supports_and_dual_matrices
Returns a tuple of tuples, each containing a tuple of support and a dual matrix representation each corresponding to an elementary error generator in this basis, returned in the same order as they appear in labels.
- property elemgen_supports_and_matrices
Returns a tuple of tuples, each containing a tuple of support and a matrix representation each corresponding to an elementary error generator in this basis, returned in the same order as they appear in labels.
- state_space
- max_weights = 'None'
- classmethod from_nice_serialization(state)
Create and initialize an object from a “nice” serialization.
A “nice” serialization here means one created by a prior call to to_nice_serialization using this class or a subclass of it. Nice serializations adhere to additional rules (e.g. that dictionary keys must be strings) that make them amenable to common file formats (e.g. JSON).
The state argument is typically a dictionary containing ‘module’ and ‘state’ keys specifying the type of object that should be created. This type must be this class or a subclass of it.
Parameters
- stateobject
An object, usually a dictionary, representing the object to de-serialize.
Returns
object
- to_explicit_basis()
Creates a new ExplicitElementaryErrorgenBasis based on this Basis’ elements.
- global_labels()
Return a list of labels for this basis as GlobalElementaryErrorgenLabel objects.
- local_labels()
Return a list of labels for this basis as LocalElementaryErrorgenLabel objects.
- sublabels(errorgen_type)
Return a tuple of labels within this basis for the specified error generator type (may be empty).
Parameters
- errorgen_type‘H’, ‘S’, ‘C’ or ‘A’
String specifying the error generator type to return the labels for.
Returns
tuple of either GlobalElementaryErrorgenLabels or LocalElementaryErrorgenLabels
- label_index(label, ok_if_missing=False, identity_label='I')
Return the index of the specified elementary error generator label in this basis’ labels list.
Parameters
- labelElementaryErrorgenLabel
Elementary error generator label to return index for.
- ok_if_missingbool
If True, then returns None instead of an integer when the given label is not present.
- identity_labelstr, optional (default ‘I’)
An optional string specifying the label used to denote the identity in basis element labels.
- create_subbasis(sslbl_overlap, retain_max_weights=True)
Create a sub-basis of this basis by including only the elements that overlap the given support (state space labels)
- union(other_basis)
Create a new ExplicitElementaryErrorgenBasis corresponding to the union of this basis with another.
Parameters
- other_basisElementaryErrorgenBasis
ElementaryErrorgenBasis to construct the union with.
- intersection(other_basis)
Create a new ExplicitElementaryErrorgenBasis corresponding to the intersection of this basis with another.
Parameters
- other_basisElementaryErrorgenBasis
ElementaryErrorgenBasis to construct the intersection with.
- difference(other_basis)
Create a new ExplicitElementaryErrorgenBasis corresponding to the difference of this basis with another. (i.e. A basis consisting of the labels contained in this basis but not the other)
Parameters
- other_basisElementaryErrorgenBasis
ElementaryErrorgenBasis to construct the difference with.