Reduce for loop nesting

This commit is contained in:
mvdbeek
2024-04-04 16:14:55 +02:00
parent 023178db2f
commit b825f798ca
+3 -3
View File
@@ -2,6 +2,7 @@
workflow steps.
"""
import math
from itertools import chain
from galaxy.util.topsort import (
CycleError,
@@ -65,9 +66,8 @@ def order_workflow_steps(steps, comments):
min_top = min(min_top_comments, min_top)
# normalize comments by min_left and min_top
for comment_list in [sortable_comments, freehand_comments]:
for comment in comment_list:
comment.position = [comment.position[0] - min_left, comment.position[1] - min_top]
for comment in chain(sortable_comments, freehand_comments):
comment.position = [comment.position[0] - min_left, comment.position[1] - min_top]
# order by Euclidean distance to the origin
sortable_comments.sort(key=lambda comment: math.sqrt(comment.position[0] ** 2 + comment.position[1] ** 2))