pygsti.data.multidataset

Defines the MultiDataSet class and supporting classes and functions

Module Contents

Classes

_MultiDataSetKVIterator

Iterator class for dataset_name,DataSet pairs of a MultiDataSet

_MultiDataSetValueIterator

Iterator class for DataSets of a MultiDataSet

MultiDataSet

A collection of DataSets that hold data for the same circuits.

class pygsti.data.multidataset._MultiDataSetKVIterator(multidataset)

Bases: object

Iterator class for dataset_name,DataSet pairs of a MultiDataSet

Parameters

multidataset (MultiDataSet) – The parent MultiDataSet.

next
__iter__(self)
__next__(self)
class pygsti.data.multidataset._MultiDataSetValueIterator(multidataset)

Bases: object

Iterator class for DataSets of a MultiDataSet

Parameters

multidataset (MultiDataSet) – The parent multi data set.

next
__iter__(self)
__next__(self)
class pygsti.data.multidataset.MultiDataSet(oli_dict=None, time_dict=None, rep_dict=None, circuit_indices=None, outcome_labels=None, outcome_label_indices=None, file_to_load_from=None, collision_actions=None, comment=None, comments=None, aux_info=None)

Bases: object

A collection of DataSets that hold data for the same circuits.

The MultiDataSet class allows for the combined access and storage of several static DataSets that contain the same circuits (in the same order) AND the same time-dependence structure (if applicable).

It is designed to behave similarly to a dictionary of DataSets, so that a DataSet is obtained by:

dataset = multiDataset[dataset_name]

where dataset_name may be a string OR a tuple.

Parameters
  • oli_dict (ordered dictionary, optional) – Keys specify dataset names. Values are 1D numpy arrays which specify outcome label indices. Each value is indexed by the values of circuit_indices.

  • time_dict (ordered dictionary, optional) – Same format as oli_dict except stores arrays of floating-point time stamp data.

  • rep_dict (ordered dictionary, optional) – Same format as oli_dict except stores arrays of integer repetition counts (can be None if there are no repetitions)

  • circuit_indices (ordered dictionary, optional) – An OrderedDict with keys equal to circuits (tuples of operation labels) and values equal to integer indices associating a row/element of counts with the circuit.

  • outcome_labels (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 associate each elememtn of timeseries with a spam label. Only specify this argument OR outcome_label_indices, not both.

  • outcome_label_indices (ordered dictionary) – An OrderedDict with keys equal to spam labels (strings) and value equal to integer indices associating a spam label with given index. Only specify this argument OR outcome_labels, not both.

  • file_to_load_from (string or file object, optional) – Specify this argument and no others to create a MultiDataSet by loading from a file (just like using the load(…) function).

  • collision_actions (dictionary, optional) – Specifies how duplicate circuits should be handled for the data sets. Keys must match those of oli_dict and values are “aggregate” or “keepseparate”. See documentation for DataSet. If None, then “aggregate” is used for all sets by default.

  • comment (string, optional) – A user-specified comment string that gets carried around with the data. A common use for this field is to attach to the data details regarding its collection.

  • comments (dict, optional) – A user-specified dictionary of comments, one per dataset. Keys are dataset names (same as oli_dict keys).

  • aux_info (dict, optional) – A user-specified dictionary of per-circuit auxiliary information. Keys should be the circuits in this MultiDataSet and value should be Python dictionaries.

property outcome_labels(self)

Get a list of all the outcome labels contained in this MultiDataSet.

Returns

list of strings or tuples – A list where each element is an outcome label (which can be a string or a tuple of strings).

__iter__(self)
__len__(self)
__getitem__(self, dataset_name)
__setitem__(self, dataset_name, dataset)
__contains__(self, dataset_name)
keys(self)

A list of the keys (dataset names) of this MultiDataSet

Returns

list

items(self)

Iterator over (dataset name, DataSet) pairs.

values(self)

Iterator over DataSets corresponding to each dataset name.

datasets_aggregate(self, *dataset_names)

Generate a new DataSet by combining the outcome counts of multiple member Datasets.

Data with the same time-stamp and outcome are merged into a single “bin” in the returned DataSet.

Parameters

dataset_names (list of strs) – one or more dataset names.

Returns

DataSet – a single DataSet containing the summed counts of each of the data named by the parameters.

add_dataset(self, dataset_name, dataset, update_auxinfo=True)

Add a DataSet to this MultiDataSet.

The dataset must be static and conform with the circuits and time-dependent structure passed upon construction or those inherited from the first dataset added.

Parameters
  • dataset_name (string) – The name to give the added dataset (i.e. the key the new data set will be referenced by).

  • dataset (DataSet) – The data set to add.

  • update_auxinfo (bool, optional) – Whether the auxiliary information (if any exists) in dataset is added to the information already stored in this MultiDataSet.

Returns

None

__str__(self)

Return str(self).

copy(self)

Make a copy of this MultiDataSet

Returns

MultiDataSet

__getstate__(self)
__setstate__(self, state_dict)
save(self, file_or_filename)
write_binary(self, file_or_filename)

Write this MultiDataSet to a binary-format file.

Parameters

file_or_filename (file or string) – Either a filename or a file object. In the former case, if the filename ends in “.gz”, the file will be gzip compressed.

Returns

None

load(self, file_or_filename)
read_binary(self, file_or_filename)

Read a MultiDataSet from a file, clearing any data is contained previously.

The file should have been created with :method:`MultiDataSet.write_binary`

Parameters

file_or_filename (file or string) – Either a filename or a file object. In the former case, if the filename ends in “.gz”, the file will be gzip uncompressed as it is read.

Returns

None

add_auxiliary_info(self, circuit, aux)

Add auxiliary meta information to circuit.

Parameters
  • circuit (tuple or Circuit) – A tuple of operation labels specifying the circuit or a Circuit object

  • aux (dict, optional) – A dictionary of auxiliary meta information to be included with this set of data counts (associated with circuit).

Returns

None