Skip to content

Commit

Permalink
Update test_IQM.py (#1826)
Browse files Browse the repository at this point in the history
Improvements enhance readability, robustness

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
  • Loading branch information
BalajiJBcs and schweitzpgi committed Jul 10, 2024
1 parent cdd74ea commit e5cb018
Showing 1 changed file with 4 additions and 6 deletions.
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

0 comments on commit e5cb018

Please sign in to comment.