:py:mod:`pygsti.baseobjs.errorgenbasis` ======================================= .. py:module:: pygsti.baseobjs.errorgenbasis .. autoapi-nested-parse:: Defines the ElementaryErrorgenBasis class and supporting functionality. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: pygsti.baseobjs.errorgenbasis.ElementaryErrorgenBasis pygsti.baseobjs.errorgenbasis.ExplicitElementaryErrorgenBasis pygsti.baseobjs.errorgenbasis.CompleteElementaryErrorgenBasis .. py:class:: ElementaryErrorgenBasis(doc_id=None) Bases: :py:obj:`pygsti.baseobjs.nicelyserializable.NicelySerializable` A 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. .. py:method:: 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 ---------- labels : list of `ElementaryErrorgenLabel` A list of elementary error generator labels to extract the indices of. ok_if_missing : bool If True, then returns `None` instead of an integer when the given label is not present .. py:class:: ExplicitElementaryErrorgenBasis(state_space, labels, basis_1q=None) Bases: :py:obj:`ElementaryErrorgenBasis` This 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_space : `StateSpace` An object describing the struture of the entire state space upon which the elements of this error generator basis act. labels : list or tuple of `ElementaryErrorgenLabel` A list of elementary error generator labels for which basis elements will be constructed. basis1q : `Basis` 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`. .. py:property:: labels .. py: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`. .. py: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`. .. py: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`. .. py: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`. .. py: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`. .. py:attribute:: state_space .. py:attribute:: sslbls .. py:method:: from_nice_serialization(state) :classmethod: 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 ---------- state : object An object, usually a dictionary, representing the object to de-serialize. Returns ------- object .. py:method:: label_index(label, ok_if_missing=False) Return the index of the specified elementary error generator label in this basis' `labels` list. Parameters ---------- label : `ElementaryErrorgenLabel` Elementary error generator label to return index for. ok_if_missing : bool If True, then returns `None` instead of an integer when the given label is not present. .. py:method:: 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_overlap : list 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. .. py:method:: union(other_basis) Create a new `ExplicitElementaryErrorgenBasis` corresponding to the union of this basis with another. Parameters ---------- other_basis : `ElementaryErrorgenBasis` `ElementaryErrorgenBasis` to construct the union with. .. py:method:: intersection(other_basis) Create a new `ExplicitElementaryErrorgenBasis` corresponding to the intersection of this basis with another. Parameters ---------- other_basis : `ElementaryErrorgenBasis` `ElementaryErrorgenBasis` to construct the intersection with. .. py:method:: 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_basis : `ElementaryErrorgenBasis` `ElementaryErrorgenBasis` to construct the difference with. .. py:class:: CompleteElementaryErrorgenBasis(basis_1q, state_space, elementary_errorgen_types=('H', 'S', 'C', 'A'), max_weights=None, sslbl_overlap=None, default_label_type='global') Bases: :py:obj:`ElementaryErrorgenBasis` This 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_1q : `Basis` 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_space : `StateSpace` An object describing the struture of the entire state space upon which the elements of this error generator basis act. elementary_errorgen_types : tuple of str, optional (default ('H', 'S', 'C', 'A')) Tuple of strings designating elementary error generator types to include in this basis. max_weights : dict, 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_overlap : list 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_type : str, 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. .. py: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. .. py: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`. .. py: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`. .. py: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`. .. py: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`. .. py: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`. .. py:attribute:: state_space .. py:attribute:: max_weights :value: 'None' .. py:method:: from_nice_serialization(state) :classmethod: 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 ---------- state : object An object, usually a dictionary, representing the object to de-serialize. Returns ------- object .. py:method:: to_explicit_basis() Creates a new `ExplicitElementaryErrorgenBasis` based on this Basis' elements. .. py:method:: global_labels() Return a list of labels for this basis as `GlobalElementaryErrorgenLabel` objects. .. py:method:: local_labels() Return a list of labels for this basis as `LocalElementaryErrorgenLabel` objects. .. py:method:: 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` .. py:method:: 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 ---------- label : `ElementaryErrorgenLabel` Elementary error generator label to return index for. ok_if_missing : bool If True, then returns `None` instead of an integer when the given label is not present. identity_label : str, optional (default 'I') An optional string specifying the label used to denote the identity in basis element labels. .. py:method:: 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) .. py:method:: union(other_basis) Create a new `ExplicitElementaryErrorgenBasis` corresponding to the union of this basis with another. Parameters ---------- other_basis : `ElementaryErrorgenBasis` `ElementaryErrorgenBasis` to construct the union with. .. py:method:: intersection(other_basis) Create a new `ExplicitElementaryErrorgenBasis` corresponding to the intersection of this basis with another. Parameters ---------- other_basis : `ElementaryErrorgenBasis` `ElementaryErrorgenBasis` to construct the intersection with. .. py:method:: 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_basis : `ElementaryErrorgenBasis` `ElementaryErrorgenBasis` to construct the difference with.