pygsti.objects.WeightedGateString

class pygsti.objects.WeightedGateString(tupleOfGateLabels, stringRepresentation=None, weight=1.0, bCheck=True)

A GateString that contains an additional “weight” member used for building up weighted lists of gate strings.

When two WeightedGateString objects are added together their weights add, and when a WeightedGateString object is multiplied by an integer (equivalent to being raised to a power) the weight is unchanged. When added to plain GateString objects, the plain GateString object is treated as having zero weight and the result is another WeightedGateString.

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

Create a new WeightedGateString object

Parameters:
  • tupleOfGateLabels (tuple (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 WeightedGateString.
  • weight (float, optional) – the weight to assign this gate string.
  • bCheck (bool, optional) – If true, raise ValueEror if stringRepresentation does not evaluate to tupleOfGateLabels.

Methods

__init__(tupleOfGateLabels[, ...]) Create a new WeightedGateString 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.