pygsti.layouts.evaltree.EvalTree#

class EvalTree(iterable=(), /)#

Bases: list

Methods

__init__(*args, **kwargs)

append(object, /)

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

create(circuits_to_evaluate)

Note: circuits_to_evaluate can be either a list or an integer-keyed dict (for faster lookups), as we only take its length and index it.

extend(iterable, /)

Extend list by appending elements from the iterable.

find_splitting(num_elements, ...)

Find a partition of the indices of circuit_tree to define a set of sub-trees with the desire properties.

index(value[, start, stop])

Return first index of value.

insert(index, object, /)

Insert object before index.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

reverse()

Reverse IN PLACE.

sort(*[, key, reverse])

Sort the list in ascending order and return None.

append(object, /)#

Append object to the end of the list.

clear()#

Remove all items from list.

copy()#

Return a shallow copy of the list.

count(value, /)#

Return number of occurrences of value.

classmethod create(circuits_to_evaluate)#

Note: circuits_to_evaluate can be either a list or an integer-keyed dict (for faster lookups), as we only take its length and index it.

Returns:

eval_tree – A list of instructions (tuples), where each element contains information about evaluating a particular circuit: (iDest, iLeft, iRight). In particular, eval_tree[iDest] = eval_tree[iLeft] + eval_tree[iRight] as sequences so that matrix(eval_tree[iDest]) = matrixOf(eval_tree[iRight]) * matrixOf(eval_tree[iLeft])

Return type:

list

extend(iterable, /)#

Extend list by appending elements from the iterable.

find_splitting(num_elements, max_sub_tree_size, num_sub_trees, verbosity)#

Find a partition of the indices of circuit_tree to define a set of sub-trees with the desire properties.

This is done in order to reduce the maximum size of any tree (useful for limiting memory consumption or for using multiple cores). Must specify either max_sub_tree_size or num_sub_trees.

Parameters:
  • num_elements (int) – The number of elements self is meant to compute (this means that any tree indices >= num_elements are considered “scratch” space.

  • max_sub_tree_size (int, optional) – The maximum size (i.e. list length) of each sub-tree. If the original tree is smaller than this size, no splitting will occur. If None, then there is no limit.

  • num_sub_trees (int, optional) – The maximum size (i.e. list length) of each sub-tree. If the original tree is smaller than this size, no splitting will occur.

  • verbosity (int, optional) – How much detail to send to stdout.

Returns:

A list of sets of elements to place in sub-trees.

Return type:

list

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

insert(index, object, /)#

Insert object before index.

pop(index=-1, /)#

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value, /)#

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()#

Reverse IN PLACE.

sort(*, key=None, reverse=False)#

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.