pygsti.baseobjs.errorgenlabel

Defines the ElementaryErrorgenLabel class and supporting functionality.

Module Contents

Classes

ElementaryErrorgenLabel

TODO: docstring - for entire module

LocalElementaryErrorgenLabel

Labels an elementary error generator by simply a type and one or two

GlobalElementaryErrorgenLabel

Labels an elementary error generator on n qubits that includes the state

class pygsti.baseobjs.errorgenlabel.ElementaryErrorgenLabel

Bases: object

TODO: docstring - for entire module

class pygsti.baseobjs.errorgenlabel.LocalElementaryErrorgenLabel(errorgen_type, basis_element_labels)

Bases: ElementaryErrorgenLabel

Labels an elementary error generator by simply a type and one or two basis element labels.

Parameters

errorgen_typestr

A string corresponding to the error generator sector this error generator label is an element of. Allowed values are ‘H’, ‘S’, ‘C’ and ‘A’.

basis_element_labelstuple or list

A list or tuple of strings labeling basis elements used to label this error generator. This is either length-1 for ‘H’ and ‘S’ type error generators, or length-2 for ‘C’ and ‘A’ type.

errorgen_type = "''"
basis_element_labels
classmethod cast(obj, sslbls=None, identity_label='I')

Method for casting an object to an instance of LocalElementaryErrorgenLabel

Parameters
objLocalElementaryErrorgenLabel, GlobalElementaryErrorgenLabel, str, tuple or list

Object to cast. If a GlobalElementaryErrorgenLabel then a value for the sslbls argument should be passed with the full list of state space labels for the system. Other castable options include:

-str: A string formatted as ‘<type>(<bel1>[,<bel2>])’. E.g. ‘H(XX)’ or

‘C(X,Y)’

-tuple/list: These can be specified either in ‘global-style’ or ‘local-style’.
  • local-style: format is (<type>, <bel1>[,<bel2>])

  • global-style:format is (<type>, (<bel1>,[<bel2>]), (<sslbls>)) Where sslbls above is specifically the subset of state space labels this error generator acts on nontrivially. When specifying global-style tuple labels the sslbls kwarg of this method which contains the complete set of state-space labels must also be specified.

sslblstuple or list, optional (default None)

A complete set of state space labels. Used when casting from a GlobalElementaryErrorgenLabel or from a tuple of length 3 (wherein the final element is interpreted as the set of ssblbs the error generator acts upon).

identity_labelstr, optional (default ‘I’)

An optional string specifying the label used to denote the identity in basis element labels.

Returns

LocalElementaryErrorgenLabel

support_indices(identity_label='I')

Returns a sorted tuple of the elements of indices of the nontrivial basis element label entries for this label.

class pygsti.baseobjs.errorgenlabel.GlobalElementaryErrorgenLabel(errorgen_type, basis_element_labels, sslbls, sort=True)

Bases: ElementaryErrorgenLabel

Labels an elementary error generator on n qubits that includes the state space labels on which the generator acts (unlike a “local” label, i.e. a LocalElementaryErrorgenLabel which doesn’t)

Parameters

errorgen_typestr

A string corresponding to the error generator sector this error generator label is an element of. Allowed values are ‘H’, ‘S’, ‘C’ and ‘A’.

basis_element_labelstuple or list

A list or tuple of strings labeling basis elements used to label this error generator. This is either length-1 for ‘H’ and ‘S’ type error generators, or length-2 for ‘C’ and ‘A’ type.

sslblstuple or list

A tuple or list of state space labels corresponding to the qudits upon which this error generator is supported.

sortbool, optional (default True)

If True then the input state space labels are first sorted, and then the used basis element labels are sorted to match the order to the newly sorted state space labels.

property support

Returns a sorted tuple of the elements of self.sslbls

errorgen_type = "''"
basis_element_labels
sslbls
classmethod cast(obj, sslbls=None, identity_label='I')

Method for casting an object to an instance of GlobalElementaryErrorgenLabel

Parameters
objGlobalElementaryErrorgenLabel, LocalElementaryErrorgenLabel, tuple or list

Object to cast. If a LocalElementaryErrorgenLabel then a value for the sslbls argument should be passed with the full list of state space labels for the system. Other castable options include:

-str: Following formatting options are supported.
  • A string formatted as ‘<type>(<bel1>[,<bel2>]:(<sslbls>))’ where <sslbls> is the subset of state-space labels this error generator acts on nontrivially specified as a comma-separated list. E.g. ‘H(XX:0,1)’ or ‘S(XIY):0,2’.

  • A string formatted as <type><bel>:<sslbls>, where <sslbls> is the subset of state-space labels this error generator acts on nontrivially specified as a comma-separated list. E.g. ‘HXX:0,1’ or ‘SIX:1’. Note this style is only compatible with basis element label error generators, and this only H and S.

  • A string formatted as <type><bel>. For this style the basis element label is assumed to correspond to the entire state space, and as such the sslbls kwarg for this method must also be specified. Like the previous example this is also only compatible with H and S terms.

-tuple/list: These can be specified either in ‘global-style’ or ‘local-style’.
  • local-style: format is (<type>, <bel1>[,<bel2>])

  • global-style:format is (<type>, (<bel1>,[<bel2>]), (<sslbls>)) Where sslbls above is specifically the subset of state space labels this error generator acts on nontrivially. When specifying global-style tuple labels the sslbls kwarg of this method which contains the complete set of state-space labels must also be specified.

sslblstuple or list, optional (default None)

A complete set of state space labels. Used when casting from a LocalElementaryErrorgenLabel or from a tuple of length 2 (wherein the final element is interpreted as the set of ssblbs the error generator acts upon).

identity_labelstr, optional (default ‘I’)

An optional string specifying the label used to denote the identity in basis element labels.

Returns

GlobalElementaryErrorgenLabel

padded_basis_element_labels(all_sslbls, identity_label='I')

Idle-padded versions of this label’s basis element labels based on its state space labels.

A tuple of strings which positions the non-trivial single-qubit labels within the elements of self.basis_element_labels into a background of identity_label characters. For example, if the ordering of all_sslbls is (0, 1, 2), self.sslbls is (1,), and self.basis_element_labels is (‘X’,) then this method returns (‘IXI’,).

For this method to work correctly, basis element labels should be composed of single characters corresponding to non-trivial single-qubit basis elements, and the total basis element should be a product of these along with the identity on the state space labels absent from self.sslbls.

Parameters
all_sslblstuple

An ordered list of the entirety of the state space labels to create padded basis element labels for. For example, (0, 1, 2) or (‘Q0’, ‘Q1’, ‘Q2’).

identity_labelstr, optional

The single-character label used to indicate the single-qubit identity operation.

Returns
tuple

A tuple of strings.

map_state_space_labels(mapper)

Creates a new GlobalElementaryErrorgenLabel whose sslbls attribute is updated according to a mapping function.

Parameters
mapperdict or function

A dictionary whose keys are the existing self.sslbls values and whose value are the new labels, or a function which takes a single existing state space label argument and returns a new state space label to replace it with.

Returns

GlobalElementaryErrorgenLabel

sort_sslbls()

Creates a new GlobalElementaryErrorgenLabel with sorted (potentially reordered) state space labels.

This puts the label into a canonical form that can be useful for comparison with other labels.

Returns

GlobalElementaryErrorgenLabel