diff --git a/b_asic/GUI/arrow.py b/b_asic/GUI/arrow.py index bdabe031322346364fa61d32636bbc7f83c33cc9..7ef81de723ea6bc63a56409ef30543710fa23277 100644 --- a/b_asic/GUI/arrow.py +++ b/b_asic/GUI/arrow.py @@ -85,9 +85,17 @@ class Arrow(QGraphicsPathItem): self.setPen(QPen(LINECOLOR, 3)) source_flipped = self.source.operation.is_flipped() destination_flipped = self.destination.operation.is_flipped() - x0 = self.source.operation.x() + self.source.x() + (PORTWIDTH if not source_flipped else 0) + x0 = ( + self.source.operation.x() + + self.source.x() + + (PORTWIDTH if not source_flipped else 0) + ) y0 = self.source.operation.y() + self.source.y() + PORTHEIGHT / 2 - x1 = self.destination.operation.x() + self.destination.x() + (0 if not destination_flipped else PORTWIDTH) + x1 = ( + self.destination.operation.x() + + self.destination.x() + + (0 if not destination_flipped else PORTWIDTH) + ) y1 = ( self.destination.operation.y() + self.destination.y() diff --git a/b_asic/save_load_structure.py b/b_asic/save_load_structure.py index d0193e5df1c2104e2022f815795992a5fbf9558f..7e8dc8a8ca881f582ca24bddaf7303f97c233b5f 100644 --- a/b_asic/save_load_structure.py +++ b/b_asic/save_load_structure.py @@ -119,6 +119,8 @@ def python_to_sfg(path: str) -> SFG: 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/schedule.py b/b_asic/schedule.py index acddc88d7530b9edf7cc547234800f6d89480b58..4db660c5062b4f7f9cb7d3da0946801639909771 100644 --- a/b_asic/schedule.py +++ b/b_asic/schedule.py @@ -164,7 +164,10 @@ class Schedule: def set_schedule_time(self, time: int) -> "Schedule": if time < self.get_max_end_time(): - raise ValueError( "New schedule time ({time})to short, minimum: ({self.get_max_end_time()}).") + raise ValueError( + "New schedule time ({time})to short, minimum:" + " ({self.get_max_end_time()})." + ) self._schedule_time = time return self diff --git a/b_asic/scheduler_gui/graphics_axes_item.py b/b_asic/scheduler_gui/graphics_axes_item.py index 25297e7e4b3a16b3e52c4d3a14909353f9f3e192..be3446ec67efb25136ee522b707e6188cc002c50 100644 --- a/b_asic/scheduler_gui/graphics_axes_item.py +++ b/b_asic/scheduler_gui/graphics_axes_item.py @@ -63,9 +63,13 @@ class GraphicsAxesItem(QGraphicsItemGroup): """ super().__init__(parent=parent) if width < 0: - raise ValueError(f"'width' greater or equal to 0 expected, got: {width}.") + raise ValueError( + f"'width' greater or equal to 0 expected, got: {width}." + ) if height < 0: - raise ValueError(f"'height' greater or equal to 0 expected, got: {height}.") + raise ValueError( + f"'height' greater or equal to 0 expected, got: {height}." + ) self._width = width self._height = height @@ -152,13 +156,17 @@ class GraphicsAxesItem(QGraphicsItemGroup): def set_height(self, height: int) -> "GraphicsAxesItem": # TODO: implement, docstring if height < 0: - raise ValueError(f"'height' greater or equal to 0 expected, got: {height}.") + raise ValueError( + f"'height' greater or equal to 0 expected, got: {height}." + ) raise NotImplementedError def set_width(self, width: int) -> "GraphicsAxesItem": # TODO: docstring if width < 0: - raise ValueError(f"'width' greater or equal to 0 expected, got: {width}.") + raise ValueError( + f"'width' greater or equal to 0 expected, got: {width}." + ) delta_width = width - self._width diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py index 41d42b13751d2e0c65f917dd24fc0b9c15ee4fdf..55aed0ed54dd1ee5241d763d2307c05c1aa3ad2f 100644 --- a/b_asic/signal_flow_graph.py +++ b/b_asic/signal_flow_graph.py @@ -151,7 +151,9 @@ class SFG(AbstractOperation): if input_signals is not None: for input_index, signal in enumerate(input_signals): if signal in self._original_components_to_new: - raise ValueError(f"Duplicate input signal {signal!r} in SFG") + raise ValueError( + f"Duplicate input signal {signal!r} in SFG" + ) new_input_op = self._add_component_unconnected_copy(Input()) new_signal = self._add_component_unconnected_copy(signal) new_signal.set_source(new_input_op.output(0)) @@ -162,7 +164,9 @@ class SFG(AbstractOperation): if inputs is not None: for input_index, input_op in enumerate(inputs, input_signal_count): if input_op in self._original_components_to_new: - raise ValueError(f"Duplicate input operation {input_op!r} in SFG") + raise ValueError( + f"Duplicate input operation {input_op!r} in SFG" + ) new_input_op = self._add_component_unconnected_copy(input_op) for signal in input_op.output(0).signals: assert signal not in self._original_components_to_new, ( @@ -199,7 +203,9 @@ class SFG(AbstractOperation): outputs, output_signal_count ): if output_op in self._original_components_to_new: - raise ValueError(f"Duplicate output operation {output_op!r} in SFG") + raise ValueError( + f"Duplicate output operation {output_op!r} in SFG" + ) new_output_op = self._add_component_unconnected_copy(output_op) for signal in output_op.input(0).signals: diff --git a/test/test_gui.py b/test/test_gui.py index f0b582d3779618702a81d0b81fa66511508c7dc4..3e15726f70b6c2d1f9e23e02d20dda692d4dd80d 100644 --- a/test/test_gui.py +++ b/test/test_gui.py @@ -51,7 +51,7 @@ def test_sfg_invalidated_by_remove_of_operation(qtbot, datadir): dragbutton = widget.operationDragDict[op[0]] dragbutton.remove() assert not widget.sfg_dict - assert ops_before_remove -1 == len(widget.operationDragDict) + assert ops_before_remove - 1 == len(widget.operationDragDict) widget.exit_app() @@ -90,13 +90,21 @@ def test_select_operation(qtbot, datadir): assert len(widget.pressed_operations) == 1 # Control-click first - qtbot.mouseClick(dragbutton, QtCore.Qt.MouseButton.LeftButton, QtCore.Qt.KeyboardModifier.ControlModifier) + qtbot.mouseClick( + dragbutton, + QtCore.Qt.MouseButton.LeftButton, + QtCore.Qt.KeyboardModifier.ControlModifier, + ) assert dragbutton2.pressed assert dragbutton.pressed assert len(widget.pressed_operations) == 2 # Control-click second - qtbot.mouseClick(dragbutton2, QtCore.Qt.MouseButton.LeftButton, QtCore.Qt.KeyboardModifier.ControlModifier) + qtbot.mouseClick( + dragbutton2, + QtCore.Qt.MouseButton.LeftButton, + QtCore.Qt.KeyboardModifier.ControlModifier, + ) assert not dragbutton2.pressed assert dragbutton.pressed assert len(widget.pressed_operations) == 1