Skip to content

Commit

Permalink
Fix a bug is StabilizerState repr (#11368)
Browse files Browse the repository at this point in the history
* fix a bug in StabilizerState repr

* add a test to check repr does not throw an error

* add release notes

(cherry picked from commit 1b69780)
  • Loading branch information
ShellyGarion authored and mergify[bot] committed Dec 14, 2023
1 parent ef21b50 commit 8e516bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion qiskit/quantum_info/states/stabilizerstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
Fix a bug in the :class:`.StabilizerState` string representation.
6 changes: 6 additions & 0 deletions test/python/quantum_info/states/test_stabilizerstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 8e516bf

Please sign in to comment.