pygsti.construction.repeat_and_truncate

pygsti.construction.repeat_and_truncate(x, N, assertAtLeastOneRep=False)

Repeat the gate string x so the repeated string has length greater than N, then truncate the string to be exactly length N.

Parameters:
  • x (tuple or GateString) – the gate string to repeat & truncate.
  • N (int) – the truncation length.
  • assertAtLeastOneRep (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 gate string

Return type:

tuple or GateString (whichever x was)