Skip to content

Commit 306e08f

Browse files
sort results from set algebra functions to obtain deterministic objects, mainly done to obtain deterministic FOGI models
1 parent cf49a87 commit 306e08f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pygsti/baseobjs/errorgenbasis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def union(self, other_basis):
262262
#Get the union of the two bases labels.
263263
union_labels = set(self._labels) | set(other_basis.labels)
264264
union_state_space = self.state_space.union(other_basis.state_space)
265-
return ExplicitElementaryErrorgenBasis(union_state_space, union_labels, self._basis_1q)
265+
return ExplicitElementaryErrorgenBasis(union_state_space, sorted(union_labels, key=lambda label: label.__str__()), self._basis_1q)
266266

267267
def intersection(self, other_basis):
268268
"""
@@ -277,7 +277,7 @@ def intersection(self, other_basis):
277277

278278
intersection_labels = set(self._labels) & set(other_basis.labels)
279279
intersection_state_space = self.state_space.intersection(other_basis.state_space)
280-
return ExplicitElementaryErrorgenBasis(intersection_state_space, intersection_labels, self._basis_1q)
280+
return ExplicitElementaryErrorgenBasis(intersection_state_space, sorted(intersection_labels, key=lambda label: label.__str__()), self._basis_1q)
281281

282282
def difference(self, other_basis):
283283
"""
@@ -295,7 +295,7 @@ def difference(self, other_basis):
295295
#that relied on the old (kind of incorrect behavior). Revert back to old version temporarily.
296296
#difference_state_space = self.state_space.difference(other_basis.state_space)
297297
difference_state_space = self.state_space
298-
return ExplicitElementaryErrorgenBasis(difference_state_space, difference_labels, self._basis_1q)
298+
return ExplicitElementaryErrorgenBasis(difference_state_space, sorted(difference_labels, key=lambda label: label.__str__()), self._basis_1q)
299299

300300
class CompleteElementaryErrorgenBasis(ElementaryErrorgenBasis):
301301
"""

0 commit comments

Comments
 (0)