From 18e719517b1b5d15767df2e78abdc88b866b5bac Mon Sep 17 00:00:00 2001 From: Mc-Zen Date: Sun, 18 Feb 2024 10:15:26 +0100 Subject: [PATCH] [fix] EntanglementStructure to string (changed in Python 3.11) --- src/htstabilizer/lc_classes.py | 3 +-- tests/test_lc_classes.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/htstabilizer/lc_classes.py b/src/htstabilizer/lc_classes.py index 994284b..d2bc1cd 100644 --- a/src/htstabilizer/lc_classes.py +++ b/src/htstabilizer/lc_classes.py @@ -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() diff --git a/tests/test_lc_classes.py b/tests/test_lc_classes.py index 3fb8eb9..c9ab3cc 100644 --- a/tests/test_lc_classes.py +++ b/tests/test_lc_classes.py @@ -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)) \ No newline at end of file