Skip to content

Commit

Permalink
Passes black
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Quesada committed Apr 23, 2024
1 parent a03c145 commit f4aa6b4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions thewalrus/tests/test_internal_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1533,18 +1533,19 @@ def test_unknown_method_in_density_matrix_single_mode():
with pytest.raises(ValueError, match="Unknown method for density_matrix_single_mode"):
density_matrix_single_mode(cov, N, cutoff=cutoff, normalize=True, method="Coo coo ca choo")


def test_haf_blocked():
"""Tests that haf blocked is the sum of many hafnians"""
n = 6
B = np.random.rand(n,n)+ 1j*np.random.rand(n,n)
B = np.random.rand(n, n) + 1j * np.random.rand(n, n)
A = B + B.T
reps_list = [[i, 3-i,4] for i in range(4)]
reps_list = [[i, 3 - i, 4] for i in range(4)]
haf_sum = 0j
for reps in reps_list:
repreps = reps + reps
haf = hafnian(reduction(A, repreps))
haf_sum += haf / np.product(factorial(reps))
blocks = ((0,1),(2,))
repeats = (3,4)
haf_val = haf_blocked(A, blocks=blocks, repeats=repeats)/np.product(factorial(repeats))
blocks = ((0, 1), (2,))
repeats = (3, 4)
haf_val = haf_blocked(A, blocks=blocks, repeats=repeats) / np.product(factorial(repeats))
assert np.allclose(haf_sum, haf_val)

0 comments on commit f4aa6b4

Please sign in to comment.