Skip to content

Commit

Permalink
Removed timing infrastructure from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinitha Balachandran committed Dec 13, 2023
1 parent b779227 commit c593965
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions tests/test_qasm_quimb_backend.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import copy
import os
from timeit import default_timer as timer

import config
import numpy as np
import pytest
Expand All @@ -18,18 +16,10 @@ def create_init_state(nqubits):

def qibo_qft(nqubits, init_state, swaps):
circ_qibo = QFT(nqubits, swaps)
state_vec = (circ_qibo(init_state)).state(numpy=True)
state_vec = circ_qibo(init_state).state(numpy=True)
return circ_qibo, state_vec


def time(func):
start = timer()
res = func()
end = timer()
time = end - start
return time, res


@pytest.mark.parametrize("nqubits, tolerance, is_mps",
[(1, 1e-6, True), (2, 1e-6, False), (5, 1e-3, True), (10, 1e-3, False)])
def test_eval(nqubits: int, tolerance: float, is_mps: bool):
Expand All @@ -45,19 +35,20 @@ def test_eval(nqubits: int, tolerance: float, is_mps: bool):
# Test qibo
qibo.set_backend(backend=config.qibo.backend,
platform=config.qibo.platform)
qibo_time, (qibo_circ, result_sv) = time(
lambda: qibo_qft(nqubits, init_state, swaps=True)
)
#qibo_time, (qibo_circ, result_sv) = time(
#lambda: qibo_qft(nqubits, init_state, swaps=True)
#)
qibo_circ, result_sv= qibo_qft(nqubits, init_state, swaps=True)


# Convert to qasm for other backends
qasm_circ = qibo_circ.to_qasm()

# Test quimb
quimb_time, result_tn = time(
lambda: qibotn.quimb.eval(
result_tn = qibotn.quimb.eval(
qasm_circ, init_state_tn, is_mps, backend=config.quimb.backend
)
)


assert np.allclose(result_sv, result_tn,
atol=tolerance), "Resulting dense vectors do not match"

0 comments on commit c593965

Please sign in to comment.