pygsti.objects.DataSet¶
-
class
pygsti.objects.
DataSet
(counts=None, gateStrings=None, gateStringIndices=None, spamLabels=None, spamLabelIndices=None, bStatic=False, fileToLoadFrom=None)¶ The DataSet class associates gate strings with counts for each spam label, and can be thought of as a table with gate strings labeling the rows and spam labels labeling the columns. It is designed to behave similarly to a dictionary of dictionaries, so that counts are accessed by: count = dataset[gateString][spamLabel]
-
__init__
(counts=None, gateStrings=None, gateStringIndices=None, spamLabels=None, spamLabelIndices=None, bStatic=False, fileToLoadFrom=None) Initialize a DataSet.
Parameters: - counts (2D numpy array (static case) or list of 1D numpy arrays (non-static case)) – Specifies spam label counts. In static case, rows of counts correspond to gate strings and columns to spam labels. In non-static case, different arrays correspond to gate strings and each array contains counts for the spam labels.
- gateStrings (list of (tuples or GateStrings)) – Each element is a tuple of gate labels or a GateString object. Indices for these strings are assumed to ascend from 0. These indices must correspond to rows/elements of counts (above). Only specify this argument OR gateStringIndices, not both.
- gateStringIndices (ordered dictionary) – An OrderedDict with keys equal to gate strings (tuples of gate labels) and values equal to integer indices associating a row/element of counts with the gate string. Only specify this argument OR gateStrings, not both.
- spamLabels (list of strings) – Specifies the set of spam labels for the DataSet. Indices for the spam labels are assumed to ascend from 0, starting with the first element of this list. These indices will index columns of the counts array/list. Only specify this argument OR spamLabelIndices, not both.
- spamLabelIndices (ordered dictionary) – An OrderedDict with keys equal to spam labels (strings) and value equal to integer indices associating a spam label with a column of counts. Only specify this argument OR spamLabels, not both.
- bStatic (bool) –
- When True, create a read-only, i.e. “static” DataSet which cannot be modified. In
- this case you must specify the counts, gate strings, and spam labels.
- When False, create a DataSet that can have counts added to it. In this case,
- you only need to specify the spam labels.
- fileToLoadFrom (string or file object) – Specify this argument and no others to create a static DataSet by loading from a file (just like using the load(...) function).
Returns: a new data set object.
Return type:
Methods
__init__
([counts, gateStrings, ...])Initialize a DataSet. add_count_dict
(gateString, countDict)Add a single gate string’s counts to this DataSet add_count_list
(gateString, countList)Add a single gate string’s counts to this DataSet. add_counts_1q
(gateString, nPlus, nMinus)Single-qubit version of addCountsDict, for convenience when the DataSet contains two spam labels, ‘plus’ and ‘minus’. add_counts_from_dataset
(otherDataSet)Append another DataSet’s data to this DataSet copy
()Make a copy of this DataSet. copy_nonstatic
()Make a non-static copy of this DataSet. done_adding_data
()Promotes a non-static DataSet to a static (read-only) DataSet. get_gate_labels
()Get a list of all the distinct gate labels used in the gate strings of this dataset. get_spam_labels
()Get the spam labels of this DataSet. has_key
(gatestring)Test whether data set contains a given gate string. iteritems
()Iterator over (gateString, countData) pairs, where gateString is a tuple of gate labels and countData is a DataSetRow instance, which behaves similarly to a dictionary with spam labels as keys and counts as values. itervalues
()Iterator over DataSetRow instances corresponding to the count data for each gate string. keys
()Returns the gate strings of this DataSet as tuples of gate labels (not GateString objects). load
(fileOrFilename)Load DataSet from a file, clearing any data is contained previously. save
(fileOrFilename)Save this DataSet to a file. truncate
(listOfGateStringsToKeep[, ...])Create a truncated dataset comprised of a subset of the counts in this dataset. -