Skip to content

Commit 74648a6

Browse files
authored
Merge pull request #488 from sandialabs/bugfix-esplodeded-fogi-labels
Bugfix esplodeded fogi labels
2 parents c1f97f8 + 2af7e11 commit 74648a6

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Diff for: pygsti/models/model.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,13 @@ def __setstate__(self, state_dict):
488488
## Get/Set methods
489489
##########################################
490490

491+
@property
492+
def parameter_labels(self):
493+
"""
494+
A list of labels, usually of the form `(op_label, string_description)` describing this model's parameters.
495+
"""
496+
return self._ops_paramlbls_to_model_paramlbls(self._paramlbls)
497+
491498
@property
492499
def sim(self):
493500
""" Forward simulator for this model """
@@ -1037,7 +1044,7 @@ def _get_shift(j): return _bisect.bisect_left(indices_to_remove, j)
10371044
obj.set_gpindices(new_inds, self, memo)
10381045

10391046
self._paramvec = self._ops_paramvec_to_model_paramvec(w)
1040-
self._paramlbls = self._ops_paramlbls_to_model_paramlbls(wl)
1047+
self._paramlbls = wl
10411048
self._param_bounds = wb if _param_bounds_are_nontrivial(wb) else None
10421049
if debug: print("DEBUG: Done rebuild: %d op params" % len(w))
10431050

Diff for: pygsti/models/modelparaminterposer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def ops_paramlbls_to_model_paramlbls(self, wl):
7777
# This can and should be improved later - particularly this will be awful when labels (els of wl) are tuples.
7878
ret = []
7979
for irow in range(self.inv_transform_matrix.shape[0]):
80-
lbl = ' + '.join(["%g%s" % (coeff, str(lbl)) for coeff, lbl in zip(self.inv_transform_matrix[irow, :], wl)])
80+
lbl = ' + '.join(["%g%s" % (coeff, str(lbl)) for coeff, lbl in zip(self.inv_transform_matrix[irow, :], wl) if abs(coeff)>1e-10])
8181
ret.append(lbl)
8282
return ret
8383

Diff for: pygsti/protocols/gst.py

+6
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,9 @@ def _to_nice_serialization(self):
11331133
for lbl, goparams in self.gaugeopt_argument_dicts.items():
11341134
goparams_list = [goparams] if hasattr(goparams, 'keys') else goparams
11351135
serialize_list = []
1136+
if lbl == 'trivial_gauge_opt':
1137+
dicts_to_serialize[lbl] = None
1138+
continue
11361139
for goparams_dict in goparams_list:
11371140
to_add = goparams_dict.copy()
11381141
if 'target_model' in to_add:
@@ -1164,6 +1167,9 @@ def _to_nice_serialization(self):
11641167
def _from_nice_serialization(cls, state): # memo holds already de-serialized objects
11651168
gaugeopt_argument_dicts = {}
11661169
for lbl, serialized_goparams_list in state['gaugeopt_argument_dicts'].items():
1170+
if lbl == 'trivial_gauge_opt':
1171+
gaugeopt_argument_dicts[lbl] = None
1172+
continue
11671173
goparams_list = []
11681174
for serialized_goparams in serialized_goparams_list:
11691175
to_add = serialized_goparams.copy()

0 commit comments

Comments
 (0)