Updated pyproject.toml with dependencies and linter settings.

This commit is contained in:
jupfi 2024-04-17 20:43:33 +02:00
parent 98e83ad54c
commit 946d6d2eb4
4 changed files with 48 additions and 18 deletions

View file

@ -25,8 +25,40 @@ dependencies = [
"pyqt6", "pyqt6",
"nqrduck", "nqrduck",
"pyserial", "pyserial",
"scipy",
] ]
[project.entry-points."nqrduck"] [project.entry-points."nqrduck"]
"nqrduck-autotm" = "nqrduck_autotm.autotm:AutoTM" "nqrduck-autotm" = "nqrduck_autotm.autotm:AutoTM"
dev = [
"black",
"pydocstyle",
"pyupgrade",
"ruff",
]
[tool.ruff]
exclude = [
"widget.py",
]
[tool.ruff.lint]
extend-select = [
"UP", # pyupgrade
"D", # pydocstyle
]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
[tool.ruff.lint.pydocstyle]
convention = "google"
[project.urls]
"Homepage" = "https://nqrduck.cool"
"Bug Tracker" = "https://github.com/nqrduck/nqrduck-autotm/issues"
"Source Code" = "https://github.com/nqrduck/nqrduck-autotm"
[tool.hatch.build.targets.wheel]
packages = ["src/nqrduck"]

View file

@ -2,11 +2,9 @@ import logging
import time import time
import numpy as np import numpy as np
import json import json
import time
from serial.tools.list_ports import comports from serial.tools.list_ports import comports
from PyQt6.QtTest import QTest
from PyQt6 import QtSerialPort from PyQt6 import QtSerialPort
from PyQt6.QtCore import QThread, pyqtSignal, pyqtSlot, Qt from PyQt6.QtCore import pyqtSlot
from PyQt6.QtCore import QTimer from PyQt6.QtCore import QTimer
from PyQt6.QtWidgets import QApplication from PyQt6.QtWidgets import QApplication
from nqrduck.module.module_controller import ModuleController from nqrduck.module.module_controller import ModuleController
@ -43,7 +41,7 @@ class AutoTMController(ModuleController):
self.tune_and_match(value) self.tune_and_match(value)
def tune_and_match(self, frequency: float) -> None: def tune_and_match(self, frequency: float) -> None:
""" This method is called when this module already has a LUT table. It should then tune and match the probe coil to the specified frequency. """This method is called when this module already has a LUT table. It should then tune and match the probe coil to the specified frequency.
""" """
if self.module.model.LUT is None: if self.module.model.LUT is None:
logger.error("Could not tune and match. No LUT available.") logger.error("Could not tune and match. No LUT available.")
@ -301,7 +299,8 @@ class AutoTMController(ModuleController):
It hides the voltage sweep spinner dialog and adds the data to the model. It hides the voltage sweep spinner dialog and adds the data to the model.
Args: Args:
LUT (LookupTable): The lookup table that is being generated.""" LUT (LookupTable): The lookup table that is being generated.
"""
logger.debug("Voltage sweep finished") logger.debug("Voltage sweep finished")
self.module.view.el_LUT_spinner.hide() self.module.view.el_LUT_spinner.hide()
self.module.model.LUT = LUT self.module.model.LUT = LUT
@ -505,7 +504,7 @@ class AutoTMController(ModuleController):
logger.debug("Importing calibration") logger.debug("Importing calibration")
# We import the different calibrations from a json file # We import the different calibrations from a json file
with open(filename, "r") as f: with open(filename) as f:
data = json.load(f) data = json.load(f)
self.module.model.short_calibration = S11Data.from_json(data["short"]) self.module.model.short_calibration = S11Data.from_json(data["short"])
self.module.model.open_calibration = S11Data.from_json(data["open"]) self.module.model.open_calibration = S11Data.from_json(data["open"])
@ -533,10 +532,9 @@ class AutoTMController(ModuleController):
Args: Args:
filename (str): Path to file. filename (str): Path to file.
""" """
logger.debug("Loading measurement.") logger.debug("Loading measurement.")
with open(filename, "r") as f: with open(filename) as f:
measurement = json.load(f) measurement = json.load(f)
self.module.model.measurement = S11Data.from_json(measurement) self.module.model.measurement = S11Data.from_json(measurement)
@ -928,7 +926,7 @@ class AutoTMController(ModuleController):
# First clear the old positions # First clear the old positions
self.module.model.saved_positions = [] self.module.model.saved_positions = []
with open(path, "r") as f: with open(path) as f:
positions = json.load(f) positions = json.load(f)
for position in positions: for position in positions:
logger.debug("Loading position: %s", position) logger.debug("Loading position: %s", position)
@ -1048,7 +1046,6 @@ class AutoTMController(ModuleController):
def start_next_mechTM(self, LUT): def start_next_mechTM(self, LUT):
"""Start the next mechanical tuning and matching sweep.""" """Start the next mechanical tuning and matching sweep."""
next_frequency = LUT.get_next_frequency() next_frequency = LUT.get_next_frequency()
LUT.started_frequency = next_frequency LUT.started_frequency = next_frequency
logger.debug("Starting next mechanical tuning and matching:") logger.debug("Starting next mechanical tuning and matching:")

