pygsti.objects.GateString

class pygsti.objects.GateString(tupleOfGateLabels, stringRepresentation=None, bCheck=True)

Encapsulates a gate string as a tuple of gate labels associated with a string representation for that tuple.

Typically there are multiple string representations for the same tuple (for example “GxGx” and “Gx^2” both correspond to the tuple (“Gx”,”Gx”) ) and it is convenient to store a specific string represntation along with the tuple.

A GateString objects behaves very similarly to a tuple and most operations supported by a tuple are supported by a GateString (e.g. adding, hashing, testing for equality, indexing, slicing, multiplying).

__init__(tupleOfGateLabels, stringRepresentation=None, bCheck=True)

Create a new GateString object

Parameters:
  • tupleOfGateLabels (tuple or GateString (or None)) – A tuple of gate labels specifying the gate sequence, or None if the sequence should be obtained by evaluating stringRepresentation as a standard-text-format gate string (e.g. “GxGy”, “Gx(Gy)^2, or “{}”).
  • stringRepresentation (string, optional) – A string representation of this GateString.
  • bCheck (bool, optional) – If true, raise ValueEror if stringRepresentation does not evaluate to tupleOfGateLabels.

Methods

__init__(tupleOfGateLabels[, ...]) Create a new GateString object
from_pythonstr(pythonString, gateLabels) Create a GateString from a python string where each gate label is represented as a single character, starting with ‘A’ and contining down the alphabet.
to_pythonstr(gateLabels) Convert this gate string into a python string, where each gate label is represented as a single character, starting with ‘A’ and contining down the alphabet.