Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and enforce flake8 #368

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix flake8 errors
  • Loading branch information
bleykauf committed Dec 19, 2023
commit 92e233d6e4d7194b42b4ffbe8ed92d44a79e3ffd
2 changes: 1 addition & 1 deletion linien-client/linien_client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, client_version, remote_version):
self.remote_version = remote_version

super().__init__(
f"Version mismatch: Client is {client_version} and server is {remote_version}"
f"Version mismatch: Client is {client_version}, server is {remote_version}"
)


Expand Down
5 changes: 4 additions & 1 deletion linien-common/linien_common/influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def __init__(
self.measurement = measurement

def __str__(self) -> str:
return f"url: {self.url}, org: {self.org}, token: {self.token}, bucket: {self.bucket}, measurement: {self.measurement}"
return (
f"url: {self.url}, org: {self.org}, token: {self.token}, "
f" bucket: {self.bucket}, measurement: {self.measurement}"
)


def save_credentials(credentials: InfluxDBCredentials) -> None:
Expand Down
19 changes: 10 additions & 9 deletions linien-gui/linien_gui/ui/spectroscopy_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,18 @@ def change_filter_type(filter_i):
)

for filter_i in [1, 2]:
_get = lambda parent, attr, filter_i=filter_i: getattr(
parent, attr.format(filter_i)
)
_get(self, "filter_{}_enabled").stateChanged.connect(
_get(self, "change_filter_{}_enabled")

def get_(parent, attr, filter_i=filter_i):
return getattr(parent, attr.format(filter_i))

get_(self, "filter_{}_enabled").stateChanged.connect(
get_(self, "change_filter_{}_enabled")
)
freq_input = _get(self, "filter_{}_frequency")
freq_input = get_(self, "filter_{}_frequency")
freq_input.setKeyboardTracking(False)
freq_input.valueChanged.connect(_get(self, "change_filter_{}_frequency"))
_get(self, "filter_{}_type").currentIndexChanged.connect(
_get(self, "change_filter_{}_type")
freq_input.valueChanged.connect(get_(self, "change_filter_{}_frequency"))
get_(self, "filter_{}_type").currentIndexChanged.connect(
get_(self, "change_filter_{}_type")
)

def automatic_changed(value):
Expand Down
1 change: 0 additions & 1 deletion linien-server/linien_server/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import logging
import pickle
import shutil
import subprocess
from pathlib import Path
from random import random
Expand Down
3 changes: 2 additions & 1 deletion linien-server/linien_server/autolock/robust.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def handle_new_spectrum(self, spectrum):

else:
logger.error(
f"Not enough spectra collected: {len(self.spectra)} of {self.N_spectra_required}"
"Not enough spectra collected:"
f"{len(self.spectra)} of {self.N_spectra_required}"
)

def setup_timeout(self, N_acquisitions_to_wait=5):
Expand Down
3 changes: 2 additions & 1 deletion linien-server/linien_server/influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def start_logging(self, interval: float) -> None:
self.thread.start()
else:
raise ConnectionError(
f"Failed to connect to InfluxDB database: {message} (Status code: {status_code})"
"Failed to connect to InfluxDB database: "
f" {message} (Status code: {status_code})"
)

def stop_logging(self) -> None:
Expand Down
7 changes: 5 additions & 2 deletions linien-server/linien_server/registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ def __init__(
def write_registers(self):
"""Writes data from `parameters` to the FPGA."""

max_ = lambda val: val if np.abs(val) <= 8191 else (8191 * val / np.abs(val))
phase_to_delay = lambda phase: int(phase / 360 * (1 << 14))
def max_(val):
return val if np.abs(val) <= 8191 else (8191 * val / np.abs(val))

def phase_to_delay(phase):
return int(phase / 360 * (1 << 14))

if not self.parameters.dual_channel.value:
factor_a = 256
Expand Down
8 changes: 6 additions & 2 deletions linien-server/linien_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def exposed_update_influxdb_credentials(
logger.info("InfluxDB credentials updated successfully")
else:
logger.info(
f"InfluxDB credentials update failed. Error message: {message} (Status Code {status_code})"
"InfluxDB credentials update failed. Error message: "
f" {message} (Status Code {status_code})"
)
return connection_succesful, status_code, message

Expand Down Expand Up @@ -355,7 +356,10 @@ def __init__(self):
def _write_random_data_to_parameters_loop(self, stop_event: Event):
while not stop_event.is_set():
max_ = randint(0, 8191)
gen = lambda: np.array([randint(-max_, max_) for _ in range(N_POINTS)])

def gen():
return np.array([randint(-max_, max_) for _ in range(N_POINTS)])

self.parameters.to_plot.value = pickle.dumps(
{
"error_signal_1": gen(),
Expand Down