pygsti.io.readers

Functions for loading GST objects from text files.

Module Contents

Functions

load_dataset(filename, cache=False, collision_action='aggregate', record_zero_counts=True, ignore_zero_count_lines=True, with_times='auto', circuit_parse_cache=None, verbosity=1)

Deprecated!

read_dataset(filename, cache=False, collision_action='aggregate', record_zero_counts=True, ignore_zero_count_lines=True, with_times='auto', circuit_parse_cache=None, verbosity=1)

Load a DataSet from a file.

load_multidataset(filename, cache=False, collision_action='aggregate', record_zero_counts=True, verbosity=1)

Deprecated!

read_multidataset(filename, cache=False, collision_action='aggregate', record_zero_counts=True, verbosity=1)

Load a MultiDataSet from a file.

load_time_dependent_dataset(filename, cache=False, record_zero_counts=True)

Deprecated!

read_time_dependent_dataset(filename, cache=False, record_zero_counts=True)

Load time-dependent (time-stamped) data as a DataSet.

load_model(filename)

Load a Model from a file, formatted using the standard text-format for models.

load_circuit_dict(filename)

Load a circuit dictionary from a file, formatted using the standard text-format.

load_circuit_list(filename, read_raw_strings=False, line_labels='auto', num_lines=None)

Deprecated!

read_circuit_list(filename, read_raw_strings=False, line_labels='auto', num_lines=None)

Load a circuit list from a file, formatted using the standard text-format.

read_circuit_strings(filename)

TODO: docstring - load various Circuit-containing standard objects from a file where

load_protocol_from_dir(dirname, quick_load=False, comm=None)

Deprecated!

read_protocol_from_dir(dirname, quick_load=False, comm=None)

Load a Protocol from a directory on disk.

load_edesign_from_dir(dirname, quick_load=False, comm=None)

Deprecated!

read_edesign_from_dir(dirname, quick_load=False, comm=None)

Load a ExperimentDesign from a directory on disk.

create_edesign_from_dir(dirname)

load_data_from_dir(dirname, quick_load=False, comm=None)

Deprecated!

read_data_from_dir(dirname, quick_load=False, comm=None)

Load a ProtocolData from a directory on disk.

load_results_from_dir(dirname, name=None, preloaded_data=None, quick_load=False, comm=None)

Deprecated!

read_results_from_dir(dirname, name=None, preloaded_data=None, quick_load=False, comm=None)

Load a ProtocolResults or ProtocolsResultsDir from a directory on disk.

pygsti.io.readers.load_dataset(filename, cache=False, collision_action='aggregate', record_zero_counts=True, ignore_zero_count_lines=True, with_times='auto', circuit_parse_cache=None, verbosity=1)

Deprecated!

pygsti.io.readers.read_dataset(filename, cache=False, collision_action='aggregate', record_zero_counts=True, ignore_zero_count_lines=True, with_times='auto', circuit_parse_cache=None, verbosity=1)

Load a DataSet from a file.

This function first tries to load file as a saved DataSet object, then as a standard text-formatted DataSet.

Parameters
  • filename (string) – The name of the file

  • cache (bool, optional) – When set to True, a pickle file with the name filename + “.cache” is searched for and loaded instead of filename if it exists and is newer than filename. If no cache file exists or one exists but it is older than filename, a cache file will be written after loading from filename.

  • collision_action ({"aggregate", "keepseparate"}) – Specifies how duplicate circuits should be handled. “aggregate” adds duplicate-circuit counts, whereas “keepseparate” tags duplicate circuits by setting their .occurrence IDs to sequential positive integers.

  • record_zero_counts (bool, optional) – Whether zero-counts are actually recorded (stored) in the returned DataSet. If False, then zero counts are ignored, except for potentially registering new outcome labels. When reading from a cache file (using cache==True) this argument is ignored: the presence of zero- counts is dictated by the value of record_zero_counts when the cache file was created.

  • ignore_zero_count_lines (bool, optional) – Whether circuits for which there are no counts should be ignored (i.e. omitted from the DataSet) or not.

  • with_times (bool or "auto", optional) – Whether to the time-stamped data format should be read in. If “auto”, then the time-stamped format is allowed but not required on a per-circuit basis (so the dataset can contain both formats). Typically you only need to set this to False when reading in a template file.

  • circuit_parse_cache (dict, optional) – A dictionary mapping qubit string representations into created Circuit objects, which can improve performance by reducing or eliminating the need to parse circuit strings.

  • verbosity (int, optional) – If zero, no output is shown. If greater than zero, loading progress is shown.

Returns

DataSet

pygsti.io.readers.load_multidataset(filename, cache=False, collision_action='aggregate', record_zero_counts=True, verbosity=1)

Deprecated!

pygsti.io.readers.read_multidataset(filename, cache=False, collision_action='aggregate', record_zero_counts=True, verbosity=1)

Load a MultiDataSet from a file.

This function first tries to load file as a saved MultiDataSet object, then as a standard text-formatted MultiDataSet.

Parameters
  • filename (string) – The name of the file

  • cache (bool, optional) – When set to True, a pickle file with the name filename + “.cache” is searched for and loaded instead of filename if it exists and is newer than filename. If no cache file exists or one exists but it is older than filename, a cache file will be written after loading from filename.

  • collision_action ({"aggregate", "keepseparate"}) – Specifies how duplicate circuits should be handled. “aggregate” adds duplicate-circuit counts, whereas “keepseparate” tags duplicate circuits by setting their .occurrence IDs to sequential positive integers.

  • record_zero_counts (bool, optional) – Whether zero-counts are actually recorded (stored) in the returned MultiDataSet. If False, then zero counts are ignored, except for potentially registering new outcome labels. When reading from a cache file (using cache==True) this argument is ignored: the presence of zero-counts is dictated by the value of record_zero_counts when the cache file was created.

  • verbosity (int, optional) – If zero, no output is shown. If greater than zero, loading progress is shown.

