From 69357a78b5e2401f652f834263c3807faa0cc49e Mon Sep 17 00:00:00 2001 From: Erik Nielsen Date: Tue, 26 Sep 2023 11:23:14 -0400 Subject: [PATCH] Updates germ_length_limit interpretation to avoid dropping a germ completely. Previously, in GST circuit construction when a maximum length was greater than the per-germ maximum length given by the `germ_length_limit` argument, the circuits for that germ were always omitted. This could be annoying, however, if *only* large maximum lengths are given and a germ has a max-length limit smaller than all the maximum lengths requested. This commit alters the behavior of the GST circuit construction routines to include the circuits for such a germ that have the germ's repeated length equals its max-length-limit (even though this limit is smaller than the first maximum length requested). --- pygsti/circuits/gstcircuits.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pygsti/circuits/gstcircuits.py b/pygsti/circuits/gstcircuits.py index 4d05caee7..8561a9ebb 100644 --- a/pygsti/circuits/gstcircuits.py +++ b/pygsti/circuits/gstcircuits.py @@ -202,7 +202,12 @@ def _create_raw_lsgst_lists(op_label_src, prep_strs, effect_strs, germ_list, max else: #Typical case of germs repeated to maxLen using Rfn for germ in germ_list: - if maxLen > germ_length_limits.get(germ, 1e100): continue + if maxLen == max_length_list[0] and maxLen > germ_length_limits.get(germ, 1e100): + maxLen_thisgerm = germ_length_limits[germ] # IndexError should not occur here! + elif maxLen > germ_length_limits.get(germ, 1e100): + continue + else: + maxLen_thisgerm = maxLen if rndm is None: fiducialPairsThisIter = fiducialPairs[germ] @@ -232,7 +237,7 @@ def _create_raw_lsgst_lists(op_label_src, prep_strs, effect_strs, germ_list, max lst += _gsc.create_circuits("f[0]+R(germ,N)+f[1]", f=fiducialPairsThisIter, - germ=germ, N=maxLen, + germ=germ, N=maxLen_thisgerm, R=Rfn, order=('f',)) if nest: lsgst_list += lst # add new strings to running list @@ -566,9 +571,14 @@ def add_to_plaquettes(pkey_dict, plaquette_dict, base_circuit, maxlen, germ, pow #Typical case of germs repeated to maxLen using r_fn for ii, germ in enumerate(germs): if germ == empty_germ: continue # handled specially above - if maxLen > germ_length_limits.get(germ, 1e100): continue + if maxLen == max_lengths[0] and maxLen > germ_length_limits.get(germ, 1e100): + maxLen_thisgerm = germ_length_limits[germ] # IndexError should not occur here! + elif maxLen > germ_length_limits.get(germ, 1e100): + continue + else: + maxLen_thisgerm = maxLen - germ_power = truncFn(germ, maxLen) + germ_power = truncFn(germ, maxLen_thisgerm) power = len(germ_power) // len(germ) # this *could* be the germ power if germ_power != germ * power: power = None # Signals there is no well-defined power @@ -579,7 +589,7 @@ def add_to_plaquettes(pkey_dict, plaquette_dict, base_circuit, maxlen, germ, pow # Switch on fidpair dicts with germ or (germ, L) keys key = germ if fidpair_germ_power_keys: - key = (germ, maxLen) + key = (germ, maxLen_thisgerm) if rndm is None: fiducialPairsThisIter = fidPairDict.get(key, allPossiblePairs) \