mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-19 10:51:34 +08:00
Reduce for loop nesting
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user