Skip to content

Commit

Permalink
fix: Approximate fix of few pylint errors
Browse files Browse the repository at this point in the history
Due to the instruments transition to pydantic
  • Loading branch information
alecandido committed Aug 22, 2024
1 parent e365798 commit 83e9fac
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
19 changes: 8 additions & 11 deletions src/qibolab/instruments/bluefors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import socket

import yaml
from pydantic import Field
from qibo.config import log

from qibolab.instruments.abstract import Instrument
Expand All @@ -19,17 +20,13 @@ class TemperatureController(Instrument):
print(temperature_value)
"""

def __init__(self, name: str, address: str, port: int = 8888):
"""Creation of the controller object.
Args:
name (str): name of the instrument.
address (str): IP address of the board sending cryo temperature data.
port (int): port of the board sending cryo temperature data.
"""
super().__init__(name, address)
self.port = port
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
address: str
"""IP address of the board sending cryo temperature data."""
port: int = 8888
"""Port of the board sending cryo temperature data."""
client_socket: socket.socket = Field(
default_factory=lambda: socket.socket(socket.AF_INET, socket.SOCK_STREAM)
)

def connect(self):
"""Connect to the socket."""
Expand Down
8 changes: 6 additions & 2 deletions src/qibolab/instruments/erasynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from qcodes_contrib_drivers.drivers.ERAInstruments import ERASynthPlusPlus
from qibo.config import log

from qibolab.instruments.oscillator import LocalOscillator
from qibolab.instruments.oscillator import LocalOscillator, LocalOscillatorSettings

RECONNECTION_ATTEMPTS = 10
"""Number of times to attempt sending requests to the web server in case of
Expand Down Expand Up @@ -128,7 +128,11 @@ class ERA(LocalOscillator):
"""

def __init__(self, name, address, ethernet=True, ref_osc_source=None):
super().__init__(name, address, ref_osc_source)
super().__init__(
name=name,
address=address,
settings=LocalOscillatorSettings(ref_osc_source=ref_osc_source),
)
self.ethernet = ethernet

def create(self):
Expand Down
5 changes: 3 additions & 2 deletions src/qibolab/instruments/icarusqfpga.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
AveragingMode,
ExecutionParameters,
)
from qibolab.identifier import QubitId
from qibolab.instruments.abstract import Controller
from qibolab.pulses import Pulse
from qibolab.qubits import Qubit, QubitId
from qibolab.qubits import Qubit
from qibolab.result import average, average_iq, collect
from qibolab.sequence import PulseSequence
from qibolab.sweeper import Parameter, Sweeper, SweeperType
Expand All @@ -41,7 +42,7 @@ def __init__(
delay_samples_offset_dac: int = 0,
delay_samples_offset_adc: int = 0,
):
super().__init__(name, address)
super().__init__(name=name, address=address, bounds="icarusq/bounds")

self.channel_delay_offset_dac = delay_samples_offset_dac
self.channel_delay_offset_adc = delay_samples_offset_adc
Expand Down
2 changes: 1 addition & 1 deletion src/qibolab/instruments/qblox/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ClusterModule(Instrument):
"""

def __init__(self, name: str, address: str):
super().__init__(name, address)
super().__init__(name=name, address=address)
DEFAULT_SEQUENCERS_VALUES = {
"cont_mode_en_awg_path0": False,
"cont_mode_en_awg_path1": False,
Expand Down
15 changes: 6 additions & 9 deletions src/qibolab/instruments/qm/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import tempfile
import warnings
from collections import defaultdict
from dataclasses import asdict, dataclass, field
from dataclasses import asdict, dataclass
from pathlib import Path
from typing import Optional

from pydantic import Field
from qm import QuantumMachinesManager, SimulationConfig, generate_qua_script
from qm.octave import QmOctaveConfig
from qm.simulate.credentials import create_credentials
Expand Down Expand Up @@ -112,7 +113,6 @@ def fetch_results(result, acquisitions):
}


@dataclass
class QmController(Controller):
""":class:`qibolab.instruments.abstract.Controller` object for controlling
a Quantum Machines cluster.
Expand All @@ -138,7 +138,7 @@ class QmController(Controller):
"""Dictionary containing the
:class:`qibolab.instruments.qm.controller.Octave` instruments being
used."""
channels: dict[str, QmChannel]
channels: dict[ChannelId, QmChannel]

bounds: str = "qm/bounds"
"""Maximum bounds used for batching in sequence unrolling."""
Expand All @@ -165,7 +165,7 @@ class QmController(Controller):
is_connected: bool = False
"""Boolean that shows whether we are connected to the QM manager."""

config: QmConfig = field(default_factory=QmConfig)
config: QmConfig = Field(default_factory=QmConfig)
"""Configuration dictionary required for pulse execution on the OPXs."""

simulation_duration: Optional[int] = None
Expand All @@ -184,12 +184,9 @@ class QmController(Controller):
Default is ``False``.
"""

def __post_init__(self):
super().__init__(self.name, self.address)
def model_post_init(self, __context):
# convert ``channels`` from list to dict
self.channels = {
str(channel.logical_channel.name): channel for channel in self.channels
}
self.channels = {channel.logical_channel: channel for channel in self.channels}

if self.simulation_duration is not None:
# convert simulation duration from ns to clock cycles
Expand Down
2 changes: 1 addition & 1 deletion src/qibolab/instruments/rfsoc/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, name: str, address: str, port: int, sampling_rate: float = 1.
address (str): IP and port of the server (ex. 192.168.0.10)
port (int): Port of the server (ex.6000)
"""
super().__init__(name, address=address)
super().__init__(name=name, address=address)
self.host = address
self.port = port
self.cfg = rfsoc.Config()
Expand Down
2 changes: 1 addition & 1 deletion src/qibolab/instruments/zhinst/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
time_of_flight=0.0,
smearing=0.0,
):
super().__init__(name, None)
super().__init__(name=name, address=None)

self.signal_map = {}
"Signals to lines mapping"
Expand Down

0 comments on commit 83e9fac

Please sign in to comment.