Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/tests/backends/emulateInfleqtion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@


@pytest.fixture(scope="session", autouse=True)
def do_something():
def setup_test_environment():
cudaq.__clearKernelRegistries()
cudaq.set_target("infleqtion", emulate=True)
yield "Running the tests."
cudaq.__clearKernelRegistries()
cudaq.reset_target()


Expand Down
8 changes: 4 additions & 4 deletions python/tests/backends/test_IQM.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import os
import shutil
import tempfile
from typing import List
from multiprocessing import Process
import numpy as np
from network_utils import check_server_connection
from typing import List

import cudaq
from cudaq import spin
import numpy as np
import pytest
from cudaq import spin
from network_utils import check_server_connection

iqm_client = pytest.importorskip("iqm.iqm_client")

Expand Down
11 changes: 7 additions & 4 deletions python/tests/backends/test_Infleqtion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import cudaq, pytest, os
from cudaq import spin
import os

import cudaq
import numpy as np
import pytest
from cudaq import spin

## NOTE: Comment the following line which skips these tests in order to run in
# local dev environment after setting the API key
Expand All @@ -17,10 +20,10 @@


@pytest.fixture(scope="session", autouse=True)
def do_something():
def setup_test_environment():
cudaq.__clearKernelRegistries()
cudaq.set_target("infleqtion")
yield "Running the tests."
cudaq.__clearKernelRegistries()
cudaq.reset_target()


Expand Down
12 changes: 8 additions & 4 deletions python/tests/backends/test_IonQ.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import cudaq, pytest, os
from cudaq import spin
import numpy as np
from typing import List
import os
from multiprocessing import Process
from typing import List

import cudaq
import numpy as np
import pytest
from cudaq import spin
from network_utils import check_server_connection

try:
from utils.mock_qpu.ionq import startServer
except:
Expand Down
9 changes: 5 additions & 4 deletions python/tests/backends/test_Ionq_LocalEmulation_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import cudaq
import cudaq.kernels
from cudaq import spin
import pytest
import os
from typing import List

import cudaq
import cudaq.kernels
import numpy as np
import pytest
from cudaq import spin


def assert_close(want, got, tolerance=1.0e-1) -> bool:
Expand Down
8 changes: 4 additions & 4 deletions python/tests/backends/test_OQC.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
# ============================================================================ #

import os
from typing import List
import pytest
from multiprocessing import Process
from network_utils import check_server_connection
from typing import List

import cudaq
from cudaq import spin
import numpy as np
import pytest
from cudaq import spin
from network_utils import check_server_connection

try:
from utils.mock_qpu.oqc import startServer
Expand Down
5 changes: 3 additions & 2 deletions python/tests/backends/test_Pasqal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import cudaq
import json
import os

import cudaq
import pytest

