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

Reformat code

parent 64fdf6c6
No related branches found
No related tags found
No related merge requests found
Pipeline #88141 passed
......@@ -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()
......
......@@ -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 {},
)
......@@ -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
......
......@@ -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
......
......@@ -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:
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment