Skip to content

Commit

Permalink
refactor: Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Jan 9, 2024
1 parent 9d908a7 commit 33f4519
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/qibolab/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def remove_couplers(runcard):
return runcard


def load_dummy_runcard():
"""Loads the runcard YAML of the dummy platform."""
return load_runcard(pathlib.Path(__file__).parent / "dummy.yml")


def create_dummy(with_couplers: bool = True):
"""Create a dummy platform using the dummy instrument.
Expand All @@ -35,7 +40,7 @@ def create_dummy(with_couplers: bool = True):
twpa_pump.frequency = 1e9
twpa_pump.power = 10

runcard = load_runcard(pathlib.Path(__file__).parent / "dummy.yml")
runcard = load_dummy_runcard()
if not with_couplers:
runcard = remove_couplers(runcard)

Expand Down
8 changes: 4 additions & 4 deletions src/qibolab/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ class TwoQubitNatives:
def symmetric(self):
"""Check if the defined two-qubit gates are symmetric between target
and control qubits."""
for fld in fields(self):
if not fld.metadata["symmetric"] and getattr(self, fld.name) is not None:
return False
return True
return all(
fld.metadata["symmetric"] or getattr(self, fld.name) is None
for fld in fields(self)
)

@classmethod
def from_dict(cls, qubits, couplers, native_gates):
Expand Down
7 changes: 3 additions & 4 deletions tests/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from qibolab import create_platform
from qibolab.backends import QibolabBackend
from qibolab.dummy import load_dummy_runcard
from qibolab.execution_parameters import ExecutionParameters
from qibolab.instruments.qblox.controller import QbloxController
from qibolab.instruments.rfsoc.driver import RFSoC
Expand Down Expand Up @@ -64,14 +65,12 @@ def test_dump_runcard(platform):
dump_runcard(platform, path)
final_runcard = load_runcard(path)
if platform.name == "dummy" or platform.name == "dummy_couplers":
target_path = (
pathlib.Path(__file__).parent.parent / "src" / "qibolab" / "dummy.yml"
)
target_runcard = load_dummy_runcard()
else:
target_path = (
pathlib.Path(__file__).parent / "dummy_qrc" / f"{platform.name}.yml"
)
target_runcard = load_runcard(target_path)
target_runcard = load_runcard(target_path)
# for the characterization section the dumped runcard may contain
# some default ``Qubit`` parameters
target_char = target_runcard.pop("characterization")["single_qubit"]
Expand Down

0 comments on commit 33f4519

Please sign in to comment.