Skip to content

Commit 91f4d79

Browse files
authored
Merge pull request #580 from sandialabs/bugfix-deterministicFOGI
Bugfix deterministic fogi
2 parents cf49a87 + c7791d7 commit 91f4d79

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pygsti/baseobjs/errorgenbasis.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def overlaps(sslbls):
231231

232232
sub_labels, sub_indices = zip(*[(lbl, i) for i, lbl in enumerate(self._labels)
233233
if overlaps(lbl[0])])
234+
sub_sslbls = sorted(sub_sslbls)
234235
sub_state_space = self.state_space.create_subspace(sub_sslbls)
235236
else:
236237
sub_labels = []
@@ -262,7 +263,7 @@ def union(self, other_basis):
262263
#Get the union of the two bases labels.
263264
union_labels = set(self._labels) | set(other_basis.labels)
264265
union_state_space = self.state_space.union(other_basis.state_space)
265-
return ExplicitElementaryErrorgenBasis(union_state_space, union_labels, self._basis_1q)
266+
return ExplicitElementaryErrorgenBasis(union_state_space, sorted(union_labels, key=lambda label: label.__str__()), self._basis_1q)
266267

267268
def intersection(self, other_basis):
268269
"""
@@ -277,7 +278,7 @@ def intersection(self, other_basis):
277278

278279
intersection_labels = set(self._labels) & set(other_basis.labels)
279280
intersection_state_space = self.state_space.intersection(other_basis.state_space)
280-
return ExplicitElementaryErrorgenBasis(intersection_state_space, intersection_labels, self._basis_1q)
281+
return ExplicitElementaryErrorgenBasis(intersection_state_space, sorted(intersection_labels, key=lambda label: label.__str__()), self._basis_1q)
281282

282283
def difference(self, other_basis):
283284
"""
@@ -295,7 +296,7 @@ def difference(self, other_basis):
295296
#that relied on the old (kind of incorrect behavior). Revert back to old version temporarily.
296297
#difference_state_space = self.state_space.difference(other_basis.state_space)
297298
difference_state_space = self.state_space
298-
return ExplicitElementaryErrorgenBasis(difference_state_space, difference_labels, self._basis_1q)
299+
return ExplicitElementaryErrorgenBasis(difference_state_space, sorted(difference_labels, key=lambda label: label.__str__()), self._basis_1q)
299300

300301
class CompleteElementaryErrorgenBasis(ElementaryErrorgenBasis):
301302
"""

0 commit comments

Comments
 (0)