diff --git a/src/qibolab/kernels.py b/src/qibolab/kernels.py index 480fe7841..654f97575 100644 --- a/src/qibolab/kernels.py +++ b/src/qibolab/kernels.py @@ -29,4 +29,6 @@ def dump(self, path: Path): The keys (QubitId) are serialized to strings and the values (numpy arrays) are kept as is. """ - np.savez(path, **{json.dumps(key): value for key, value in self.items()}) + np.savez( + path, **{json.dumps(qubit_id): value for qubit_id, value in self.items()} + ) diff --git a/src/qibolab/serialize.py b/src/qibolab/serialize.py index d4c971e1a..65cdc70a6 100644 --- a/src/qibolab/serialize.py +++ b/src/qibolab/serialize.py @@ -23,6 +23,8 @@ ) from qibolab.qubits import Qubit, QubitPair +KERNELS_FILE = "kernels.npz" + def load_runcard(path: Path) -> dict: """Load runcard YAML to a dictionary.""" @@ -51,7 +53,7 @@ def load_qubits( } if extras_folder is not None: - kernels = Kernels.load(path=extras_folder / "kernels.npz") + kernels = Kernels.load(path=extras_folder / KERNELS_FILE) for q in kernels: qubits[q].kernel = kernels[q] @@ -178,12 +180,12 @@ def dump_runcard(platform: Platform, path: Path): path (pathlib.Path): Path that the yaml file will be saved. """ - kernels = {} + kernels = Kernels() for qubit in platform.qubits.values(): if qubit.kernel is not None: - kernels[str(qubit.name)] = qubit.kernel + kernels[qubit.name] = qubit.kernel qubit.kernel = None - Kernels(kernels).dump(Path(__file__).parent / "dummy/kernels.npz") + Kernels(kernels).dump(Path(__file__).parent / "dummy" / KERNELS_FILE) settings = { "nqubits": platform.nqubits, diff --git a/tests/dummy_qrc/zurich.py b/tests/dummy_qrc/zurich.py index e1a6d8d32..1ff4fe654 100644 --- a/tests/dummy_qrc/zurich.py +++ b/tests/dummy_qrc/zurich.py @@ -171,8 +171,8 @@ def create(runcard_path=RUNCARD): channels[ch].local_oscillator = local_oscillators[lo] # create qubit objects - runcard = load_runcard(runcard_path, FOLDER) - qubits, couplers, pairs = load_qubits(runcard) + runcard = load_runcard(runcard_path) + qubits, couplers, pairs = load_qubits(runcard, FOLDER) settings = load_settings(runcard) # assign channels to qubits and sweetspots(operating points)