Skip to content

Commit

Permalink
remove for loops in fswap test
Browse files Browse the repository at this point in the history
  • Loading branch information
haimeng-zhang committed Jul 25, 2024
1 parent 7a4c4c3 commit 36b209f
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions tests/python/gates/basic_gates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,24 +607,23 @@ def test_apply_fswap_gate_matrix_spinful(norb: int, spin: ffsim.Spin):
phase_00 = 1
phase_11 = -1

for _ in range(3):
for i, j in itertools.combinations(range(norb), 2):
for target_orbs in [(i, j), (j, i)]:
assert_has_two_orbital_matrix(
lambda vec, norb, nelec: ffsim.apply_fswap_gate(
vec,
target_orbs=target_orbs,
norb=norb,
nelec=nelec,
spin=spin,
),
for i, j in itertools.combinations(range(norb), 2):
for target_orbs in [(i, j), (j, i)]:
assert_has_two_orbital_matrix(
lambda vec, norb, nelec: ffsim.apply_fswap_gate(
vec,
target_orbs=target_orbs,
mat=mat01,
phase_00=phase_00,
phase_11=phase_11,
norb=norb,
nelec=nelec,
spin=spin,
)
),
target_orbs=target_orbs,
mat=mat01,
phase_00=phase_00,
phase_11=phase_11,
norb=norb,
spin=spin,
)


@pytest.mark.parametrize("norb", range(4))
Expand All @@ -637,19 +636,18 @@ def test_apply_fswap_gate_matrix_spinless(norb: int):
phase_00 = 1
phase_11 = -1

for _ in range(3):
for i, j in itertools.combinations(range(norb), 2):
for target_orbs in [(i, j), (j, i)]:
assert_has_two_orbital_matrix_spinless(
lambda vec, norb, nelec: ffsim.apply_fswap_gate(
vec,
target_orbs=target_orbs,
norb=norb,
nelec=nelec,
),
for i, j in itertools.combinations(range(norb), 2):
for target_orbs in [(i, j), (j, i)]:
assert_has_two_orbital_matrix_spinless(
lambda vec, norb, nelec: ffsim.apply_fswap_gate(
vec,
target_orbs=target_orbs,
mat=mat01,
phase_00=phase_00,
phase_11=phase_11,
norb=norb,
)
nelec=nelec,
),
target_orbs=target_orbs,
mat=mat01,
phase_00=phase_00,
phase_11=phase_11,
norb=norb,
)

0 comments on commit 36b209f

Please sign in to comment.