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

Fix string formatting

parent 692aa02c
No related branches found
No related tags found
No related merge requests found
Pipeline #88038 passed
...@@ -80,7 +80,7 @@ class PropertiesWindow(QDialog): ...@@ -80,7 +80,7 @@ class PropertiesWindow(QDialog):
x += 1 x += 1
y = 0 y = 0
input_label = QLabel("in" + str(i)) input_label = QLabel(f"in{i}")
input_layout.addWidget(input_label) input_layout.addWidget(input_label)
input_value = QLineEdit() input_value = QLineEdit()
try: try:
...@@ -93,7 +93,7 @@ class PropertiesWindow(QDialog): ...@@ -93,7 +93,7 @@ class PropertiesWindow(QDialog):
int_valid.setBottom(-1) int_valid.setBottom(-1)
input_value.setValidator(int_valid) input_value.setValidator(int_valid)
input_value.setFixedWidth(50) input_value.setFixedWidth(50)
self.latency_fields["in" + str(i)] = input_value self.latency_fields[f"in{i}"] = input_value
input_layout.addWidget(input_value) input_layout.addWidget(input_value)
input_layout.addStretch() input_layout.addStretch()
input_layout.setSpacing(10) input_layout.setSpacing(10)
...@@ -119,7 +119,7 @@ class PropertiesWindow(QDialog): ...@@ -119,7 +119,7 @@ class PropertiesWindow(QDialog):
x += 1 x += 1
y = 0 y = 0
input_label = QLabel("out" + str(i)) input_label = QLabel(f"out{i}")
input_layout.addWidget(input_label) input_layout.addWidget(input_label)
input_value = QLineEdit() input_value = QLineEdit()
try: try:
...@@ -132,7 +132,7 @@ class PropertiesWindow(QDialog): ...@@ -132,7 +132,7 @@ class PropertiesWindow(QDialog):
int_valid.setBottom(-1) int_valid.setBottom(-1)
input_value.setValidator(int_valid) input_value.setValidator(int_valid)
input_value.setFixedWidth(50) input_value.setFixedWidth(50)
self.latency_fields["out" + str(i)] = input_value self.latency_fields[f"out{i}"] = input_value
input_layout.addWidget(input_value) input_layout.addWidget(input_value)
input_layout.addStretch() input_layout.addStretch()
input_layout.setSpacing(10) input_layout.setSpacing(10)
......
...@@ -80,10 +80,10 @@ class SimulateSFGWindow(QDialog): ...@@ -80,10 +80,10 @@ class SimulateSFGWindow(QDialog):
x += 1 x += 1
y = 0 y = 0
input_label = QLabel("in" + str(i)) input_label = QLabel(f"in{i}")
input_layout.addWidget(input_label) input_layout.addWidget(input_label)
input_value = QLineEdit() input_value = QLineEdit()
input_value.setPlaceholderText("e.g 0, 0, 0") input_value.setPlaceholderText("e.g. 0, 0, 0")
input_value.setFixedWidth(100) input_value.setFixedWidth(100)
input_layout.addWidget(input_value) input_layout.addWidget(input_value)
input_layout.addStretch() input_layout.addStretch()
......
...@@ -877,10 +877,10 @@ class AbstractOperation(Operation, AbstractGraphComponent): ...@@ -877,10 +877,10 @@ class AbstractOperation(Operation, AbstractGraphComponent):
latency_offsets = {} latency_offsets = {}
for i, inp in enumerate(self.inputs): for i, inp in enumerate(self.inputs):
latency_offsets["in" + str(i)] = inp.latency_offset latency_offsets[f"in{i}"] = inp.latency_offset
for i, outp in enumerate(self.outputs): for i, outp in enumerate(self.outputs):
latency_offsets["out" + str(i)] = outp.latency_offset latency_offsets[f"out{i}"] = outp.latency_offset
return latency_offsets return latency_offsets
......
...@@ -89,11 +89,7 @@ def sfg_to_python(sfg: SFG, counter: int = 0, suffix: str = None) -> str: ...@@ -89,11 +89,7 @@ def sfg_to_python(sfg: SFG, counter: int = 0, suffix: str = None) -> str:
"[" + ", ".join(op.graph_id for op in sfg.output_operations) + "]" "[" + ", ".join(op.graph_id for op in sfg.output_operations) + "]"
) )
sfg_name = ( sfg_name = (
sfg.name sfg.name if sfg.name else f"sfg{counter}" if counter > 0 else "sfg"
if sfg.name
else "sfg" + str(counter)
if counter > 0
else "sfg"
) )
sfg_name_var = sfg_name.replace(" ", "_") sfg_name_var = sfg_name.replace(" ", "_")
result += ( result += (
......
...@@ -289,7 +289,7 @@ class SFG(AbstractOperation): ...@@ -289,7 +289,7 @@ class SFG(AbstractOperation):
string_io.write(line) string_io.write(line)
for operation in self.get_operations_topological_order(): for operation in self.get_operations_topological_order():
string_io.write(str(operation) + "\n") string_io.write(f"{operation}\n")
string_io.write(line) string_io.write(line)
...@@ -720,16 +720,15 @@ class SFG(AbstractOperation): ...@@ -720,16 +720,15 @@ class SFG(AbstractOperation):
# Creates nodes for each output port in the precedence list # Creates nodes for each output port in the precedence list
for i in range(len(p_list)): for i in range(len(p_list)):
ports = p_list[i] ports = p_list[i]
with pg.subgraph(name="cluster_" + str(i)) as sub: with pg.subgraph(name=f"cluster_{i}") as sub:
sub.attr(label="N" + str(i + 1)) sub.attr(label=f"N{i+1}")
for port in ports: for port in ports:
portstr = f"{port.operation.graph_id}.{port.index}"
if port.operation.output_count > 1: if port.operation.output_count > 1:
sub.node( sub.node(portstr)
port.operation.graph_id + "." + str(port.index)
)
else: else:
sub.node( sub.node(
port.operation.graph_id + "." + str(port.index), portstr,
label=port.operation.graph_id, label=port.operation.graph_id,
) )
# Creates edges for each output port and creates nodes for each operation and edges for them as well # Creates edges for each output port and creates nodes for each operation and edges for them as well
...@@ -747,7 +746,7 @@ class SFG(AbstractOperation): ...@@ -747,7 +746,7 @@ class SFG(AbstractOperation):
else: else:
dest_node = signal.destination.operation.graph_id dest_node = signal.destination.operation.graph_id
dest_label = signal.destination.operation.graph_id dest_label = signal.destination.operation.graph_id
node_node = port.operation.graph_id + "." + str(port.index) node_node = f"{port.operation.graph_id}.{port.index}"
pg.edge(node_node, dest_node) pg.edge(node_node, dest_node)
pg.node(dest_node, label=dest_label, shape="square") pg.node(dest_node, label=dest_label, shape="square")
if port.operation.type_name() == Delay.type_name(): if port.operation.type_name() == Delay.type_name():
...@@ -755,7 +754,7 @@ class SFG(AbstractOperation): ...@@ -755,7 +754,7 @@ class SFG(AbstractOperation):
else: else:
source_node = port.operation.graph_id source_node = port.operation.graph_id
source_label = port.operation.graph_id source_label = port.operation.graph_id
node_node = port.operation.graph_id + "." + str(port.index) node_node = f"{port.operation.graph_id}.{port.index}"
pg.edge(source_node, node_node) pg.edge(source_node, node_node)
pg.node(source_node, label=source_label, shape="square") pg.node(source_node, label=source_label, shape="square")
......
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