Skip to content

Commit

Permalink
[fix] EntanglementStructure to string (changed in Python 3.11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mc-Zen committed Feb 18, 2024
1 parent a851d0a commit 18e7195
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/htstabilizer/lc_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ def __repr__(self) -> str:

def __str__(self) -> str:
id = self.id()
type = str(self.type)
data = ", ".join(map(str, [item.data for sublist in self.data.groups for item in sublist]))
return f"LCClass{self.num_qubits()}{{{type[type.index('.') + 1:]} / {id} / {data}}})"
return f"LCClass{self.num_qubits()}{{{self.type.name} / {id} / {data}}})"

def __eq__(self, other) -> bool:
return self.num_qubits() == other.num_qubits() and self.id() == other.id()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lc_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def test_get_type(self):
self.assertEqual(LCClass2.get_entanglement_structure(1), LCClass2.EntanglementStructure.Entangled)

def test_str(self):
print(str(LCClass4(5)))
self.assertEqual(str(LCClass4(5)), "LCClass4{Pair / 5 / [0], [2], [1, 3]})")

def test_eq(self):
self.assertEqual(LCClass4(5), LCClass4(5))

0 comments on commit 18e7195

Please sign in to comment.