diff --git a/thewalrus/tests/test_internal_modes.py b/thewalrus/tests/test_internal_modes.py index d9e96187..7653c57f 100644 --- a/thewalrus/tests/test_internal_modes.py +++ b/thewalrus/tests/test_internal_modes.py @@ -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)