Returns

MultiDataSet

pygsti.io.readers.load_time_dependent_dataset(filename, cache=False, record_zero_counts=True)

Deprecated!

pygsti.io.readers.read_time_dependent_dataset(filename, cache=False, record_zero_counts=True)

Load time-dependent (time-stamped) data as a DataSet.

Parameters
  • filename (string) – The name of the file

  • cache (bool, optional) – Reserved to perform caching similar to read_dataset. Currently this argument doesn’t do anything.

  • record_zero_counts (bool, optional) – Whether zero-counts are actually recorded (stored) in the returned DataSet. If False, then zero counts are ignored, except for potentially registering new outcome labels.

Returns

DataSet

pygsti.io.readers.load_model(filename)

Load a Model from a file, formatted using the standard text-format for models.

Parameters

filename (string) – The name of the file

Returns

Model

pygsti.io.readers.load_circuit_dict(filename)

Load a circuit dictionary from a file, formatted using the standard text-format.

Parameters

filename (string) – The name of the file.

Returns

Dictionary with keys = circuit labels and values = Circuit objects.

pygsti.io.readers.load_circuit_list(filename, read_raw_strings=False, line_labels='auto', num_lines=None)

Deprecated!

pygsti.io.readers.read_circuit_list(filename, read_raw_strings=False, line_labels='auto', num_lines=None)

Load a circuit list from a file, formatted using the standard text-format.

Parameters
  • filename (string) – The name of the file

  • read_raw_strings (boolean) – If True, circuits are not converted to Circuit objects.

  • line_labels (iterable, optional) – The (string valued) line labels used to initialize Circuit objects when line label information is absent from the one-line text representation contained in filename. If ‘auto’, then line labels are taken to be the list of all state-space labels present in the circuit’s layers. If there are no such labels then the special value ‘*’ is used as a single line label.

  • num_lines (int, optional) – Specify this instead of line_labels to set the latter to the integers between 0 and num_lines-1.

Returns

list of Circuit objects

pygsti.io.readers.read_circuit_strings(filename)

TODO: docstring - load various Circuit-containing standard objects from a file where they have been replaced by their string representations

pygsti.io.readers.load_protocol_from_dir(dirname, quick_load=False, comm=None)

Deprecated!

pygsti.io.readers.read_protocol_from_dir(dirname, quick_load=False, comm=None)

Load a Protocol from a directory on disk.

Parameters
  • dirname (string) – Directory name.

  • quick_load (bool, optional) – Setting this to True skips the loading of components that may take a long time to load. This can be useful when this information isn’t needed and loading takes a long time.

  • comm (mpi4py.MPI.Comm, optional) – When not None, an MPI communicator used to synchronize file access.

Returns

Protocol

pygsti.io.readers.load_edesign_from_dir(dirname, quick_load=False, comm=None)

Deprecated!

pygsti.io.readers.read_edesign_from_dir(dirname, quick_load=False, comm=None)

Load a ExperimentDesign from a directory on disk.

Parameters
  • dirname (string) – Directory name.

  • quick_load (bool, optional) – Setting this to True skips the loading of components that may take a long time to load. This can be useful when this information isn’t needed and loading takes a long time.

  • comm (mpi4py.MPI.Comm, optional) – When not None, an MPI communicator used to synchronize file access.

Returns

ExperimentDesign

pygsti.io.readers.create_edesign_from_dir(dirname)
pygsti.io.readers.load_data_from_dir(dirname, quick_load=False, comm=None)

Deprecated!

pygsti.io.readers.read_data_from_dir(dirname, quick_load=False, comm=None)

Load a ProtocolData from a directory on disk.

Parameters
  • dirname (string) – Directory name.

  • quick_load (bool, optional) – Setting this to True skips the loading of components that may take a long time to load. This can be useful when this information isn’t needed and loading takes a long time.

  • comm (mpi4py.MPI.Comm, optional) – When not None, an MPI communicator used to synchronize file access.

Returns

ProtocolData

pygsti.io.readers.load_results_from_dir(dirname, name=None, preloaded_data=None, quick_load=False, comm=None)

Deprecated!

pygsti.io.readers.read_results_from_dir(dirname, name=None, preloaded_data=None, quick_load=False, comm=None)

Load a ProtocolResults or ProtocolsResultsDir from a directory on disk.

Which object type is loaded depends on whether name is given: if it is, then a ProtocolResults object is loaded. If not, a ProtocolsResultsDir results.

Parameters
  • dirname (string) – Directory name. This should be a “base” directory, containing subdirectories like “edesign”, “data”, and “results”

  • name (string or None) – The ‘name’ of a particular ProtocolResults object, which is a sub-directory beneath dirname/results/. If None, then all the results (all names) at the given base-directory are loaded and returned as a ProtocolResultsDir object.

  • preloaded_data (ProtocolData, optional) – The data object belonging to the to-be-loaded results, in cases when this has been loaded already (only use this if you know what you’re doing).

  • quick_load (bool, optional) – Setting this to True skips the loading of data and experiment-design components that may take a long time to load. This can be useful all the information of interest lies only within the results objects.

  • comm (mpi4py.MPI.Comm, optional) – When not None, an MPI communicator used to synchronize file access.

Returns

ProtocolResults or ProtocolResultsDir