Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test_IQM.py #1826

Merged
merged 5 commits into from
Jul 10, 2024
Merged
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
10 changes: 4 additions & 6 deletions python/tests/backends/test_IQM.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import pytest

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

try:
from utils.mock_qpu.iqm import startServer
from utils.mock_qpu.iqm.mock_iqm_cortex_cli import write_a_mock_tokens_file
Expand All @@ -34,8 +35,8 @@ def assert_close(want, got, tolerance=1.0e-5) -> bool:
@pytest.fixture(scope="session", autouse=True)
def startUpMockServer():
# Write a fake access tokens file
tmp_tokens_file = tempfile.NamedTemporaryFile(delete=False)
write_a_mock_tokens_file(tmp_tokens_file.name)
with tempfile.NamedTemporaryFile(delete=False) as tmp_tokens_file:
write_a_mock_tokens_file(tmp_tokens_file.name)

# Launch the Mock Server
p = Process(target=startServer, args=(port,))
Expand All @@ -44,8 +45,7 @@ def startUpMockServer():

# Set the targeted QPU
os.environ["IQM_TOKENS_FILE"] = tmp_tokens_file.name
kwargs = dict()
kwargs["qpu-architecture"] = "Apollo"
kwargs = {"qpu-architecture": "Apollo"}
# If we're in a git repo, test that we can provide a filename with spaces.
# If we are not in a git repo, then simply test without overriding
# mapping_file. (Testing a mapping_file with spaces is done elsewhere, and
Expand Down Expand Up @@ -87,9 +87,7 @@ def test_iqm_ghz():
assert assert_close(counts["11"], shots / 2, 2)

future = cudaq.sample_async(kernel, shots_count=shots)

futureAsString = str(future)

futureReadIn = cudaq.AsyncSampleResult(futureAsString)
counts = futureReadIn.get()
assert assert_close(counts["00"], shots / 2, 2)
Expand Down
Loading