Skip to content

Commit eac73e2

Browse files
Updating the documentation of pauli_string.py
1 parent c04594b commit eac73e2

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

mpqp/core/instruction/measurement/pauli_string.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Represents Pauli strings, which is linear combinations of
2-
:class:`PauliMonomial` with is a combination of :class:`PauliAtom`.
2+
:class:`PauliMonomial` which is a combination of :class:`PauliAtom`.
33
:class:`PauliString` objects can be added, subtracted, and multiplied by
44
scalars. They also support matrix multiplication with other :class:`PauliString`
55
objects.
@@ -48,7 +48,7 @@ def __init__(self, monomials: Optional[list["PauliStringMonomial"]] = None):
4848

4949
@property
5050
def monomials(self) -> list[PauliStringMonomial]:
51-
"""Get the monomials of the PauliString.
51+
"""Gets the monomials of the PauliString.
5252
5353
Returns:
5454
The list of monomials in the PauliString.
@@ -57,7 +57,7 @@ def monomials(self) -> list[PauliStringMonomial]:
5757

5858
@property
5959
def nb_qubits(self) -> int:
60-
"""Get the number of qubits associated with the PauliString.
60+
"""Gets the number of qubits associated with the PauliString.
6161
6262
Returns:
6363
The number of qubits associated with the PauliString.
@@ -139,11 +139,11 @@ def __eq__(self, other: object) -> bool:
139139
return self.to_dict() == other.to_dict()
140140

141141
def simplify(self, inplace: bool = False) -> PauliString:
142-
"""Simplify the PauliString by combining like terms and removing terms
142+
"""Simplifies the PauliString by combining like terms and removing terms
143143
with zero coefficients.
144144
145145
Args:
146-
inplace: If the simplify should change self.
146+
inplace: Indicates if ``simplify`` should update self.
147147
148148
Example:
149149
>>> ps = I @ I - 2 * I @ I + Z @ I - Z @ I
@@ -175,7 +175,7 @@ def simplify(self, inplace: bool = False) -> PauliString:
175175
return res
176176

177177
def to_matrix(self) -> Matrix:
178-
"""Convert the PauliString to a matrix representation.
178+
"""Converts the PauliString to a matrix representation.
179179
180180
Example:
181181
>>> ps = I + Z
@@ -195,18 +195,18 @@ def to_matrix(self) -> Matrix:
195195

196196
@classmethod
197197
def from_matrix(cls, matrix: Matrix) -> PauliString:
198-
"""Construct a PauliString from a matrix.
198+
"""Constructs a PauliString from a matrix.
199199
200200
Args:
201-
Matrix from which the PauliString is generated
201+
matrix: Matrix from which the PauliString is generated
202202
203203
Example:
204204
>>> ps = PauliString.from_matrix(np.array([[0, 1], [1, 2]]))
205205
>>> print(ps)
206206
(1+0j)*I + (1+0j)*X + (-1+0j)*Z
207207
208208
Returns:
209-
PauliString: form class PauliString.
209+
PauliString: Pauli string decomposition of the matrix in parameter.
210210
211211
Raises:
212212
ValueError: If the input matrix is not square or its dimensions are not a power of 2.
@@ -238,15 +238,15 @@ def from_matrix(cls, matrix: Matrix) -> PauliString:
238238
return pauli_list
239239

240240
def to_dict(self) -> dict[str, float]:
241-
"""Convert the PauliString object to a dictionary representation.
242-
243-
Returns:
244-
Dictionary representation of the PauliString object.
241+
"""Converts the PauliString object to a dictionary representation.
245242
246243
Example:
247244
>>> ps = 1 * I @ Z + 2 * I @ I
248245
>>> print(ps.to_dict())
249246
{'II': 2, 'IZ': 1}
247+
248+
Returns:
249+
Dictionary representation of the PauliString object.
250250
"""
251251
self = self.simplify()
252252
dict = {}
@@ -383,8 +383,8 @@ class PauliStringAtom(PauliStringMonomial):
383383
"""Represents a single Pauli operator acting on a qubit in a Pauli string.
384384
385385
Args:
386-
Label: The label representing the Pauli operator (e.g., 'I', 'X', 'Y', 'Z').
387-
Matrix: The matrix representation of the Pauli operator.
386+
label: The label representing the Pauli operator (e.g., 'I', 'X', 'Y', 'Z').
387+
matrix: The matrix representation of the Pauli operator.
388388
389389
Raises:
390390
AttributeError: new atoms cannot be created

0 commit comments

Comments
 (0)