Skip to content

Bugfix esplodeded fogi labels #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pygsti/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,13 @@ def __setstate__(self, state_dict):
## Get/Set methods
##########################################

@property
def parameter_labels(self):
"""
A list of labels, usually of the form `(op_label, string_description)` describing this model's parameters.
"""
return self._ops_paramlbls_to_model_paramlbls(self._paramlbls)

@property
def sim(self):
""" Forward simulator for this model """
Expand Down Expand Up @@ -1037,7 +1044,7 @@ def _get_shift(j): return _bisect.bisect_left(indices_to_remove, j)
obj.set_gpindices(new_inds, self, memo)

self._paramvec = self._ops_paramvec_to_model_paramvec(w)
self._paramlbls = self._ops_paramlbls_to_model_paramlbls(wl)
self._paramlbls = wl
self._param_bounds = wb if _param_bounds_are_nontrivial(wb) else None
if debug: print("DEBUG: Done rebuild: %d op params" % len(w))

Expand Down
2 changes: 1 addition & 1 deletion pygsti/models/modelparaminterposer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def ops_paramlbls_to_model_paramlbls(self, wl):
# This can and should be improved later - particularly this will be awful when labels (els of wl) are tuples.
ret = []
for irow in range(self.inv_transform_matrix.shape[0]):
lbl = ' + '.join(["%g%s" % (coeff, str(lbl)) for coeff, lbl in zip(self.inv_transform_matrix[irow, :], wl)])
lbl = ' + '.join(["%g%s" % (coeff, str(lbl)) for coeff, lbl in zip(self.inv_transform_matrix[irow, :], wl) if abs(coeff)>1e-10])
ret.append(lbl)
return ret

Expand Down
6 changes: 6 additions & 0 deletions pygsti/protocols/gst.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,9 @@ def _to_nice_serialization(self):
for lbl, goparams in self.gaugeopt_argument_dicts.items():
goparams_list = [goparams] if hasattr(goparams, 'keys') else goparams
serialize_list = []
if lbl == 'trivial_gauge_opt':
dicts_to_serialize[lbl] = None
continue
for goparams_dict in goparams_list:
to_add = goparams_dict.copy()
if 'target_model' in to_add:
Expand Down Expand Up @@ -1164,6 +1167,9 @@ def _to_nice_serialization(self):
def _from_nice_serialization(cls, state): # memo holds already de-serialized objects
gaugeopt_argument_dicts = {}
for lbl, serialized_goparams_list in state['gaugeopt_argument_dicts'].items():
if lbl == 'trivial_gauge_opt':
gaugeopt_argument_dicts[lbl] = None
continue
goparams_list = []
for serialized_goparams in serialized_goparams_list:
to_add = serialized_goparams.copy()
Expand Down
Loading