Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone-Bordoni committed Feb 14, 2024
1 parent 512e900 commit b38492a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/qibojit/tests/test_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,28 @@ def test_apply_csx(backend, nqubits, targets, dtype):
state = backend.apply_gate(gate, np.copy(state), nqubits)
backend.assert_allclose(state, target_state, atol=ATOL.get(dtype))

@pytest.mark.parametrize(
("nqubits", "targets"),
[
(2, [0, 1]),
(3, [0, 2]),
(4, [1, 3]),
(3, [1, 2]),
(4, [0, 2]),
(4, [2, 3]),
(5, [3, 4]),
(6, [1, 4]),
],
)
def test_apply_csxdg(backend, nqubits, targets, dtype):
tbackend = NumpyBackend()
state = random_statevector(2**nqubits, backend=tbackend).astype(dtype)
gate = gates.CSXDG(*targets)

set_precision(dtype, backend, tbackend)
target_state = tbackend.apply_gate(gate, np.copy(state), nqubits)
state = backend.apply_gate(gate, np.copy(state), nqubits)
backend.assert_allclose(state, target_state, atol=ATOL.get(dtype))

@pytest.mark.parametrize(
("nqubits", "targets"),
Expand Down

0 comments on commit b38492a

Please sign in to comment.