Skip to content

Commit

Permalink
fix: Fix task_options tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-pasquale committed Mar 21, 2024
1 parent 1148b55 commit c3439ee
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions tests/test_task_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
ReadoutMitigationMatrixParameters,
)

PLATFORM = create_platform("dummy")
QUBITS = list(PLATFORM.qubits)
TARGETS = [0, 1, 2]
DUMMY_CARD = {
"backend": "numpy",
"targets": QUBITS,
"targets": TARGETS,
"actions": [
{
"id": "standard rb",
"priority": 0,
"operation": "standard_rb",
"parameters": {
"depths": [1, 5, 10],
Expand All @@ -37,8 +34,9 @@
}


def modify_card(card, targets=None, update=None):
def modify_card(card, targets=None, update=None, backend="qibolab"):
"""Modify runcard to change local targets or update."""
card["backend"] = backend
for action in card["actions"]:
if targets is not None:
action["targets"] = targets
Expand All @@ -47,43 +45,42 @@ def modify_card(card, targets=None, update=None):
return card


@pytest.mark.parametrize("platform", [None, PLATFORM])
@pytest.mark.parametrize("backend", ["numpy", "qibolab"])
@pytest.mark.parametrize("local_targets", [None, [0, 1]])
def test_targets_argument(platform, local_targets, tmp_path):
def test_targets_argument(backend, local_targets, tmp_path):
"""Test possible qubits combinations between global and local."""
runcard = Runcard.load(modify_card(DUMMY_CARD, targets=local_targets))
runcard = Runcard.load(
modify_card(DUMMY_CARD, targets=local_targets, backend=backend)
)
task = Task(runcard.actions[0])

completed = task.run(
max_iterations=1,
platform=platform,
targets=list(QUBITS),
platform=runcard.platform,
targets=TARGETS,
mode=ExecutionMode.acquire,
folder=tmp_path,
)
if local_targets:
assert completed.task.targets == local_targets
else:
assert completed.task.targets == list(QUBITS)
assert runcard.targets == list(QUBITS)
assert completed.task.targets == TARGETS
assert runcard.targets == TARGETS


UPDATE_CARD = {
"targets": QUBITS,
"targets": TARGETS,
"actions": [
{
"id": "readout frequency",
"priority": 0,
"operation": "resonator_frequency",
"main": "classification",
"parameters": {
"freq_width": 10_000_000,
"freq_step": 100_000,
},
},
{
"id": "classification",
"priority": 0,
"operation": "single_shot_classification",
"parameters": {"nshots": 100},
},
Expand All @@ -101,7 +98,7 @@ def test_update_argument(global_update, local_update, tmp_path):
Runcard.load(NEW_CARD),
tmp_path,
platform,
platform.qubits,
list(platform.qubits),
update=global_update,
)

Expand Down

0 comments on commit c3439ee

Please sign in to comment.