skipIfPasqalNotInstalled = pytest.mark.skipif(
Expand All @@ -17,7 +18,7 @@


@pytest.fixture(scope="session", autouse=True)
def do_something():
def setup_test_environment():
# NOTE: Credentials can be set with environment variables
cudaq.set_target("pasqal")
yield "Running the tests."
Expand Down
2 changes: 1 addition & 1 deletion python/tests/backends/test_QCI.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from multiprocessing import Process

import cudaq
from cudaq import spin
import pytest
from cudaq import spin
from network_utils import check_server_connection

try:
Expand Down
11 changes: 6 additions & 5 deletions python/tests/backends/test_QuEra.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import cudaq
from cudaq.operators import RydbergHamiltonian, ScalarOperator
from cudaq.dynamics import Schedule
import json
import numpy as np
import os

import cudaq
import numpy as np
import pytest
from cudaq.dynamics import Schedule
from cudaq.operators import RydbergHamiltonian, ScalarOperator


@pytest.fixture(scope="session", autouse=True)
def do_something():
def setup_test_environment():
cudaq.set_target("quera")
yield "Running the tests."
cudaq.reset_target()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import os
from typing import List

import cudaq
import numpy as np
import pytest
import os
from cudaq import spin
import numpy as np
from typing import List


def assert_close(got) -> bool:
Expand Down
10 changes: 6 additions & 4 deletions python/tests/backends/test_Quantinuum_LocalEmulation_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import os
from typing import List

import cudaq
import numpy as np
import pytest
import os
from cudaq import spin
import numpy as np
from typing import List


def requires_openfermion():
open_fermion_found = True
try:
import openfermion, openfermionpyscf
import openfermion
import openfermionpyscf
except:
open_fermion_found = False
return pytest.mark.skipif(not open_fermion_found,
Expand Down
10 changes: 7 additions & 3 deletions python/tests/backends/test_Quantinuum_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import cudaq, pytest, os
import numpy as np
import os
from multiprocessing import Process
from typing import List

import cudaq
import numpy as np
import pytest
from cudaq import spin
from multiprocessing import Process
from network_utils import check_server_connection

try:
from utils.mock_qpu.quantinuum import startServer
except:
Expand Down
10 changes: 7 additions & 3 deletions python/tests/backends/test_Quantinuum_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import cudaq, pytest, os
import numpy as np
from cudaq import spin
import os
from multiprocessing import Process
from typing import List

import cudaq
import numpy as np
import pytest
from cudaq import spin
from network_utils import check_server_connection

try:
from utils.mock_qpu.quantinuum import startServer
except:
Expand Down
5 changes: 3 additions & 2 deletions python/tests/backends/test_Quantum_Machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import cudaq
import os
import pytest
from multiprocessing import Process

import cudaq
import pytest
from network_utils import check_server_connection

try:
Expand Down
9 changes: 5 additions & 4 deletions python/tests/backends/test_braket.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import os

import cudaq
import numpy as np
import pytest
import os
from cudaq import spin
import numpy as np

## NOTE: Comment the following line which skips these tests in order to run in
# local dev environment after setting AWS credentials.
Expand All @@ -19,10 +20,10 @@


@pytest.fixture(scope="session", autouse=True)
def do_something():
def setup_test_environment():
cudaq.__clearKernelRegistries()
cudaq.set_target("braket")
yield "Running the tests."
cudaq.__clearKernelRegistries()
cudaq.reset_target()


Expand Down
3 changes: 1 addition & 2 deletions python/tests/backends/test_resource_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
@pytest.fixture(scope="session", autouse=True)
def clean():
cudaq.reset_target()

yield "Running the tests."

cudaq.__clearKernelRegistries()
cudaq.reset_target()


Expand Down
2 changes: 1 addition & 1 deletion python/tests/backends/test_stim.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

import os
from typing import List
import pytest

import cudaq
import numpy as np
import pytest


@pytest.fixture(scope="session", autouse=True)
Expand Down
11 changes: 8 additions & 3 deletions python/tests/builder/test_NoiseModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
# ============================================================================ #

import os
import random

import pytest
import cudaq
import numpy as np
import pytest

import cudaq
import random

@pytest.fixture(autouse=True)
def setup_test_environment():
cudaq.__clearKernelRegistries()
yield


@pytest.mark.parametrize('target', ['density-matrix-cpu', 'stim'])
Expand Down
11 changes: 8 additions & 3 deletions python/tests/builder/test_cupy_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@
# ============================================================================ #
import os

import pytest
import numpy as np

import cudaq
import numpy as np
import pytest

cp = pytest.importorskip('cupy')

if cudaq.num_available_gpus() == 0:
pytest.skip("Skipping GPU tests", allow_module_level=True)


@pytest.fixture(autouse=True)
def setup_test_environment():
cudaq.__clearKernelRegistries()
yield


def assert_close(want, got, tolerance=1.e-5) -> bool:
return abs(want - got) < tolerance

Expand Down
12 changes: 9 additions & 3 deletions python/tests/builder/test_kernel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@
# This file is responsible for testing the accuracy of gates within
# the kernel builder.

import pytest
import random
import numpy as np
import os
import random
from typing import List

import cudaq
import numpy as np
import pytest
from cudaq import spin


@pytest.fixture(autouse=True)
def setup_test_environment():
cudaq.__clearKernelRegistries()
yield


def test_sdg_0_state():
"""Tests the adjoint S-gate on a qubit starting in the 0-state."""
kernel = cudaq.make_kernel()
Expand Down
Loading
Loading