View file

@ -40,7 +40,6 @@ class S11Data:
Keyword Arguments: Keyword Arguments:
phase_correction {bool} -- If True, the phase correction is applied. (default: {False}) phase_correction {bool} -- If True, the phase correction is applied. (default: {False})
""" """
phase_deg = (self.phase_mv - self.CENTER_POINT_PHASE) / self.PHASE_SLOPE phase_deg = (self.phase_mv - self.CENTER_POINT_PHASE) / self.PHASE_SLOPE
if phase_correction: if phase_correction:
phase_deg = self.phase_correction(self.frequency, phase_deg) phase_deg = self.phase_correction(self.frequency, phase_deg)
@ -197,7 +196,7 @@ class Stepper:
self.homed = False self.homed = False
self.position = 0 self.position = 0
class SavedPosition(): class SavedPosition:
"""This class is used to store a saved position for tuning and matching of electrical probeheads.""" """This class is used to store a saved position for tuning and matching of electrical probeheads."""
def __init__(self, frequency: float, tuning_position : int, matching_position : int) -> None: def __init__(self, frequency: float, tuning_position : int, matching_position : int) -> None:
self.frequency = frequency self.frequency = frequency
@ -251,7 +250,8 @@ class ElectricalLookupTable(LookupTable):
Args: Args:
tuning_voltage (float): The tuning voltage for the given frequency. tuning_voltage (float): The tuning voltage for the given frequency.
matching_voltage (float): The matching voltage for the given frequency.""" matching_voltage (float): The matching voltage for the given frequency.
"""
self.data[self.started_frequency] = (tuning_voltage, matching_voltage) self.data[self.started_frequency] = (tuning_voltage, matching_voltage)
def get_voltages(self, frequency: float) -> tuple: def get_voltages(self, frequency: float) -> tuple:
@ -287,7 +287,6 @@ class ElectricalLookupTable(LookupTable):
Returns: Returns:
float: The next frequency for which the tuning and matching voltage is not yet set. float: The next frequency for which the tuning and matching voltage is not yet set.
""" """
for frequency, (tuning_voltage, matching_voltage) in self.data.items(): for frequency, (tuning_voltage, matching_voltage) in self.data.items():
if tuning_voltage is None or matching_voltage is None: if tuning_voltage is None or matching_voltage is None:
return frequency return frequency
@ -316,7 +315,8 @@ class MechanicalLookupTable(LookupTable):
Args: Args:
tuning_position (int): The tuning position for the given frequency. tuning_position (int): The tuning position for the given frequency.
matching_position (int): The matching position for the given frequency.""" matching_position (int): The matching position for the given frequency.
"""
self.data[self.started_frequency] = (tuning_position, matching_position) self.data[self.started_frequency] = (tuning_position, matching_position)
def get_positions(self, frequency: float) -> tuple: def get_positions(self, frequency: float) -> tuple:
@ -352,7 +352,6 @@ class MechanicalLookupTable(LookupTable):
Returns: Returns:
float: The next frequency for which the tuning and matching position is not yet set. float: The next frequency for which the tuning and matching position is not yet set.
""" """
for frequency, (tuning_position, matching_position) in self.data.items(): for frequency, (tuning_position, matching_position) in self.data.items():
if tuning_position is None or matching_position is None: if tuning_position is None or matching_position is None:
return frequency return frequency
@ -452,7 +451,8 @@ class AutoTMModel(ModuleModel):
@property @property
def measurement(self): def measurement(self):
"""The measurement property is used to store the current measurement. """The measurement property is used to store the current measurement.
This is the measurement that is shown in the main S11 plot""" This is the measurement that is shown in the main S11 plot
"""
return self._measurement return self._measurement
@measurement.setter @measurement.setter

View file

@ -212,7 +212,8 @@ class AutoTMView(ModuleView):
"""Update the serial 'connectionLabel' according to the current serial connection. """Update the serial 'connectionLabel' according to the current serial connection.
Args: Args:
serial (serial.Serial): The current serial connection.""" serial (serial.Serial): The current serial connection.
"""
logger.debug("Updating serial connection label") logger.debug("Updating serial connection label")
if serial.isOpen(): if serial.isOpen():
self._ui_form.connectionLabel.setText(serial.portName()) self._ui_form.connectionLabel.setText(serial.portName())