From edff13c4f60d2d0eb4985bc156dd56b7e5f80321 Mon Sep 17 00:00:00 2001 From: Shelly Garion Date: Mon, 4 Dec 2023 10:34:08 +0000 Subject: [PATCH 1/3] fix a bug in StabilizerState repr --- qiskit/quantum_info/states/stabilizerstate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/quantum_info/states/stabilizerstate.py b/qiskit/quantum_info/states/stabilizerstate.py index 7ba0698500aa..5420f54561c5 100644 --- a/qiskit/quantum_info/states/stabilizerstate.py +++ b/qiskit/quantum_info/states/stabilizerstate.py @@ -95,7 +95,7 @@ def __eq__(self, other): return (self._data.stab == other._data.stab).all() def __repr__(self): - return f"StabilizerState({self._data.stabilizer})" + return f"StabilizerState({self._data.to_labels(mode='S')})" @property def clifford(self): From 378cfffd141304dfb10a11cbafcad2c3b936bab7 Mon Sep 17 00:00:00 2001 From: Shelly Garion Date: Mon, 4 Dec 2023 10:34:43 +0000 Subject: [PATCH 2/3] add a test to check repr does not throw an error --- test/python/quantum_info/states/test_stabilizerstate.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/python/quantum_info/states/test_stabilizerstate.py b/test/python/quantum_info/states/test_stabilizerstate.py index c6a9e6bb7462..c7053e1d109b 100644 --- a/test/python/quantum_info/states/test_stabilizerstate.py +++ b/test/python/quantum_info/states/test_stabilizerstate.py @@ -980,6 +980,12 @@ def test_stabilizer_bell_equiv(self): self.assertFalse(cliff1.equiv(cliff3)) self.assertFalse(cliff2.equiv(cliff4)) + def test_visualize_does_not_throw_error(self): + """Test to verify that drawing StabilizerState does not throw an error""" + clifford = random_clifford(3, seed=0) + stab = StabilizerState(clifford) + _ = repr(stab) + if __name__ == "__main__": unittest.main() From ae5d97e49d5d0c262a9d68461901104686efd169 Mon Sep 17 00:00:00 2001 From: Shelly Garion Date: Tue, 5 Dec 2023 06:21:44 +0000 Subject: [PATCH 3/3] add release notes --- .../notes/fix-stabilizerstate-repr-908c830028b1f868.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 releasenotes/notes/fix-stabilizerstate-repr-908c830028b1f868.yaml diff --git a/releasenotes/notes/fix-stabilizerstate-repr-908c830028b1f868.yaml b/releasenotes/notes/fix-stabilizerstate-repr-908c830028b1f868.yaml new file mode 100644 index 000000000000..735c8b3b31fd --- /dev/null +++ b/releasenotes/notes/fix-stabilizerstate-repr-908c830028b1f868.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Fix a bug in the :class:`.StabilizerState` string representation.