Skip to content
Snippets Groups Projects
Commit 7ca370e4 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Cleanup code, refactor, fix docs

parent b138c5f9
Branches
Tags
1 merge request!241Cleanup code, refactor, fix docs
Pipeline #90628 passed
...@@ -40,7 +40,7 @@ from b_asic.GUI.show_pc_window import ShowPCWindow ...@@ -40,7 +40,7 @@ from b_asic.GUI.show_pc_window import ShowPCWindow
# from b_asic.GUI.simulate_sfg_window import Plot, SimulateSFGWindow # from b_asic.GUI.simulate_sfg_window import Plot, SimulateSFGWindow
from b_asic.GUI.simulate_sfg_window import SimulateSFGWindow from b_asic.GUI.simulate_sfg_window import SimulateSFGWindow
from b_asic.GUI.util_dialogs import FaqWindow, KeybindsWindow from b_asic.GUI.util_dialogs import FaqWindow, KeybindingsWindow
from b_asic.GUI.utils import decorate_class, handle_error from b_asic.GUI.utils import decorate_class, handle_error
from b_asic.gui_utils.about_window import AboutWindow from b_asic.gui_utils.about_window import AboutWindow
from b_asic.gui_utils.plot_window import PlotWindow from b_asic.gui_utils.plot_window import PlotWindow
...@@ -83,7 +83,21 @@ class MainWindow(QMainWindow): ...@@ -83,7 +83,21 @@ class MainWindow(QMainWindow):
self.sfg_dict = {} self.sfg_dict = {}
self._window = self self._window = self
self.logger = logging.getLogger(__name__) self.logger = logging.getLogger(__name__)
self.init_ui()
# Create Graphics View
self.graphic_view = QGraphicsView(self.scene, self)
self.graphic_view.setRenderHint(QPainter.Antialiasing)
self.graphic_view.setGeometry(
self.ui.operation_box.width(), 20, self.width(), self.height()
)
self.graphic_view.setDragMode(QGraphicsView.RubberBandDrag)
# Create toolbar
self.toolbar = self.addToolBar("Toolbar")
self.toolbar.addAction("Create SFG", self.create_sfg_from_toolbar)
self.toolbar.addAction("Clear workspace", self.clear_workspace)
# Add operations
self.add_operations_from_namespace( self.add_operations_from_namespace(
b_asic.core_operations, self.ui.core_operations_list b_asic.core_operations, self.ui.core_operations_list
) )
...@@ -110,7 +124,7 @@ class MainWindow(QMainWindow): ...@@ -110,7 +124,7 @@ class MainWindow(QMainWindow):
self.ui.actionSimulateSFG.triggered.connect(self.simulate_sfg) self.ui.actionSimulateSFG.triggered.connect(self.simulate_sfg)
self.ui.faqBASIC.triggered.connect(self.display_faq_page) self.ui.faqBASIC.triggered.connect(self.display_faq_page)
self.ui.aboutBASIC.triggered.connect(self.display_about_page) self.ui.aboutBASIC.triggered.connect(self.display_about_page)
self.ui.keybindsBASIC.triggered.connect(self.display_keybinds_page) self.ui.keybindsBASIC.triggered.connect(self.display_keybindings_page)
self.ui.core_operations_list.itemClicked.connect( self.ui.core_operations_list.itemClicked.connect(
self.on_list_widget_item_clicked self.on_list_widget_item_clicked
) )
...@@ -133,6 +147,10 @@ class MainWindow(QMainWindow): ...@@ -133,6 +147,10 @@ class MainWindow(QMainWindow):
self.shortcut_signal = QShortcut(QKeySequence(Qt.Key_Space), self) self.shortcut_signal = QShortcut(QKeySequence(Qt.Key_Space), self)
self.shortcut_signal.activated.connect(self._connect_callback) self.shortcut_signal.activated.connect(self._connect_callback)
self._keybindings_page = None
self._about_page = None
self._faq_page = None
self.logger.info("Finished setting up GUI") self.logger.info("Finished setting up GUI")
self.logger.info( self.logger.info(
"For questions please refer to 'Ctrl+?', or visit the 'Help' " "For questions please refer to 'Ctrl+?', or visit the 'Help' "
...@@ -141,23 +159,6 @@ class MainWindow(QMainWindow): ...@@ -141,23 +159,6 @@ class MainWindow(QMainWindow):
self.cursor = QCursor() self.cursor = QCursor()
def init_ui(self) -> None:
self.create_toolbar_view()
self.create_graphics_view()
def create_graphics_view(self) -> None:
self.graphic_view = QGraphicsView(self.scene, self)
self.graphic_view.setRenderHint(QPainter.Antialiasing)
self.graphic_view.setGeometry(
self.ui.operation_box.width(), 20, self.width(), self.height()
)
self.graphic_view.setDragMode(QGraphicsView.RubberBandDrag)
def create_toolbar_view(self) -> None:
self.toolbar = self.addToolBar("Toolbar")
self.toolbar.addAction("Create SFG", self.create_sfg_from_toolbar)
self.toolbar.addAction("Clear workspace", self.clear_workspace)
def resizeEvent(self, event) -> None: def resizeEvent(self, event) -> None:
ui_width = self.ui.operation_box.width() ui_width = self.ui.operation_box.width()
self.ui.operation_box.setGeometry(10, 10, ui_width, self.height()) self.ui.operation_box.setGeometry(10, 10, ui_width, self.height())
...@@ -565,8 +566,8 @@ class MainWindow(QMainWindow): ...@@ -565,8 +566,8 @@ class MainWindow(QMainWindow):
def _create_operation_item(self, item) -> None: def _create_operation_item(self, item) -> None:
self.logger.info("Creating operation of type: %s" % str(item.text())) self.logger.info("Creating operation of type: %s" % str(item.text()))
try: try:
attr_oper = self._operations_from_name[item.text()]() attr_operation = self._operations_from_name[item.text()]()
self.create_operation(attr_oper) self.create_operation(attr_operation)
except Exception as e: except Exception as e:
self.logger.error( self.logger.error(
"Unexpected error occurred while creating operation: " + str(e) "Unexpected error occurred while creating operation: " + str(e)
...@@ -712,16 +713,19 @@ class MainWindow(QMainWindow): ...@@ -712,16 +713,19 @@ class MainWindow(QMainWindow):
self._simulation_dialog.simulate.connect(self._simulate_sfg) self._simulation_dialog.simulate.connect(self._simulate_sfg)
def display_faq_page(self, event=None) -> None: def display_faq_page(self, event=None) -> None:
self._faq_page = FaqWindow(self) if self._faq_page is None:
self._faq_page = FaqWindow(self)
self._faq_page.scroll_area.show() self._faq_page.scroll_area.show()
def display_about_page(self, event=None) -> None: def display_about_page(self, event=None) -> None:
self._about_page = AboutWindow(self) if self._about_page is None:
self._about_page = AboutWindow(self)
self._about_page.show() self._about_page.show()
def display_keybinds_page(self, event=None) -> None: def display_keybindings_page(self, event=None) -> None:
self._keybinds_page = KeybindsWindow(self) if self._keybindings_page is None:
self._keybinds_page.show() self._keybindings_page = KeybindingsWindow(self)
self._keybindings_page.show()
def start_gui(): def start_gui():
......
...@@ -65,7 +65,7 @@ _QUESTIONS = { ...@@ -65,7 +65,7 @@ _QUESTIONS = {
} }
class KeybindsWindow(QDialog): class KeybindingsWindow(QDialog):
def __init__(self, window): def __init__(self, window):
super().__init__() super().__init__()
self._window = window self._window = window
...@@ -88,7 +88,7 @@ class KeybindsWindow(QDialog): ...@@ -88,7 +88,7 @@ class KeybindsWindow(QDialog):
frame.setFrameShadow(QFrame.Sunken) frame.setFrameShadow(QFrame.Sunken)
self.dialog_layout.addWidget(frame) self.dialog_layout.addWidget(frame)
keybinds_label = QLabel( keybindings_label = QLabel(
"'Ctrl+R' - Reload the operation list to add any new operations " "'Ctrl+R' - Reload the operation list to add any new operations "
"created.\n" "created.\n"
"'Ctrl+Q' - Quit the application.\n" "'Ctrl+Q' - Quit the application.\n"
...@@ -104,7 +104,7 @@ class KeybindsWindow(QDialog): ...@@ -104,7 +104,7 @@ class KeybindsWindow(QDialog):
self.dialog_layout.addLayout(information_layout) self.dialog_layout.addLayout(information_layout)
self.dialog_layout.addWidget(frame) self.dialog_layout.addWidget(frame)
self.dialog_layout.addWidget(keybinds_label) self.dialog_layout.addWidget(keybindings_label)
class FaqWindow(QDialog): class FaqWindow(QDialog):
......
...@@ -360,7 +360,7 @@ class Multiplication(AbstractOperation): ...@@ -360,7 +360,7 @@ class Multiplication(AbstractOperation):
@property @property
def is_linear(self) -> bool: def is_linear(self) -> bool:
return any( return any(
input.connected_source.operation.is_constant for input in self.inputs input_.connected_source.operation.is_constant for input_ in self.inputs
) )
......
...@@ -130,10 +130,7 @@ class AbstractGraphComponent(GraphComponent): ...@@ -130,10 +130,7 @@ class AbstractGraphComponent(GraphComponent):
f"id: {self.graph_id if self.graph_id else 'no_id'}, \tname:" f"id: {self.graph_id if self.graph_id else 'no_id'}, \tname:"
f" {self.name if self.name else 'no_name'}" f" {self.name if self.name else 'no_name'}"
+ "".join( + "".join(
( (f", \t{key}: {str(param)}" for key, param in self._parameters.items())
f", \t{key}: {str(param)}"
for key, param in self._parameters.items()
)
) )
) )
...@@ -176,12 +173,12 @@ class AbstractGraphComponent(GraphComponent): ...@@ -176,12 +173,12 @@ class AbstractGraphComponent(GraphComponent):
def traverse(self) -> Generator[GraphComponent, None, None]: def traverse(self) -> Generator[GraphComponent, None, None]:
# Breadth first search. # Breadth first search.
visited = {self} visited = {self}
fontier = deque([self]) frontier = deque([self])
while fontier: while frontier:
component = fontier.popleft() component = frontier.popleft()
yield component yield component
for neighbor in component.neighbors: for neighbor in component.neighbors:
neighbor = cast(AbstractGraphComponent, neighbor) neighbor = cast(AbstractGraphComponent, neighbor)
if neighbor not in visited: if neighbor not in visited:
visited.add(neighbor) visited.add(neighbor)
fontier.append(neighbor) frontier.append(neighbor)
"""PlotWindow is a window in which simulation results are plotted.""" """PlotWindow is a window in which simulation results are plotted."""
# TODO's:
# * Solve the legend update. That isn't working at all.
# * Add a function to run this as a "stand-alone".
import re import re
import sys import sys
from typing import Dict, List, Optional, Tuple from typing import Dict, List, Optional
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure from matplotlib.figure import Figure
from matplotlib.ticker import MaxNLocator from matplotlib.ticker import MaxNLocator
from qtpy.QtCore import Qt from qtpy.QtCore import Qt
# Intereme imports for the Plot class:
from qtpy.QtWidgets import ( # QFrame,; QScrollArea,; QLineEdit,; QSizePolicy,; QLabel,; QFileDialog,; QShortcut, from qtpy.QtWidgets import ( # QFrame,; QScrollArea,; QLineEdit,; QSizePolicy,; QLabel,; QFileDialog,; QShortcut,
QApplication, QApplication,
QCheckBox, QCheckBox,
...@@ -144,18 +138,18 @@ class PlotWindow(QDialog): ...@@ -144,18 +138,18 @@ class PlotWindow(QDialog):
# listlayout.addWidget(self.ontop_checkbox) # listlayout.addWidget(self.ontop_checkbox)
# Add "Close" buttons # Add "Close" buttons
buttonClose = QPushButton("&Close", self) button_close = QPushButton("&Close", self)
buttonClose.clicked.connect(self.close) button_close.clicked.connect(self.close)
listlayout.addWidget(buttonClose) listlayout.addWidget(button_close)
# Done. Tell the functions below to redraw the canvas when needed. # Done. Tell the functions below to redraw the canvas when needed.
# self.plotcanvas.draw() # self.plotcanvas.draw()
self._auto_redraw = True self._auto_redraw = True
def _legend_checkbox_change(self, checkState): def _legend_checkbox_change(self, check_state):
self._legend.set(visible=(checkState == Qt.CheckState.Checked)) self._legend.set(visible=(check_state == Qt.CheckState.Checked))
if self._auto_redraw: if self._auto_redraw:
if checkState == Qt.CheckState.Checked: if check_state == Qt.CheckState.Checked:
self._legend = self._plot_axes.legend() self._legend = self._plot_axes.legend()
self._plot_canvas.draw() self._plot_canvas.draw()
......
...@@ -856,9 +856,9 @@ class AbstractOperation(Operation, AbstractGraphComponent): ...@@ -856,9 +856,9 @@ class AbstractOperation(Operation, AbstractGraphComponent):
operation_copy: Operation = cast(Operation, self.copy_component()) operation_copy: Operation = cast(Operation, self.copy_component())
inputs = [] inputs = []
for i in range(self.input_count): for i in range(self.input_count):
_input = Input() input_ = Input()
operation_copy.input(i).connect(_input) operation_copy.input(i).connect(input_)
inputs.append(_input) inputs.append(input_)
outputs = [Output(operation_copy)] outputs = [Output(operation_copy)]
...@@ -868,8 +868,8 @@ class AbstractOperation(Operation, AbstractGraphComponent): ...@@ -868,8 +868,8 @@ class AbstractOperation(Operation, AbstractGraphComponent):
new_component: Operation = cast( new_component: Operation = cast(
Operation, super().copy_component(*args, **kwargs) Operation, super().copy_component(*args, **kwargs)
) )
for i, input in enumerate(self.inputs): for i, _input in enumerate(self.inputs):
new_component.input(i).latency_offset = input.latency_offset new_component.input(i).latency_offset = _input.latency_offset
for i, output in enumerate(self.outputs): for i, output in enumerate(self.outputs):
new_component.output(i).latency_offset = output.latency_offset new_component.output(i).latency_offset = output.latency_offset
new_component.execution_time = self._execution_time new_component.execution_time = self._execution_time
...@@ -974,8 +974,8 @@ class AbstractOperation(Operation, AbstractGraphComponent): ...@@ -974,8 +974,8 @@ class AbstractOperation(Operation, AbstractGraphComponent):
return max( return max(
( (
(cast(int, output.latency_offset) - cast(int, input.latency_offset)) (cast(int, output.latency_offset) - cast(int, input_.latency_offset))
for output, input in it.product(self.outputs, self.inputs) for output, input_ in it.product(self.outputs, self.inputs)
) )
) )
...@@ -983,8 +983,8 @@ class AbstractOperation(Operation, AbstractGraphComponent): ...@@ -983,8 +983,8 @@ class AbstractOperation(Operation, AbstractGraphComponent):
def latency_offsets(self) -> Dict[str, Optional[int]]: def latency_offsets(self) -> Dict[str, Optional[int]]:
latency_offsets = {} latency_offsets = {}
for i, input in enumerate(self.inputs): for i, input_ in enumerate(self.inputs):
latency_offsets[f"in{i}"] = input.latency_offset latency_offsets[f"in{i}"] = input_.latency_offset
for i, output in enumerate(self.outputs): for i, output in enumerate(self.outputs):
latency_offsets[f"out{i}"] = output.latency_offset latency_offsets[f"out{i}"] = output.latency_offset
...@@ -992,7 +992,7 @@ class AbstractOperation(Operation, AbstractGraphComponent): ...@@ -992,7 +992,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
return latency_offsets return latency_offsets
def _check_all_latencies_set(self) -> None: def _check_all_latencies_set(self) -> None:
"""Raises an exception of an input or output does not have its latency offset set """Raises an exception if an input or output does not have its latency offset set
""" """
self.input_latency_offsets() self.input_latency_offsets()
self.output_latency_offsets() self.output_latency_offsets()
...@@ -1159,5 +1159,5 @@ class AbstractOperation(Operation, AbstractGraphComponent): ...@@ -1159,5 +1159,5 @@ class AbstractOperation(Operation, AbstractGraphComponent):
@property @property
def is_constant(self) -> bool: def is_constant(self) -> bool:
return all( return all(
input.connected_source.operation.is_constant for input in self.inputs input_.connected_source.operation.is_constant for input_ in self.inputs
) )
...@@ -72,7 +72,7 @@ class OperatorProcess(Process): ...@@ -72,7 +72,7 @@ class OperatorProcess(Process):
========== ==========
start_time : int start_time : int
Start time of process. Start time of process.
operation : Operation operation : :class:`~b_asic.operation.Operation`
Operation that the process corresponds to. Operation that the process corresponds to.
name : str, optional name : str, optional
The name of the process. The name of the process.
...@@ -106,11 +106,11 @@ class MemoryVariable(Process): ...@@ -106,11 +106,11 @@ class MemoryVariable(Process):
write_time : int write_time : int
Time when the memory variable is written. Time when the memory variable is written.
write_port : OutputPort write_port : :class:`~b_asic.port.OutputPort`
The OutputPort that the memory variable originates from. The OutputPort that the memory variable originates from.
reads : {InputPort: int, ...} reads : dict
Dictionary with the InputPorts that reads the memory variable and Dictionary with :class:`~b_asic.port.InputPort` that reads the memory variable as key and
for how long after the *write_time* they will read. for how long after the *write_time* it will read.
name : str, optional name : str, optional
The name of the process. The name of the process.
""" """
......
...@@ -3,13 +3,15 @@ Functions to generate memory-variable test data that are used for research. ...@@ -3,13 +3,15 @@ Functions to generate memory-variable test data that are used for research.
""" """
import random import random
from typing import Optional, Set from typing import List, Optional, Tuple
from b_asic.process import PlainMemoryVariable from b_asic.process import PlainMemoryVariable
from b_asic.resources import ProcessCollection from b_asic.resources import ProcessCollection
def _insert_delays(inputorder, outputorder, min_lifetime, cyclic): def _insert_delays(
inputorder: List[int], outputorder: List[int], min_lifetime: int, cyclic: bool
) -> Tuple[List[int], List[int]]:
size = len(inputorder) size = len(inputorder)
maxdiff = min(outputorder[i] - inputorder[i] for i in range(size)) maxdiff = min(outputorder[i] - inputorder[i] for i in range(size))
outputorder = [o - maxdiff + min_lifetime for o in outputorder] outputorder = [o - maxdiff + min_lifetime for o in outputorder]
......
...@@ -376,10 +376,12 @@ class ProcessCollection: ...@@ -376,10 +376,12 @@ class ProcessCollection:
---------- ----------
heuristic : {'graph_color', 'left_edge'}, default: 'graph_color' heuristic : {'graph_color', 'left_edge'}, default: 'graph_color'
The heuristic used when splitting based on execution times. The heuristic used when splitting based on execution times.
coloring_strategy : str, default: 'saturation_largest_first' coloring_strategy : str, default: 'saturation_largest_first'
Node ordering strategy passed to :func:`networkx.coloring.greedy_color`. Node ordering strategy passed to :func:`networkx.coloring.greedy_color`.
This parameter is only considered if *heuristic* is set to 'graph_color'. This parameter is only considered if *heuristic* is set to 'graph_color'.
One of One of
* 'largest_first' * 'largest_first'
* 'random_sequential' * 'random_sequential'
* 'smallest_last' * 'smallest_last'
...@@ -418,14 +420,18 @@ class ProcessCollection: ...@@ -418,14 +420,18 @@ class ProcessCollection:
heuristic : str, default: "graph_color" heuristic : str, default: "graph_color"
The heuristic used when splitting this ProcessCollection. The heuristic used when splitting this ProcessCollection.
Valid options are: Valid options are:
* "graph_color" * "graph_color"
* "..." * "..."
read_ports : int, optional read_ports : int, optional
The number of read ports used when splitting process collection based on The number of read ports used when splitting process collection based on
memory variable access. memory variable access.
write_ports : int, optional write_ports : int, optional
The number of write ports used when splitting process collection based on The number of write ports used when splitting process collection based on
memory variable access. memory variable access.
total_ports : int, optional total_ports : int, optional
The total number of ports used when splitting process collection based on The total number of ports used when splitting process collection based on
memory variable access. memory variable access.
......
...@@ -23,7 +23,7 @@ def sfg_to_python( ...@@ -23,7 +23,7 @@ def sfg_to_python(
Parameters Parameters
---------- ----------
sfg : SFG sfg : :class:`~b_asic.signal_flow_graph.SFG`
The SFG to serialize. The SFG to serialize.
counter : int, default: 0 counter : int, default: 0
Number used for naming the SFG. Enables SFGs in SFGs. Number used for naming the SFG. Enables SFGs in SFGs.
...@@ -167,7 +167,7 @@ def schedule_to_python(schedule: Schedule) -> str: ...@@ -167,7 +167,7 @@ def schedule_to_python(schedule: Schedule) -> str:
Parameters Parameters
---------- ----------
schedule : Schedule schedule : :class:`~b_asic.schedule.Schedule`
The schedule to serialize. The schedule to serialize.
""" """
if not isinstance(schedule, Schedule): if not isinstance(schedule, Schedule):
......
...@@ -48,7 +48,7 @@ class Schedule: ...@@ -48,7 +48,7 @@ class Schedule:
Parameters Parameters
---------- ----------
sfg : SFG sfg : :class:`~b_asic.signal_flow_graph.SFG`
The signal flow graph to schedule. The signal flow graph to schedule.
schedule_time : int, optional schedule_time : int, optional
The schedule time. If not provided, it will be determined by the scheduling The schedule time. If not provided, it will be determined by the scheduling
...@@ -899,7 +899,7 @@ class Schedule: ...@@ -899,7 +899,7 @@ class Schedule:
Parameters Parameters
---------- ----------
ax : matplotlib.axes.Axes ax : :class:`~matplotlib.axes.Axes`
The :class:`matplotlib.axes.Axes` to plot in. The :class:`matplotlib.axes.Axes` to plot in.
operation_gap : float, optional operation_gap : float, optional
The vertical distance between operations in the schedule. The height of The vertical distance between operations in the schedule. The height of
......
...@@ -46,7 +46,7 @@ def _check_qt_version() -> None: ...@@ -46,7 +46,7 @@ def _check_qt_version() -> None:
def replace_qt_bindings(filename: str) -> None: def replace_qt_bindings(filename: str) -> None:
"""Raplaces qt-binding api in *filename* from PySide2/6 or PyQt5/6 to qtpy.""" """Replaces qt-binding API in *filename* from PySide2/6 or PyQt5/6 to qtpy."""
with open(f"{filename}", "r") as file: with open(f"{filename}", "r") as file:
filedata = file.read() filedata = file.read()
filedata = filedata.replace("from PyQt5", "from qtpy") filedata = filedata.replace("from PyQt5", "from qtpy")
...@@ -64,7 +64,7 @@ def compile_rc(*filenames: str) -> None: ...@@ -64,7 +64,7 @@ def compile_rc(*filenames: str) -> None:
""" """
_check_qt_version() _check_qt_version()
def compile(filename: str) -> None: def _compile(filename: str) -> None:
outfile = f"{os.path.splitext(filename)[0]}_rc.py" outfile = f"{os.path.splitext(filename)[0]}_rc.py"
rcc = shutil.which("pyside2-rcc") rcc = shutil.which("pyside2-rcc")
arguments = f"-g python -o {outfile} {filename}" arguments = f"-g python -o {outfile} {filename}"
...@@ -117,12 +117,12 @@ def compile_rc(*filenames: str) -> None: ...@@ -117,12 +117,12 @@ def compile_rc(*filenames: str) -> None:
] ]
for filename in rc_files: for filename in rc_files:
compile(filename) _compile(filename)
else: else:
_check_filenames(*filenames) _check_filenames(*filenames)
for filename in filenames: for filename in filenames:
compile(filename) _compile(filename)
def compile_ui(*filenames: str) -> None: def compile_ui(*filenames: str) -> None:
...@@ -132,7 +132,7 @@ def compile_ui(*filenames: str) -> None: ...@@ -132,7 +132,7 @@ def compile_ui(*filenames: str) -> None:
""" """
_check_qt_version() _check_qt_version()
def compile(filename: str) -> None: def _compile(filename: str) -> None:
directory, file = os.path.split(filename) directory, file = os.path.split(filename)
file = os.path.splitext(file)[0] file = os.path.splitext(file)[0]
directory = directory if directory else "." directory = directory if directory else "."
...@@ -219,11 +219,11 @@ def compile_ui(*filenames: str) -> None: ...@@ -219,11 +219,11 @@ def compile_ui(*filenames: str) -> None:
if name.endswith(".ui") if name.endswith(".ui")
] ]
for filename in ui_files: for filename in ui_files:
compile(filename) _compile(filename)
else: else:
_check_filenames(*filenames) _check_filenames(*filenames)
for filename in filenames: for filename in filenames:
compile(filename) _compile(filename)
def compile_all() -> None: def compile_all() -> None:
......
...@@ -9,7 +9,7 @@ on the :mod:`logging` module and has predefined levels of logging. ...@@ -9,7 +9,7 @@ on the :mod:`logging` module and has predefined levels of logging.
Usage: Usage:
------ ------
>>> import logger >>> import b_asic.scheduler_gui.logger as logger
>>> log = logger.getLogger() >>> log = logger.getLogger()
>>> log.info('This is a log post with level INFO') >>> log.info('This is a log post with level INFO')
...@@ -87,7 +87,7 @@ def getLogger(filename: str = "scheduler-gui.log", loglevel: str = "INFO") -> Lo ...@@ -87,7 +87,7 @@ def getLogger(filename: str = "scheduler-gui.log", loglevel: str = "INFO") -> Lo
loglevel = getattr(logging, loglevel.upper(), logging.INFO) loglevel = getattr(logging, loglevel.upper(), logging.INFO)
logger.setLevel(loglevel) logger.setLevel(loglevel)
# setup the console logger # set up the console logger
c_fmt_date = "%T" c_fmt_date = "%T"
c_fmt = ( c_fmt = (
"[%(process)d] %(asctime)s %(filename)18s:%(lineno)-4s" "[%(process)d] %(asctime)s %(filename)18s:%(lineno)-4s"
......
...@@ -617,13 +617,13 @@ class SFG(AbstractOperation): ...@@ -617,13 +617,13 @@ class SFG(AbstractOperation):
if component_copy.input_count != component.input_count: if component_copy.input_count != component.input_count:
raise TypeError("The input count may not differ between the operations") raise TypeError("The input count may not differ between the operations")
for index_in, inp in enumerate(component_copy.inputs): for index_in, input_ in enumerate(component_copy.inputs):
for signal in inp.signals: for signal in input_.signals:
signal.remove_destination() signal.remove_destination()
signal.set_destination(component.input(index_in)) signal.set_destination(component.input(index_in))
for index_out, outp in enumerate(component_copy.outputs): for index_out, output in enumerate(component_copy.outputs):
for signal in outp.signals: for signal in output.signals:
signal.remove_source() signal.remove_source()
signal.set_source(component.output(index_out)) signal.set_source(component.output(index_out))
...@@ -1410,8 +1410,8 @@ class SFG(AbstractOperation): ...@@ -1410,8 +1410,8 @@ class SFG(AbstractOperation):
# and outputs of all operations # and outputs of all operations
for layer, op_list in enumerate(new_ops): for layer, op_list in enumerate(new_ops):
for op_idx, op in enumerate(op_list): for op_idx, op in enumerate(op_list):
for input in op.inputs: for input_ in op.inputs:
input.clear() input_.clear()
for output in op.outputs: for output in op.outputs:
output.clear() output.clear()
...@@ -1458,7 +1458,7 @@ class SFG(AbstractOperation): ...@@ -1458,7 +1458,7 @@ class SFG(AbstractOperation):
for out_signal in op.outputs[0].signals: for out_signal in op.outputs[0].signals:
sink_port = out_signal.destination sink_port = out_signal.destination
if sink_port is None: if sink_port is None:
# It would be weird if we found a signal but it wasn't connected anywere # It would be weird if we found a signal that wasn't connected anywhere
raise ValueError("Dangling output port in sfg") raise ValueError("Dangling output port in sfg")
sink_op_idx = id_idx_map[sink_port.operation.graph_id] sink_op_idx = id_idx_map[sink_port.operation.graph_id]
......
...@@ -13,7 +13,6 @@ if you want more information. ...@@ -13,7 +13,6 @@ if you want more information.
from math import pi, sin from math import pi, sin
from numbers import Number from numbers import Number
from pathlib import Path
from typing import Optional, Sequence from typing import Optional, Sequence
import numpy as np import numpy as np
...@@ -300,7 +299,7 @@ class Delay(SignalGenerator): ...@@ -300,7 +299,7 @@ class Delay(SignalGenerator):
""" """
Signal generator that delays the value of another signal generator. Signal generator that delays the value of another signal generator.
This can used to easily delay a sequence during simulation. This can be used to easily delay a sequence during simulation.
.. note:: Although the purpose is to delay, it is also possible to look ahead by .. note:: Although the purpose is to delay, it is also possible to look ahead by
providing a negative delay. providing a negative delay.
......
...@@ -139,11 +139,11 @@ def test_help_dialogs(qtbot): ...@@ -139,11 +139,11 @@ def test_help_dialogs(qtbot):
widget.display_faq_page() widget.display_faq_page()
widget.display_about_page() widget.display_about_page()
widget.display_keybinds_page() widget.display_keybindings_page()
qtbot.wait(100) qtbot.wait(100)
widget._faq_page.close() widget._faq_page.close()
widget._about_page.close() widget._about_page.close()
widget._keybinds_page.close() widget._keybindings_page.close()
widget.exit_app() widget.exit_app()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment