Skip to content

Commit

Permalink
Adds some extra logic for processing gauge-optimization suite object …
Browse files Browse the repository at this point in the history
…when running GST.

Adds logic that treats a gauge optimization suite object with `None` as its
suite names (checks of `gaugeopt_suite.gaugeopt_suite_names is None`) as specifying
that no gauge optimization should be performed.  Such an object is build if
gaugeopt_suite=None is passed when creating a GST protocol, and so we should
handle this case gracefully (previously this would result in an error).
  • Loading branch information
enielse committed Sep 26, 2023
1 parent 69357a7 commit 6827098
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pygsti/protocols/gst.py
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,7 @@ def _add_badfit_estimates(results, base_estimate_label, badfit_options,
#corresponding to the elements of gaugeopt_labels. In this case let's make
#base_estimate.extra_parameters['wildcard1d' + "_unmodeled_error"] a dictionary of
#the serialized PrimitiveOpsSingleScaleWildcardBudget elements
if gaugeopt_suite is not None:
if gaugeopt_suite is not None and gaugeopt_suite.gaugeopt_suite_names is not None:
gaugeopt_labels = gaugeopt_suite.gaugeopt_suite_names
base_estimate.extra_parameters['wildcard1d' + "_unmodeled_error"] = {lbl: budget[lbl].to_nice_serialization() for lbl in gaugeopt_labels}
base_estimate.extra_parameters['wildcard1d' + "_unmodeled_active_constraints"] \
Expand Down Expand Up @@ -2116,14 +2116,14 @@ def _compute_wildcard_budget_1d_model(estimate, objfn_cache, mdc_objfn, paramete
redbox_threshold = _chi2.ppf(1 - percentile / nboxes, 1)

ref, reference_name = _compute_1d_reference_values_and_name(estimate, badfit_options, gaugeopt_suite)
if gaugeopt_suite is None:

if gaugeopt_suite is None or gaugeopt_suite.gaugeopt_suite_names is None:
gaugeopt_labels = None
primitive_ops = list(ref.keys())
else:
gaugeopt_labels= gaugeopt_suite.gaugeopt_suite_names
gaugeopt_labels = gaugeopt_suite.gaugeopt_suite_names
primitive_ops = list(ref[list(gaugeopt_labels)[0]].keys())

if gaugeopt_labels is None:
wcm = _wild.PrimitiveOpsSingleScaleWildcardBudget(primitive_ops, [ref[k] for k in primitive_ops],
reference_name=reference_name)
Expand All @@ -2144,7 +2144,7 @@ def _compute_1d_reference_values_and_name(estimate, badfit_options, gaugeopt_sui
DOCSTRING: TODO
'''
if badfit_options.wildcard1d_reference == 'diamond distance':
if gaugeopt_suite is None:
if gaugeopt_suite is None or gaugeopt_suite.gaugeopt_suite_names is None:
final_model = estimate.models['final iteration estimate']
target_model = estimate.models['target']
gaugeopt_model = _alg.gaugeopt_to_target(final_model, target_model)
Expand Down

0 comments on commit 6827098

Please sign in to comment.