pygsti.circuits.circuitconstruction.create_circuits

pygsti.circuits.circuitconstruction.create_circuits#

create_circuits(*args, **kwargs)#

Create a list of circuits using a nested loop.

Positional arguments specify evaluation strings, which are evaluated within the inner-loop for a nested loop over all list or tuple type keyword arguments.

Parameters:
  • args (list of strings) – Positional arguments are strings that python can evaluate into either a tuple of operation labels or a Circuit instance. If evaluation raises an AssertionError (an assert statement fails) then that inner loop evaluation is skipped and list construction proceeds.

  • kwargs (dict) – keys specify variable names that can be used in positional argument strings.

Return type:

list of Circuit

Examples

>>> from pygsti.circuits import create_circuits
>>> As = [('a1',), ('a2',)]
>>> Bs = [('b1',), ('b2',)]
>>> list1 = create_circuits('a', 'a+b', a=As, b=Bs)
>>> print(list(map(str, list1)))
['a1', 'a2', 'a1b1', 'a1b2', 'a2b1', 'a2b2']

You can change the order in which the different iterables are advanced.

>>> list2 = create_circuits('a+b', a=As, b=Bs, order=['a', 'b'])
>>> print(list(map(str, list2)))
['a1b1', 'a1b2', 'a2b1', 'a2b2']
>>> list3 = create_circuits('a+b', a=As, b=Bs, order=['b', 'a'])
>>> print(list(map(str, list3)))
['a1b1', 'a2b1', 'a1b2', 'a2b2']