diff --git a/b_asic/GUI/simulate_sfg_window.py b/b_asic/GUI/simulate_sfg_window.py index 9cb69e26ad6fa7fe5863be62085cc91595bb0e28..847beb05b561c243046277de252d8c39465214a9 100644 --- a/b_asic/GUI/simulate_sfg_window.py +++ b/b_asic/GUI/simulate_sfg_window.py @@ -109,7 +109,7 @@ class SimulateSFGWindow(QDialog): return _input_values def save_properties(self): - for sfg, properties in self.input_fields.items(): + for sfg, _properties in self.input_fields.items(): input_values = self.parse_input_values(widget.text().split(",") if widget.text() else [0] for widget in self.input_fields[sfg]["input_values"]) if max(len(list_) for list_ in input_values) != min(len(list_) for list_ in input_values): self._window.logger.error(f"Minimum length of input lists are not equal to maximum length of input lists: {max(len(list_) for list_ in input_values)} != {min(len(list_) for list_ in input_values)}.") diff --git a/b_asic/GUI/utils.py b/b_asic/GUI/utils.py index f98ec70c9e35f6cf8aa65d37d7a79b0bfc16e0d1..355a559210535cabc1a0b40f8bece8b0d0afb380 100644 --- a/b_asic/GUI/utils.py +++ b/b_asic/GUI/utils.py @@ -5,9 +5,10 @@ def handle_error(fn): def wrapper(self, *args, **kwargs): try: return fn(self, *args, **kwargs) - except Exception as e: + except Exception: self._window.logger.error(f"Unexpected error: {format_exc()}") - QErrorMessage(self._window).showMessage(f"Unexpected error: {format_exc()}") + QErrorMessage(self._window).showMessage( + f"Unexpected error: {format_exc()}") return wrapper @@ -17,4 +18,4 @@ def decorate_class(decorator): if callable(getattr(cls, attr)): setattr(cls, attr, decorator(getattr(cls, attr))) return cls - return decorate \ No newline at end of file + return decorate diff --git a/b_asic/operation.py b/b_asic/operation.py index 293b47526bfb8f216e13bc0537e1360040d2f01e..dd4c9fc786a7e76411061d8dce4ba3343353b44c 100644 --- a/b_asic/operation.py +++ b/b_asic/operation.py @@ -565,7 +565,7 @@ class AbstractOperation(Operation, AbstractGraphComponent): raise IndexError( f"Output index out of range (expected 0-{self.output_count - 1}, got {output_index})") # By default, assume each output depends on all inputs. - return [i for i in range(self.input_count)] + return list(range(self.input_count)) @property def neighbors(self) -> Iterable[GraphComponent]: diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py index 42c0cdefd3af54add2ff13eae402ba8ef2a56a81..9d73629274fd0dd791c6a395f9cad92719bedcb3 100644 --- a/b_asic/signal_flow_graph.py +++ b/b_asic/signal_flow_graph.py @@ -308,7 +308,7 @@ class SFG(AbstractOperation): input_op: index for index, input_op in enumerate(self._input_operations)} output_op = self._output_operations[output_index] queue = deque([output_op]) - visited = set([output_op]) + visited = {output_op} while queue: op = queue.popleft() if isinstance(op, Input): @@ -598,7 +598,7 @@ class SFG(AbstractOperation): no_inputs_queue) > 0, "Illegal SFG state, dangling signals in SFG." first_op = no_inputs_queue.popleft() - visited = set([first_op]) + visited = {first_op} p_queue = PriorityQueue() p_queue_entry_num = it.count() # Negative priority as max-heap popping is wanted diff --git a/test/conftest.py b/test/conftest.py index 63cf5ce1d0eb3d6652dc4eee14113aba98a3f2fc..48b49489424817e1439f6b2b6eb3d7cd63b29a75 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -2,4 +2,4 @@ from test.fixtures.signal import signal, signals from test.fixtures.operation_tree import * from test.fixtures.port import * from test.fixtures.signal_flow_graph import * -import pytest \ No newline at end of file +import pytest diff --git a/test/fixtures/operation_tree.py b/test/fixtures/operation_tree.py index 695979c65ab56eda3baf992b3b99963ee1fe7c9a..7a04400969874ab49e6c024420aa9234c81a3b93 100644 --- a/test/fixtures/operation_tree.py +++ b/test/fixtures/operation_tree.py @@ -71,7 +71,7 @@ def butterfly_operation_tree(): v ^ v ^ v ^ butterfly butterfly butterfly ^ v ^ v ^ v - | | | | | | + | | | | | | 4 ---+ +--- (2 - 4) ---+ +--- (6 - (-2)) ---+ +--- (4 - 8) ---> out2 = -4 """ return Butterfly(*(Butterfly(*(Butterfly(Constant(2), Constant(4), name="bfly3").outputs), name="bfly2").outputs), name="bfly1") diff --git a/test/fixtures/signal_flow_graph.py b/test/fixtures/signal_flow_graph.py index a2c25ec9b10083b08c46543c7a5bfc30607560ef..f80e10a07abb815dbed01b6d4f7ae51458e9a2e7 100644 --- a/test/fixtures/signal_flow_graph.py +++ b/test/fixtures/signal_flow_graph.py @@ -170,7 +170,7 @@ def sfg_custom_operation(): class CustomOperation(AbstractOperation): def __init__(self, src0: Optional[SignalSourceProvider] = None, name: Name = ""): super().__init__(input_count = 1, output_count = 2, name = name, input_sources = [src0]) - + @classmethod def type_name(self) -> TypeName: return "custom" diff --git a/test/test_fast_simulation.py b/test/test_fast_simulation.py index acdea48d2bf51040b59fda5bd99d67ed158a1035..6ddd666d362023760f982a570a106b3ab7cb742f 100644 --- a/test/test_fast_simulation.py +++ b/test/test_fast_simulation.py @@ -91,7 +91,7 @@ class TestRunFor: assert simulation.results["0"][4] == 9 assert simulation.results["1"][4] == 11 - + def test_with_numpy_array_overflow(self, sfg_two_inputs_two_outputs): input0 = np.array([5, 9, 25, -5, 7]) input1 = np.array([7, 3, 3, 54, 2]) @@ -165,7 +165,7 @@ class TestRun: assert output0[0] == 11405 assert output1[0] == 4221 - + def test_accumulator(self, sfg_accumulator): data_in = np.array([5, -2, 25, -6, 7, 0]) reset = np.array([0, 0, 0, 1, 0, 0]) @@ -188,7 +188,7 @@ class TestRun: simulation = FastSimulation(sfg_simple_accumulator, [data_in]) simulation.run() assert list(simulation.results["0"]) == [0, 1, 3, 6, 10, 15, 21, 28, 36, 45] - + def test_simple_filter(self, sfg_simple_filter): input0 = np.array([1, 2, 3, 4, 5]) simulation = FastSimulation(sfg_simple_filter, [input0]) @@ -210,7 +210,7 @@ class TestLarge: sfg = SFG(outputs=[Output(prev_op)]) simulation = FastSimulation(sfg, []) assert simulation.step()[0] == 2000 - + def test_1k_subtractions(self): prev_op = Subtraction(Constant(0), Constant(2)) for _ in range(999): @@ -218,7 +218,7 @@ class TestLarge: sfg = SFG(outputs=[Output(prev_op)]) simulation = FastSimulation(sfg, []) assert simulation.step()[0] == -2000 - + def test_1k_butterfly(self): prev_op_add = Addition(Constant(1), Constant(1)) prev_op_sub = Subtraction(Constant(-1), Constant(1)) @@ -229,4 +229,4 @@ class TestLarge: butterfly = Butterfly(prev_op_add, prev_op_sub) sfg = SFG(outputs=[Output(butterfly.output(0)), Output(butterfly.output(1))]) simulation = FastSimulation(sfg, []) - assert list(simulation.step()) == [0, 2000] \ No newline at end of file + assert list(simulation.step()) == [0, 2000] diff --git a/test/test_sfg.py b/test/test_sfg.py index 0a5fe96ed0f24607efdcacefdb1a5275cf229d83..d2d1c0b1fde9529f978f558b140e7ec43bbba230 100644 --- a/test/test_sfg.py +++ b/test/test_sfg.py @@ -228,7 +228,7 @@ class TestComponents: mac_sfg = SFG(inputs=[inp1, inp2], outputs=[out1], name="mac_sfg") - assert set([comp.name for comp in mac_sfg.components]) == { + assert {comp.name for comp in mac_sfg.components} == { "INP1", "INP2", "INP3", "ADD1", "ADD2", "MUL1", "OUT1", "S1", "S2", "S3", "S4", "S5", "S6", "S7"} diff --git a/test/test_signal.py b/test/test_signal.py index 42086d4d5fb68eb861eee72d1351931d473b480b..3a681b321e995586bbf30d7ab1f984e475ef6169 100644 --- a/test/test_signal.py +++ b/test/test_signal.py @@ -85,4 +85,4 @@ class Bits: def test_bits_pos_then_none(self, signal): signal.bits = 10 signal.bits = None - assert signal.bits is None \ No newline at end of file + assert signal.bits is None diff --git a/test/test_simulation.py b/test/test_simulation.py index 8ca19e47ba862d269402cce9789e12aa795fcf83..b5c46721e79544a1675eae010bacf18eb28319a1 100644 --- a/test/test_simulation.py +++ b/test/test_simulation.py @@ -91,7 +91,7 @@ class TestRunFor: assert simulation.results["0"][4] == 9 assert simulation.results["1"][4] == 11 - + def test_with_numpy_array_overflow(self, sfg_two_inputs_two_outputs): input0 = np.array([5, 9, 25, -5, 7]) input1 = np.array([7, 3, 3, 54, 2]) @@ -165,7 +165,7 @@ class TestRun: assert output0[0] == 11405 assert output1[0] == 4221 - + def test_accumulator(self, sfg_accumulator): data_in = np.array([5, -2, 25, -6, 7, 0]) reset = np.array([0, 0, 0, 1, 0, 0]) @@ -188,7 +188,7 @@ class TestRun: simulation = Simulation(sfg_simple_accumulator, [data_in]) simulation.run() assert list(simulation.results["0"]) == [0, 1, 3, 6, 10, 15, 21, 28, 36, 45] - + def test_simple_filter(self, sfg_simple_filter): input0 = np.array([1, 2, 3, 4, 5]) simulation = Simulation(sfg_simple_filter, [input0])