pygsti.circuits.circuit.CompressedCircuit#

class CompressedCircuit(circuit, min_len_to_compress=20, max_period_to_look_for=20)#

Bases: object

A “compressed” Circuit that requires less disk space.

The tuple of circuit layers is compressed using a custom algorithm which looks for repeated portions of the circuit.

One place where CompressedCircuit objects can be useful is when saving large lists of long operation sequences in some non-human-readable format (e.g. pickle). CompressedCircuit objects cannot be used in place of Circuit objects within pyGSTi, and so are not useful when manipulating and running algorithms which use operation sequences.

Parameters:
  • circuit (Circuit) – The operation sequence object which is compressed to create a new CompressedCircuit object.

  • min_len_to_compress (int, optional) – The minimum length string to compress. If len(circuit) is less than this amount its tuple is returned.

  • max_period_to_look_for (int, optional) – The maximum period length to use when searching for periodic structure within circuit. Larger values mean the method takes more time but could result in better compressing.

Create a new CompressedCircuit object

Parameters:
  • circuit (Circuit) – The operation sequence object which is compressed to create a new CompressedCircuit object.

  • min_len_to_compress (int) – The minimum length string to compress. If len(circuit) is less than this amount its tuple is returned.

  • max_period_to_look_for (int) – The maximum period length to use when searching for periodic structure within circuit. Larger values mean the method takes more time but could result in better compressing.

Methods

__init__(circuit[, min_len_to_compress, ...])

Create a new CompressedCircuit object

compress_op_label_tuple(circuit[, ...])

Compress a operation sequence.

expand()

Expands this compressed operation sequence into a Circuit object.

expand_op_label_tuple(compressed_op_labels)

Expand a compressed tuple (created with compress_op_label_tuple()) into a tuple of operation labels.

static compress_op_label_tuple(circuit, min_len_to_compress=20, max_period_to_look_for=20)#

Compress a operation sequence.

The result is tuple with a special compressed- gate-string form form that is not useable by other GST methods but is typically shorter (especially for long operation sequences with a repetitive structure) than the original operation sequence tuple.

Parameters:
  • circuit (tuple of operation labels or Circuit) – The operation sequence to compress.

  • min_len_to_compress (int) – The minimum length string to compress. If len(circuit) is less than this amount its tuple is returned.

  • max_period_to_look_for (int) – The maximum period length to use when searching for periodic structure within circuit. Larger values mean the method takes more time but could result in better compressing.

Returns:

The compressed (or raw) operation sequence tuple.

Return type:

tuple

expand()#

Expands this compressed operation sequence into a Circuit object.

Return type:

Circuit

static expand_op_label_tuple(compressed_op_labels)#

Expand a compressed tuple (created with compress_op_label_tuple()) into a tuple of operation labels.

Parameters:

compressed_op_labels (tuple) – a tuple in the compressed form created by compress_op_label_tuple(…).

Returns:

A tuple of operation labels specifying the uncompressed operation sequence.

Return type:

tuple