Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastián Duque Mesa <675763+sduquemesa@users.noreply.github.com>
  • Loading branch information
nquesada and sduquemesa authored Nov 9, 2023
1 parent 18e6fe3 commit bcb6398
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
25 changes: 12 additions & 13 deletions thewalrus/_montrealer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@

@numba.jit(nopython=True, cache=True)
def dec2bin(num, n): # pragma: no cover
"""Helper function to generate convert an integer into an element of the powerset of n objects.
"""Helper function to convert an integer into an element of the power-set of ``n`` objects.
Args:
num (int): label to convert.
n (int): number of elements in the set.
num (int): label to convert
n (int): number of elements in the set
Returns:
(array): array containing the labels of the elements to be selected.
(array): array containing the labels of the elements to be selected
"""
digits = np.zeros((n), dtype=type(num))
nn = num
Expand All @@ -39,11 +38,10 @@ def montrealer(Sigma): # pragma: no cover
"""Calculates the loop-montrealer of the zero-displacement Gaussian state with the given complex covariance matrix.
Args:
A (array): adjacency matrix of the Gaussian state.
A (array): adjacency matrix of the Gaussian state
Returns:
(np.complex128): the montrealer of A.
(np.complex128): the montrealer of A
"""
n = len(Sigma) // 2
tot_num = 2**n
Expand All @@ -60,7 +58,8 @@ def montrealer(Sigma): # pragma: no cover

@numba.jit(nopython=True)
def power_loop(Sigma, zeta, n): # pragma: no cover
"""Auxiliary function to calculate the product np.conj(zeta) @ Sigma^{n-1} @ zeta.
"""Auxiliary function to calculate the product ``np.conj(zeta) @ Sigma^{n-1} @ zeta``.
Args:
Sigma (array): square complex matrix
zeta (array): complex vector
Expand All @@ -80,11 +79,11 @@ def lmontrealer(Sigma, zeta): # pragma: no cover
"""Calculates the loop-montrealer of the displaced Gaussian state with the given complex covariance matrix and vector of displacements.
Args:
Sigma (array): complex Glauber covariance matrix of the Gaussian state.
Sigma (array): complex Glauber covariance matrix of the Gaussian state
zeta (array): vector of displacements
Returns:
(np.complex128): the montrealer of A.
(np.complex128): the montrealer of ``A``
"""
n = len(Sigma) // 2
tot_num = 2**n
Expand All @@ -106,7 +105,7 @@ def lmtl(A, zeta):
"""Returns the montrealer of an NxN matrix and an N-length vector.
Args:
A (array): an NxN array of even dimensions.
A (array): an NxN array of even dimensions
zeta (array): an N-length vector of even dimensions
Returns:
Expand All @@ -126,7 +125,7 @@ def mtl(A):
A (array): an NxN array of even dimensions.
Returns:
np.float64 or np.complex128: the montrealer of matrix A
np.float64 or np.complex128: the montrealer of matrix ``A``
"""

tor_input_checks(A)
Expand Down
7 changes: 4 additions & 3 deletions thewalrus/_torontonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@


def tor_input_checks(A, loops=None):
"""Checks the correcteness of the inputs for the torontonian/montrealer.
"""Checks the correctness of the inputs for the torontonian/montrealer.
Args:
A (array): an NxN array of even dimensions.
loops (array): optinal argument, an N-length vector of even dimensions.
A (array): an NxN array of even dimensions
loops (array): optional argument, an N-length vector of even dimensions
"""
if not isinstance(A, np.ndarray):
raise TypeError("Input matrix must be a NumPy array.")
Expand Down
10 changes: 5 additions & 5 deletions thewalrus/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def mapper(x, objects):
"""Helper function to turn a permutation and bistring into an element of rpmp.
Args:
x (tuple): tuple containing a permutation and a bistring.
x (tuple): tuple containing a permutation and a bistring
objects (list): list objects to permute
Returns:
Expand All @@ -313,10 +313,10 @@ def bitstrings(n):
"""Returns the bistrings from 0 to n/2
Args:
n (int) : Twice the highest bitstring value.
n (int): Twice the highest bitstring value.
Returns:
(iterator) : An iterable of all bistrings.
(iterator): An iterable of all bistrings.
"""
for binary in map("".join, product("01", repeat=n - 1)):
yield "0" + binary
Expand All @@ -329,7 +329,7 @@ def rpmp(s):
s (tuple): tuple of labels to be used
Returns:
generator: the set of restricted perfect matching permutations of the tuple s
generator: the set of restricted perfect matching permutations of the tuple ``s``
"""
m = len(s) // 2

Expand Down Expand Up @@ -386,7 +386,7 @@ def mtl(A, loop=False):
loop (boolean): if set to ``True``, the loop montrealer is returned
Returns:
np.float64, np.complex128 or sympy.core.add.Add: the Montrealer of matrix A.
np.float64, np.complex128 or sympy.core.add.Add: the Montrealer of matrix ``A``.
"""
n, _ = A.shape
net_sum = 0
Expand Down

0 comments on commit bcb6398

Please sign in to comment.