Skip to content

Commit d1ac450

Browse files
committed
Change _RLSortRoots in rlocus.py to placate ruff
1 parent 71ea2d7 commit d1ac450

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

control/rlocus.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)