diff --git a/b_asic/GUI/__init__.py b/b_asic/GUI/__init__.py index 357ada54290822d2b6c92c4e831446e64de6a908..89256ec9340dbc331d5ddc58488e7a126907dde7 100644 --- a/b_asic/GUI/__init__.py +++ b/b_asic/GUI/__init__.py @@ -2,6 +2,7 @@ Graphical user interface for B-ASIC. """ + from b_asic.GUI.main_window import start_editor __all__ = ['start_editor'] diff --git a/b_asic/GUI/port_button.py b/b_asic/GUI/port_button.py index 92f2696caa2154208bec98ca38d2268a628853a6..c90166d08391fe31101959072bbe56a66395875f 100644 --- a/b_asic/GUI/port_button.py +++ b/b_asic/GUI/port_button.py @@ -1,6 +1,7 @@ """ B-ASIC port button module. """ + from typing import TYPE_CHECKING from qtpy.QtCore import QMimeData, Qt, Signal diff --git a/b_asic/GUI/precedence_graph_window.py b/b_asic/GUI/precedence_graph_window.py index 090ca3d14a6f14cee679854fb4dff15203492af5..57365bf9cef7d3d224bf71ca1fec6f5d0269b512 100644 --- a/b_asic/GUI/precedence_graph_window.py +++ b/b_asic/GUI/precedence_graph_window.py @@ -1,6 +1,7 @@ """ B-ASIC window to show precedence graph. """ + from qtpy.QtCore import Qt, Signal from qtpy.QtWidgets import ( QCheckBox, diff --git a/b_asic/GUI/properties_window.py b/b_asic/GUI/properties_window.py index cb6cda29b7c75303566c946b9a724e62aa0ab136..6babd698309bf263eace0959614332897ec4daad 100644 --- a/b_asic/GUI/properties_window.py +++ b/b_asic/GUI/properties_window.py @@ -162,10 +162,12 @@ class PropertiesWindow(QDialog): self.operation.operation.set_latency_offsets( { - port: float(latency_edit.text().replace(",", ".")) - if latency_edit.text() - and float(latency_edit.text().replace(",", ".")) > 0 - else None + port: ( + float(latency_edit.text().replace(",", ".")) + if latency_edit.text() + and float(latency_edit.text().replace(",", ".")) > 0 + else None + ) for port, latency_edit in self._latency_fields.items() } ) diff --git a/b_asic/GUI/select_sfg_window.py b/b_asic/GUI/select_sfg_window.py index 53118a4b469574ab35db4f95536e9b72e187316f..a3ac58bfaba9dc723be51f0502cec916e16a84af 100644 --- a/b_asic/GUI/select_sfg_window.py +++ b/b_asic/GUI/select_sfg_window.py @@ -1,6 +1,7 @@ """ B-ASIC select SFG window. """ + from typing import TYPE_CHECKING from qtpy.QtCore import Qt, Signal diff --git a/b_asic/GUI/simulate_sfg_window.py b/b_asic/GUI/simulate_sfg_window.py index 2e27170e4db751c57f52ec3ac31ca14e663fe61b..29dc5c8e3028aea33fc4c506cfda401fbb0a3b2c 100644 --- a/b_asic/GUI/simulate_sfg_window.py +++ b/b_asic/GUI/simulate_sfg_window.py @@ -1,6 +1,7 @@ """ B-ASIC window to simulate an SFG. """ + from typing import TYPE_CHECKING, Dict from qtpy.QtCore import Qt, Signal diff --git a/b_asic/__init__.py b/b_asic/__init__.py index fbf1fe4f550cf3ab42d74222029d7991755e979d..dcc3b3970076745b34d3424bcd2964d1c4c96027 100644 --- a/b_asic/__init__.py +++ b/b_asic/__init__.py @@ -1,6 +1,7 @@ """B-ASIC - Better ASIC Toolbox. ASIC toolbox that simplifies circuit design and optimization. """ + # Python modules. from b_asic.core_operations import * from b_asic.graph_component import * diff --git a/b_asic/codegen/vhdl/entity.py b/b_asic/codegen/vhdl/entity.py index 4ccbd28d21db58fbf31d245542485a2d4b5e4871..c52f85842e533f15c92ecca68c99e360d835b76a 100644 --- a/b_asic/codegen/vhdl/entity.py +++ b/b_asic/codegen/vhdl/entity.py @@ -1,6 +1,7 @@ """ Module for code generation of VHDL entity declarations """ + from typing import Set, TextIO from b_asic.codegen.vhdl import VHDL_TAB, write_lines diff --git a/b_asic/core_operations.py b/b_asic/core_operations.py index b83baa723afd21ecfbc6682c6aafdef1e1091115..869f5e8f9d7cd6de9fd494c9ec1e1b671f878ea3 100644 --- a/b_asic/core_operations.py +++ b/b_asic/core_operations.py @@ -73,6 +73,7 @@ class Constant(AbstractOperation): def __str__(self) -> str: return f"{self.value}" + class Addition(AbstractOperation): """ Binary addition operation. @@ -240,6 +241,7 @@ class AddSub(AbstractOperation): ======== Addition, Subtraction """ + is_linear = True def __init__( @@ -317,6 +319,7 @@ class Multiplication(AbstractOperation): ======== ConstantMultiplication """ + is_swappable = True def __init__( @@ -450,6 +453,7 @@ class Min(AbstractOperation): ======== Max """ + is_swappable = True def __init__( @@ -515,6 +519,7 @@ class Max(AbstractOperation): ======== Min """ + is_swappable = True def __init__( @@ -729,6 +734,7 @@ class ConstantMultiplication(AbstractOperation): -------- Multiplication """ + is_linear = True def __init__( @@ -802,6 +808,7 @@ class Butterfly(AbstractOperation): execution_time : int, optional Operation execution time (time units before operator can be reused). """ + is_linear = True def __init__( @@ -865,6 +872,7 @@ class MAD(AbstractOperation): Multiplication Addition """ + is_swappable = True def __init__( @@ -1196,6 +1204,7 @@ class Shift(AbstractOperation): raise TypeError("value must be an int") self.set_param("value", value) + class Sink(AbstractOperation): r""" Sink operation. diff --git a/b_asic/gui_utils/color_button.py b/b_asic/gui_utils/color_button.py index 725ddda151abc09b2aca2e325cbbb3a158476956..5f753e9292ccb84c8655ed0982f3cac90eb0f7d8 100644 --- a/b_asic/gui_utils/color_button.py +++ b/b_asic/gui_utils/color_button.py @@ -1,6 +1,7 @@ """ Qt button for use in preference dialogs, selecting color. """ + from qtpy.QtCore import Qt, Signal from qtpy.QtGui import QColor from qtpy.QtWidgets import QColorDialog, QPushButton diff --git a/b_asic/port.py b/b_asic/port.py index 911634cee32efe41e81fde325edf1d22b84b1de6..e0eb028f9c2ba1e8ccfe25faf881f48fef3b6a3c 100644 --- a/b_asic/port.py +++ b/b_asic/port.py @@ -347,6 +347,7 @@ class InputPort(AbstractPort): Returns the input port of the first delay element in the chain. """ from b_asic.special_operations import Delay + if not isinstance(number, int) or number < 0: raise TypeError("Number of delays must be a positive integer") tmp_signal = None diff --git a/b_asic/save_load_structure.py b/b_asic/save_load_structure.py index 1dccc40b560696bffa217b5a0ea96ceec88b868f..58497f4dcc6404434f5b5df07307f715fc8c3574 100644 --- a/b_asic/save_load_structure.py +++ b/b_asic/save_load_structure.py @@ -63,9 +63,11 @@ def sfg_to_python( if attr != "latency" and hasattr(comp, attr) } params = { - attr: getattr(comp, attr) - if not isinstance(getattr(comp, attr), str) - else f'"{getattr(comp, attr)}"' + attr: ( + getattr(comp, attr) + if not isinstance(getattr(comp, attr), str) + else f'"{getattr(comp, attr)}"' + ) for attr in params_filtered } params = {k: v for k, v in params.items() if v} @@ -153,9 +155,11 @@ def python_to_sfg(path: str) -> Tuple[SFG, Dict[str, Tuple[int, int]]]: exec(code, globals(), locals()) return ( - locals()["prop"]["name"] - if "prop" in locals() - else [v for k, v in locals().items() if isinstance(v, SFG)][0], + ( + locals()["prop"]["name"] + if "prop" in locals() + else [v for k, v in locals().items() if isinstance(v, SFG)][0] + ), locals()["positions"] if "positions" in locals() else {}, ) diff --git a/b_asic/scheduler_gui/__init__.py b/b_asic/scheduler_gui/__init__.py index fa401de50874f25c76ba2bd1dc2aa7d3bf7ca715..65a54cad1b64720f0fdc55740e91a90c1593dc30 100644 --- a/b_asic/scheduler_gui/__init__.py +++ b/b_asic/scheduler_gui/__init__.py @@ -3,6 +3,7 @@ B-ASIC Scheduler-gui Module. Graphical user interface for B-ASIC scheduler. """ + from b_asic.scheduler_gui.main_window import start_scheduler __all__ = ['start_scheduler'] diff --git a/b_asic/scheduler_gui/scheduler_event.py b/b_asic/scheduler_gui/scheduler_event.py index d11df3465833b7ccfcc9178f1a8cd31085392b49..6df2b67917ba4103536ad4216370b2f3bb194307 100644 --- a/b_asic/scheduler_gui/scheduler_event.py +++ b/b_asic/scheduler_gui/scheduler_event.py @@ -69,12 +69,10 @@ class SchedulerEvent: # PyQt5 # Filters # ########### @overload - def installSceneEventFilters(self, filterItems: QGraphicsItem) -> None: - ... + def installSceneEventFilters(self, filterItems: QGraphicsItem) -> None: ... @overload - def installSceneEventFilters(self, filterItems: List[QGraphicsItem]) -> None: - ... + def installSceneEventFilters(self, filterItems: List[QGraphicsItem]) -> None: ... def installSceneEventFilters(self, filterItems) -> None: """ @@ -88,12 +86,10 @@ class SchedulerEvent: # PyQt5 item.installSceneEventFilter(self) @overload - def removeSceneEventFilters(self, filterItems: QGraphicsItem) -> None: - ... + def removeSceneEventFilters(self, filterItems: QGraphicsItem) -> None: ... @overload - def removeSceneEventFilters(self, filterItems: List[QGraphicsItem]) -> None: - ... + def removeSceneEventFilters(self, filterItems: List[QGraphicsItem]) -> None: ... def removeSceneEventFilters(self, filterItems) -> None: """ diff --git a/b_asic/scheduler_gui/signal_item.py b/b_asic/scheduler_gui/signal_item.py index ccb065dfdd66a5ce9ccd409777c0fe3c9b48e99f..723bf228c22daee09108097406128870ae4aa6e6 100644 --- a/b_asic/scheduler_gui/signal_item.py +++ b/b_asic/scheduler_gui/signal_item.py @@ -5,7 +5,6 @@ Contains the scheduler_gui SignalItem class for drawing and maintaining a signal in the schedule. """ - from typing import TYPE_CHECKING, cast from qtpy.QtCore import QPointF diff --git a/b_asic/sfg_generators.py b/b_asic/sfg_generators.py index 1f1bf2c701ee737956b2af4f62e600368053f546..051249ca029ee745238665e9aee02c3e4fffa424 100644 --- a/b_asic/sfg_generators.py +++ b/b_asic/sfg_generators.py @@ -3,6 +3,7 @@ B-ASIC signal flow graph generators. This module contains a number of functions generating SFGs for specific functions. """ + from typing import Dict, Optional, Sequence, Union import numpy as np diff --git a/b_asic/signal.py b/b_asic/signal.py index df04fadcb46ab56bd233e972f4aa8b61b5a38eb1..d755bfd50cb22920231a7537a63f22868de2682a 100644 --- a/b_asic/signal.py +++ b/b_asic/signal.py @@ -3,6 +3,7 @@ B-ASIC Signal Module. Contains the class for representing the connections between operations. """ + from typing import TYPE_CHECKING, Iterable, Optional, Union from b_asic.graph_component import AbstractGraphComponent, GraphComponent diff --git a/b_asic/wdf_operations.py b/b_asic/wdf_operations.py index 95213e83a64ae2418e74b19c78607c122755c626..027a1601a3d88bc34a02da493ddb7a81b441e7ee 100644 --- a/b_asic/wdf_operations.py +++ b/b_asic/wdf_operations.py @@ -3,6 +3,7 @@ B-ASIC Core Operations Module. Contains wave digital filter adaptors. """ + from typing import Dict, Iterable, Optional, Tuple from b_asic.graph_component import Name, TypeName @@ -21,6 +22,7 @@ class SymmetricTwoportAdaptor(AbstractOperation): y_1 & = & x_0 + \text{value}\times\left(x_1 - x_0\right) \end{eqnarray} """ + is_linear = True is_swappable = True @@ -91,6 +93,7 @@ class SeriesTwoportAdaptor(AbstractOperation): Port 1 is the dependent port. """ + is_linear = True is_swappable = True @@ -166,6 +169,7 @@ class ParallelTwoportAdaptor(AbstractOperation): Port 1 is the dependent port. """ + is_linear = True is_swappable = True @@ -242,6 +246,7 @@ class SeriesThreeportAdaptor(AbstractOperation): Port 2 is the dependent port. """ + is_linear = True is_swappable = True @@ -312,6 +317,7 @@ class ReflectionFreeSeriesThreeportAdaptor(AbstractOperation): Port 1 is the reflection-free port and port 2 is the dependent port. """ + is_linear = True is_swappable = True diff --git a/examples/introduction.py b/examples/introduction.py index 16778e30853cd38c314739bc59316d9449f2c0d0..0caa0bd038a8a26fb86b9e880f86fcb0504294e4 100644 --- a/examples/introduction.py +++ b/examples/introduction.py @@ -3,6 +3,7 @@ Introduction example for the TSTE87 course ========================================== """ + from b_asic.core_operations import Addition, ConstantMultiplication from b_asic.signal_flow_graph import SFG from b_asic.special_operations import Delay, Input, Output diff --git a/examples/schedulingexample.py b/examples/schedulingexample.py index 316631946effd70878e841e08b2b66c6a658d701..f68c42a62c06ddfc65083e1801ebaff459ab349d 100644 --- a/examples/schedulingexample.py +++ b/examples/schedulingexample.py @@ -14,6 +14,7 @@ Node numbering from the original SFG used with the Matlab toolbox:: sfg=addoperand(sfg,'delay',1,3,4); sfg=addoperand(sfg,'out',1,7); """ + from b_asic.signal_flow_graph import SFG from b_asic.special_operations import Delay, Input, Output diff --git a/examples/thirdorderblwdf.py b/examples/thirdorderblwdf.py index 02b454860d0d2591bf5c42afa91228c554bc3a2f..1915c6021de40ea72ea5eadedd9603270eb81fdf 100644 --- a/examples/thirdorderblwdf.py +++ b/examples/thirdorderblwdf.py @@ -5,6 +5,7 @@ Third-order Bireciprocal LWDF Small bireciprocal lattice wave digital filter. """ + import numpy as np from mplsignal.freq_plots import freqz_fir diff --git a/pyproject.toml b/pyproject.toml index 558e8e9fc516d1587849e835e1240d8e7caa522b..23033b051a6fc4aba2dfdb9f1999c3c4f0b94d5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ ignore_missing_imports = true precision = 2 [tool.ruff] -ignore = ["F403"] +lint.ignore = ["F403"] [tool.typos] -default.extend-identifiers = { addd0 = "addd0", inout = "inout", ArChItEctUrE = "ArChItEctUrE" } +default.extend-identifiers = { addd0 = "addd0", inout = "inout", ArChItEctUrE = "ArChItEctUrE", ser2p = "ser2p", ser3p = "ser3p" } diff --git a/test/fixtures/operation_tree.py b/test/fixtures/operation_tree.py index 0213466801404454c27fb38369d172fa3863358c..23c1179ef7a6c9e093e78defa5a54efe0767901d 100644 --- a/test/fixtures/operation_tree.py +++ b/test/fixtures/operation_tree.py @@ -87,10 +87,10 @@ def butterfly_operation_tree(): *( Butterfly( *(Butterfly(Constant(2), Constant(4), name="bfly3").outputs), - name="bfly2" + name="bfly2", ).outputs ), - name="bfly1" + name="bfly1", ) diff --git a/test/test_gui/twotapfir.py b/test/test_gui/twotapfir.py index e0d7ca6fd9fc3685a961816d84c98744617a9219..44300bb885c4d8ca60c28822fdfd48012a38ff10 100644 --- a/test/test_gui/twotapfir.py +++ b/test/test_gui/twotapfir.py @@ -3,15 +3,8 @@ B-ASIC automatically generated SFG file. Name: twotapfir Last saved: 2023-01-24 14:38:17.654639. """ -from b_asic import ( - SFG, - Addition, - ConstantMultiplication, - Delay, - Input, - Output, - Signal, -) + +from b_asic import SFG, Addition, ConstantMultiplication, Delay, Input, Output, Signal # Inputs: in1 = Input(name="in1") @@ -24,9 +17,7 @@ t1 = Delay(initial_value=0, name="") cmul1 = ConstantMultiplication( value=-0.5, name="cmul1", latency_offsets={'in0': None, 'out0': None} ) -add1 = Addition( - name="add1", latency_offsets={'in0': None, 'in1': None, 'out0': None} -) +add1 = Addition(name="add1", latency_offsets={'in0': None, 'in1': None, 'out0': None}) cmul2 = ConstantMultiplication( value=0.5, name="cmul2", latency_offsets={'in0': None, 'out0': None} ) diff --git a/test/test_operation.py b/test/test_operation.py index dc7ad0b1eee0395bf3d0cb12987426ebc52474c2..ebcd17895a942241d72ad4e7bb3530d39da5eb54 100644 --- a/test/test_operation.py +++ b/test/test_operation.py @@ -1,6 +1,7 @@ """ B-ASIC test suite for the AbstractOperation class. """ + import re import pytest diff --git a/test/test_outputport.py b/test/test_outputport.py index 3480c2ebc85c88a4cc58dd9b377d3d5863995ea2..5ebc5655c2d2c3e08dfec325826cd15e57959fc9 100644 --- a/test/test_outputport.py +++ b/test/test_outputport.py @@ -1,6 +1,7 @@ """ B-ASIC test suite for OutputPort. """ + import pytest from b_asic import Signal diff --git a/test/test_wdf_operations.py b/test/test_wdf_operations.py index be86b53200cd5015553de8ea6d545ac05bdb77d7..c6b30744c7f7aa00eb70c9ed347e3b4b283ccf37 100644 --- a/test/test_wdf_operations.py +++ b/test/test_wdf_operations.py @@ -1,4 +1,5 @@ """B-ASIC test suite for the core operations.""" + import pytest from b_asic.wdf_operations import (