File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -452,20 +452,18 @@ def _RLSortRoots(roots):
452452 one branch to another."""
453453
454454 sorted = zeros_like (roots )
455- for n , row in enumerate (roots ):
456- if n == 0 :
457- sorted [n , :] = row
458- else :
459- # sort the current row by finding the element with the
460- # smallest absolute distance to each root in the
461- # previous row
462- available = list (range (len (prevrow )))
463- for elem in row :
464- evect = elem - prevrow [available ]
465- ind1 = abs (evect ).argmin ()
466- ind = available .pop (ind1 )
467- sorted [n , ind ] = elem
468- prevrow = sorted [n , :]
455+ sorted [0 ] = roots [0 ]
456+ for n , row in enumerate (roots [1 :], start = 1 ):
457+ # sort the current row by finding the element with the
458+ # smallest absolute distance to each root in the
459+ # previous row
460+ prevrow = sorted [n - 1 ]
461+ available = list (range (len (prevrow )))
462+ for elem in row :
463+ evect = elem - prevrow [available ]
464+ ind1 = abs (evect ).argmin ()
465+ ind = available .pop (ind1 )
466+ sorted [n , ind ] = elem
469467 return sorted
470468
471469
You can’t perform that action at this time.
0 commit comments