pygsti.circuits.circuitconstruction.repeat_and_truncate

pygsti.circuits.circuitconstruction.repeat_and_truncate#

repeat_and_truncate(x, n, assert_at_least_one_rep=False)#

Repeat and truncate x to yield a sequence with exactly length n.

Repeats x so the result has length greater than n, then truncates it to have exactly length n.

Parameters:
  • x (tuple or Circuit) – the operation sequence to repeat & truncate.

  • n (int) – the truncation length.

  • assert_at_least_one_rep (bool, optional) – if True, assert that number of repetitions is > 0. This is always the case when x has length > 0.

Returns:

the repeated-then-truncated operation sequence

Return type:

tuple or Circuit (whichever x was)