From 2bed40ebfac56a74700b60d43c706bdad0c8d90b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:57:49 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/qibolab/compilers/default.py | 1 + .../instruments/qblox/cluster_qcm_bb.py | 6 +- .../instruments/qblox/cluster_qrm_rf.py | 12 +-- src/qibolab/instruments/qblox/controller.py | 2 +- src/qibolab/instruments/qblox/sweeper.py | 9 +- src/qibolab/instruments/rfsoc/convert.py | 1 + src/qibolab/instruments/unrolling.py | 1 + src/qibolab/instruments/zhinst.py | 98 +++++++++---------- src/qibolab/pulses.py | 1 + src/qibolab/serialize.py | 1 + tests/test_instruments_qmsim.py | 1 + tests/test_platform.py | 1 + tests/test_pulses.py | 1 + tests/test_result.py | 1 + 14 files changed, 70 insertions(+), 66 deletions(-) diff --git a/src/qibolab/compilers/default.py b/src/qibolab/compilers/default.py index a9a8202c2..fb0b5e4f5 100644 --- a/src/qibolab/compilers/default.py +++ b/src/qibolab/compilers/default.py @@ -2,6 +2,7 @@ Uses I, Z, RZ, U3, CZ, and M as the set of native gates. """ + import math from qibolab.pulses import PulseSequence diff --git a/src/qibolab/instruments/qblox/cluster_qcm_bb.py b/src/qibolab/instruments/qblox/cluster_qcm_bb.py index a5e95a554..2101adebf 100644 --- a/src/qibolab/instruments/qblox/cluster_qcm_bb.py +++ b/src/qibolab/instruments/qblox/cluster_qcm_bb.py @@ -122,9 +122,9 @@ def __init__(self, name: str, address: str): self.channel_map: dict = {} self._device_num_output_ports = 2 self._device_num_sequencers: int - self._free_sequencers_numbers: list[ - int - ] = [] # TODO: we can create only list and put three flags: free, used, unused + self._free_sequencers_numbers: list[int] = ( + [] + ) # TODO: we can create only list and put three flags: free, used, unused self._used_sequencers_numbers: list[int] = [] self._unused_sequencers_numbers: list[int] = [] diff --git a/src/qibolab/instruments/qblox/cluster_qrm_rf.py b/src/qibolab/instruments/qblox/cluster_qrm_rf.py index 31c51e88d..4d0cb2d35 100644 --- a/src/qibolab/instruments/qblox/cluster_qrm_rf.py +++ b/src/qibolab/instruments/qblox/cluster_qrm_rf.py @@ -989,9 +989,9 @@ def acquire(self): if len(sequencer.pulses.ro_pulses) == 1: pulse = sequencer.pulses.ro_pulses[0] frequency = self.get_if(pulse) - acquisitions[pulse.qubit] = acquisitions[ - pulse.serial - ] = AveragedAcquisition(scope, duration, frequency) + acquisitions[pulse.qubit] = acquisitions[pulse.serial] = ( + AveragedAcquisition(scope, duration, frequency) + ) else: raise RuntimeError( "Software Demodulation only supports one acquisition per channel. " @@ -1001,9 +1001,9 @@ def acquire(self): results = self.device.get_acquisitions(sequencer.number) for pulse in sequencer.pulses.ro_pulses: bins = results[pulse.serial]["acquisition"]["bins"] - acquisitions[pulse.qubit] = acquisitions[ - pulse.serial - ] = DemodulatedAcquisition(bins, duration) + acquisitions[pulse.qubit] = acquisitions[pulse.serial] = ( + DemodulatedAcquisition(bins, duration) + ) # Provide Scope Data for verification (assuming memory reseet is being done) if len(sequencer.pulses.ro_pulses) == 1: diff --git a/src/qibolab/instruments/qblox/controller.py b/src/qibolab/instruments/qblox/controller.py index 3e024f6ff..d50c04b67 100644 --- a/src/qibolab/instruments/qblox/controller.py +++ b/src/qibolab/instruments/qblox/controller.py @@ -111,7 +111,7 @@ def _execute_pulse_sequence( sequence: PulseSequence, options: ExecutionParameters, sweepers: list() = [], # list(Sweeper) = [] - **kwargs + **kwargs, # nshots=None, # navgs=None, # relaxation_time=None, diff --git a/src/qibolab/instruments/qblox/sweeper.py b/src/qibolab/instruments/qblox/sweeper.py index 270c17c96..140922055 100644 --- a/src/qibolab/instruments/qblox/sweeper.py +++ b/src/qibolab/instruments/qblox/sweeper.py @@ -156,9 +156,7 @@ def __init__( ) ), QbloxSweeperType.relative_phase: (lambda v: True), - QbloxSweeperType.start: ( - lambda v: all((4 <= x and x < 2**16) for x in v) - ), + QbloxSweeperType.start: (lambda v: all((4 <= x and x < 2**16) for x in v)), QbloxSweeperType.duration: ( lambda v: all((0 <= x and x < 2**16) for x in v) ), @@ -187,10 +185,7 @@ def __init__( self._con_step = convert[type](self._abs_step) self._con_stop = (self._con_start + self._con_step * (self._n) + 1) % 2**32 self._con_values = np.array( - [ - (self._con_start + self._con_step * m) % 2**32 - for m in range(self._n + 1) - ] + [(self._con_start + self._con_step * m) % 2**32 for m in range(self._n + 1)] ) # log.info(f"Qblox sweeper converted values: {self._con_values}") diff --git a/src/qibolab/instruments/rfsoc/convert.py b/src/qibolab/instruments/rfsoc/convert.py index 7b87b3f67..39bdf3463 100644 --- a/src/qibolab/instruments/rfsoc/convert.py +++ b/src/qibolab/instruments/rfsoc/convert.py @@ -1,4 +1,5 @@ """Convert helper functions for rfsoc driver.""" + from dataclasses import asdict from functools import singledispatch diff --git a/src/qibolab/instruments/unrolling.py b/src/qibolab/instruments/unrolling.py index 832c6a0cf..2ae60824d 100644 --- a/src/qibolab/instruments/unrolling.py +++ b/src/qibolab/instruments/unrolling.py @@ -2,6 +2,7 @@ May be reused by different instruments. """ + from more_itertools import chunked diff --git a/src/qibolab/instruments/zhinst.py b/src/qibolab/instruments/zhinst.py index 9049ce883..60ba9d060 100644 --- a/src/qibolab/instruments/zhinst.py +++ b/src/qibolab/instruments/zhinst.py @@ -420,20 +420,20 @@ def register_readout_line(self, qubit, intermediate_frequency, options): self.signal_map[f"measure{q}"] = self.device_setup.logical_signal_groups[ f"q{q}" ].logical_signals["measure_line"] - self.calibration[ - f"/logical_signal_groups/q{q}/measure_line" - ] = lo.SignalCalibration( - oscillator=lo.Oscillator( - frequency=intermediate_frequency, - modulation_type=lo.ModulationType.SOFTWARE, - ), - local_oscillator=lo.Oscillator( - uid="lo_shfqa_m" + str(q), - frequency=int(qubit.readout.local_oscillator.frequency), - ), - range=qubit.readout.power_range, - port_delay=None, - delay_signal=0, + self.calibration[f"/logical_signal_groups/q{q}/measure_line"] = ( + lo.SignalCalibration( + oscillator=lo.Oscillator( + frequency=intermediate_frequency, + modulation_type=lo.ModulationType.SOFTWARE, + ), + local_oscillator=lo.Oscillator( + uid="lo_shfqa_m" + str(q), + frequency=int(qubit.readout.local_oscillator.frequency), + ), + range=qubit.readout.power_range, + port_delay=None, + delay_signal=0, + ) ) self.signal_map[f"acquire{q}"] = self.device_setup.logical_signal_groups[ @@ -454,13 +454,13 @@ def register_readout_line(self, qubit, intermediate_frequency, options): # To keep compatibility with angle and threshold discrimination (Remove when possible) threshold = qubit.threshold - self.calibration[ - f"/logical_signal_groups/q{q}/acquire_line" - ] = lo.SignalCalibration( - oscillator=oscillator, - range=qubit.feedback.power_range, - port_delay=self.time_of_flight * NANO_TO_SECONDS, - threshold=threshold, + self.calibration[f"/logical_signal_groups/q{q}/acquire_line"] = ( + lo.SignalCalibration( + oscillator=oscillator, + range=qubit.feedback.power_range, + port_delay=self.time_of_flight * NANO_TO_SECONDS, + threshold=threshold, + ) ) def register_drive_line(self, qubit, intermediate_frequency): @@ -469,20 +469,20 @@ def register_drive_line(self, qubit, intermediate_frequency): self.signal_map[f"drive{q}"] = self.device_setup.logical_signal_groups[ f"q{q}" ].logical_signals["drive_line"] - self.calibration[ - f"/logical_signal_groups/q{q}/drive_line" - ] = lo.SignalCalibration( - oscillator=lo.Oscillator( - frequency=intermediate_frequency, - modulation_type=lo.ModulationType.HARDWARE, - ), - local_oscillator=lo.Oscillator( - uid="lo_shfqc" + str(q), - frequency=int(qubit.drive.local_oscillator.frequency), - ), - range=qubit.drive.power_range, - port_delay=None, - delay_signal=0, + self.calibration[f"/logical_signal_groups/q{q}/drive_line"] = ( + lo.SignalCalibration( + oscillator=lo.Oscillator( + frequency=intermediate_frequency, + modulation_type=lo.ModulationType.HARDWARE, + ), + local_oscillator=lo.Oscillator( + uid="lo_shfqc" + str(q), + frequency=int(qubit.drive.local_oscillator.frequency), + ), + range=qubit.drive.power_range, + port_delay=None, + delay_signal=0, + ) ) def register_flux_line(self, qubit): @@ -491,13 +491,13 @@ def register_flux_line(self, qubit): self.signal_map[f"flux{q}"] = self.device_setup.logical_signal_groups[ f"q{q}" ].logical_signals["flux_line"] - self.calibration[ - f"/logical_signal_groups/q{q}/flux_line" - ] = lo.SignalCalibration( - range=qubit.flux.power_range, - port_delay=None, - delay_signal=0, - voltage_offset=qubit.flux.offset, + self.calibration[f"/logical_signal_groups/q{q}/flux_line"] = ( + lo.SignalCalibration( + range=qubit.flux.power_range, + port_delay=None, + delay_signal=0, + voltage_offset=qubit.flux.offset, + ) ) def register_couplerflux_line(self, coupler): @@ -506,13 +506,13 @@ def register_couplerflux_line(self, coupler): self.signal_map[f"couplerflux{c}"] = self.device_setup.logical_signal_groups[ f"qc{c}" ].logical_signals["flux_line"] - self.calibration[ - f"/logical_signal_groups/qc{c}/flux_line" - ] = lo.SignalCalibration( - range=coupler.flux.power_range, - port_delay=None, - delay_signal=0, - voltage_offset=coupler.flux.offset, + self.calibration[f"/logical_signal_groups/qc{c}/flux_line"] = ( + lo.SignalCalibration( + range=coupler.flux.power_range, + port_delay=None, + delay_signal=0, + voltage_offset=coupler.flux.offset, + ) ) def run_exp(self): diff --git a/src/qibolab/pulses.py b/src/qibolab/pulses.py index 0d04e992a..01f8797e9 100644 --- a/src/qibolab/pulses.py +++ b/src/qibolab/pulses.py @@ -1,4 +1,5 @@ """Pulse and PulseSequence classes.""" + import copy import re from abc import ABC, abstractmethod diff --git a/src/qibolab/serialize.py b/src/qibolab/serialize.py index d454786f8..43ea53ba0 100644 --- a/src/qibolab/serialize.py +++ b/src/qibolab/serialize.py @@ -4,6 +4,7 @@ repository is assumed here. See :ref:`Using runcards ` example for more details. """ + import json from dataclasses import asdict from pathlib import Path diff --git a/tests/test_instruments_qmsim.py b/tests/test_instruments_qmsim.py index 051746811..9668d8880 100644 --- a/tests/test_instruments_qmsim.py +++ b/tests/test_instruments_qmsim.py @@ -11,6 +11,7 @@ If an error is raised or a waveform is generated for the first time, a plot will also be created so that the user can check if the waveform looks as expected. """ + import os import h5py diff --git a/tests/test_platform.py b/tests/test_platform.py index 0dca4522b..5995df451 100644 --- a/tests/test_platform.py +++ b/tests/test_platform.py @@ -1,5 +1,6 @@ """Tests :class:`qibolab.platforms.multiqubit.MultiqubitPlatform` and :class:`qibolab.platforms.platform.DesignPlatform`.""" + import pathlib import pickle import warnings diff --git a/tests/test_pulses.py b/tests/test_pulses.py index 10e650b9c..8135b3c75 100644 --- a/tests/test_pulses.py +++ b/tests/test_pulses.py @@ -1,4 +1,5 @@ """Tests ``pulses.py``.""" + import os import pathlib diff --git a/tests/test_result.py b/tests/test_result.py index 70bb9c5d7..cff4c38a7 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -1,4 +1,5 @@ """Testing result.py.""" + import numpy as np import pytest