@@ -25,7 +25,7 @@ class PauliString:
25
25
monomials : List of Pauli monomials.
26
26
27
27
Example:
28
- >>> I@ Z + 2*Y@ I + X@ Z
28
+ >>> I @ Z + 2 * Y @ I + X @ Z
29
29
1*I@Z + 2*Y@I + 1*X@Z
30
30
"""
31
31
@@ -118,7 +118,7 @@ def __itruediv__(self, other: FixedReal) -> "PauliString":
118
118
return self
119
119
120
120
def __truediv__ (self , other : FixedReal ) -> "PauliString" :
121
- return self * (1 / other ) # pyright: ignore[reportOperatorIssue]
121
+ return self * (1 / other ) # pyright: ignore[reportOperatorIssue]
122
122
123
123
def __imatmul__ (self , other : "PauliString" ) -> "PauliString" :
124
124
self ._monomials = [
@@ -140,7 +140,7 @@ def simplify(self) -> PauliString:
140
140
"""Simplify the PauliString by combining like terms and removing terms with zero coefficients.
141
141
142
142
Example:
143
- >>> ps = I@ I - 2* I@ I + Z@ I - Z@ I
143
+ >>> ps = I @ I - 2 * I @ I + Z @ I - Z @ I
144
144
>>> simplified_ps = ps.simplify()
145
145
>>> print(simplified_ps)
146
146
-1*I@I
@@ -426,7 +426,9 @@ def __repr__(self):
426
426
return str (self )
427
427
428
428
def __truediv__ (self , other : FixedReal ) -> PauliStringMonomial :
429
- return PauliStringMonomial (1 / other , [self ]) # pyright: ignore[reportArgumentType]
429
+ return PauliStringMonomial (
430
+ 1 / other , [self ]
431
+ ) # pyright: ignore[reportArgumentType]
430
432
431
433
def __imul__ (self , other : FixedReal ) -> PauliStringMonomial :
432
434
return self * other
@@ -467,27 +469,24 @@ def __hash__(self):
467
469
_allow_atom_creation = True
468
470
469
471
I = PauliStringAtom ("I" , np .eye (2 , dtype = np .complex64 ))
470
- """Pauli-I atom representing the identity operator in a Pauli monomial or string.
472
+ r """Pauli-I atom representing the identity operator in a Pauli monomial or string.
471
473
Matrix representation:
472
- [1 0]
473
- [0 1]
474
+ `\begin{pmatrix}1&0\\0&1\end{pmatrix}`
474
475
"""
475
476
X = PauliStringAtom ("X" , 1 - np .eye (2 , dtype = np .complex64 ))
476
- """Pauli-X atom representing the X operator in a Pauli monomial or string.
477
+ r """Pauli-X atom representing the X operator in a Pauli monomial or string.
477
478
Matrix representation:
478
- [0 1]
479
- [1 0]
479
+ `\begin{pmatrix}0&1\\1&0\end{pmatrix}`
480
+
480
481
"""
481
482
Y = PauliStringAtom ("Y" , np .fliplr (np .diag ([1j , - 1j ])))
482
- """Pauli-Y atom representing the Y operator in a Pauli monomial or string.
483
+ r """Pauli-Y atom representing the Y operator in a Pauli monomial or string.
483
484
Matrix representation:
484
- [0 -i]
485
- [i 0]
485
+ `\begin{pmatrix}0&-i\\i&0\end{pmatrix}`
486
486
"""
487
487
Z = PauliStringAtom ("Z" , np .diag ([1 , - 1 ]))
488
- """Pauli-Z atom representing the Z operator in a Pauli monomial or string.
488
+ r """Pauli-Z atom representing the Z operator in a Pauli monomial or string.
489
489
Matrix representation:
490
- [1 0]
491
- [0 -1]
490
+ `\begin{pmatrix}1&0\\0&-1\end{pmatrix}`
492
491
"""
493
492
_allow_atom_creation = False
0 commit comments