8000 rename mymat to root_array for clarity · python-control/python-control@15543ff · GitHub
[go: up one dir, main page]

Skip to content

Commit 15543ff

Browse files
committed
rename mymat to root_array for clarity
1 parent eadd496 commit 15543ff

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

control/rlocus.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ def _default_gains(num, den, xlim, ylim, zoom_xlim=None, zoom_ylim=None):
286286
kvect = np.hstack((np.linspace(0, kmax, 50), np.real(k_break)))
287287
kvect.sort()
288288

289-
mymat = _RLFindRoots(num, den, kvect)
290-
mymat = _RLSortRoots(mymat)
289+
root_array = _RLFindRoots(num, den, kvect)
290+
root_array = _RLSortRoots(root_array)
291291
open_loop_poles = den.roots
292292
open_loop_zeros = num.roots
293293

@@ -297,13 +297,13 @@ def _default_gains(num, den, xlim, ylim, zoom_xlim=None, zoom_ylim=None):
297297
open_loop_zeros,
298298
np.ones(open_loop_poles.size - open_loop_zeros.size)
299299
* open_loop_zeros[-1])
300-
mymat_xl = np.append(mymat, open_loop_zeros_xl)
300+
root_array_xl = np.append(root_array, open_loop_zeros_xl)
301301
else:
302-
mymat_xl = mymat
302+
root_array_xl = root_array
303303
singular_points = np.concatenate((num.roots, den.roots), axis=0)
304304
important_points = np.concatenate((singular_points, real_break), axis=0)
305305
important_points = np.concatenate((important_points, np.zeros(2)), axis=0)
306-
mymat_xl = np.append(mymat_xl, important_points)
306+
root_array_xl = np.append(root_array_xl, important_points)
307307

308308
false_gain = float(den.coeffs[0]) / float(num.coeffs[0])
309309
if false_gain < 0 and not den.order > num.order:
@@ -312,27 +312,27 @@ def _default_gains(num, den, xlim, ylim, zoom_xlim=None, zoom_ylim=None):
312312
"with equal order of numerator and denominator.")
313313

314314
if xlim is None and false_gain > 0:
315-
x_tolerance = 0.05 * (np.max(np.real(mymat_xl))
316-
- np.min(np.real(mymat_xl)))
317-
xlim = _ax_lim(mymat_xl)
315+
x_tolerance = 0.05 * (np.max(np.real(root_array_xl))
316+
- np.min(np.real(root_array_xl)))
317+
xlim = _ax_lim(root_array_xl)
318318
elif xlim is None and false_gain < 0:
319319
axmin = np.min(np.real(important_points)) \
320320
- (np.max(np.real(important_points))
321321
- np.min(np.real(important_points)))
322-
axmin = np.min(np.array([axmin, np.min(np.real(mymat_xl))]))
322+
axmin = np.min(np.array([axmin, np.min(np.real(root_array_xl))]))
323323
axmax = np.max(np.real(important_points)) \
324324
+ np.max(np.real(important_points)) \
325325
- np.min(np.real(important_points))
326-
axmax = np.max(np.array([axmax, np.max(np.real(mymat_xl))]))
326+
axmax = np.max(np.array([axmax, np.max(np.real(root_array_xl))]))
327327
xlim = [axmin, axmax]
328328
x_tolerance = 0.05 * (axmax - axmin)
329329
else:
330330
x_tolerance = 0.05 * (xlim[1] - xlim[0])
331331

332332
if ylim is None:
333-
y_tolerance = 0.05 * (np.max(np.imag(mymat_xl))
334-
- np.min(np.imag(mymat_xl)))
335-
ylim = _ax_lim(mymat_xl * 1j)
333+
y_tolerance = 0.05 * (np.max(np.imag(root_array_xl))
334+
- np.min(np.imag(root_array_xl)))
335+
ylim = _ax_lim(root_array_xl * 1j)
336336
else:
337337
y_tolerance = 0.05 * (ylim[1] - ylim[0])
338338

@@ -345,7 +345,7 @@ def _default_gains(num, den, xlim, ylim, zoom_xlim=None, zoom_ylim=None):
345345
tolerance = x_tolerance
346346
else:
347347
tolerance = np.min([x_tolerance, y_tolerance])
348-
indexes_too_far = _indexes_filt(mymat, tolerance, zoom_xlim, zoom_ylim)
348+
indexes_too_far = _indexes_filt(root_array, tolerance, zoom_xlim, zoom_ylim)
349349

350350
# Add more points into the root locus for points that are too far apart
351351
while len(indexes_too_far) > 0 and kvect.size < 5000:
@@ -354,27 +354,27 @@ def _default_gains(num, den, xlim, ylim, zoom_xlim=None, zoom_ylim=None):
354354
new_gains = np.linspace(kvect[index], kvect[index + 1], 5)
355355
new_points = _RLFindRoots(num, den, new_gains[1:4])
356356
kvect = np.insert(kvect, index + 1, new_gains[1:4])
357-
mymat = np.insert(mymat, index + 1, new_points, axis=0)
357+
root_array = np.insert(root_array, index + 1, new_points, axis=0)
358358

359-
mymat = _RLSortRoots(mymat)
360-
indexes_too_far = _indexes_filt(mymat, tolerance, zoom_xlim, zoom_ylim)
359+
root_array = _RLSortRoots(root_array)
360+
indexes_too_far = _indexes_filt(root_array, tolerance, zoom_xlim, zoom_ylim)
361361

362362
new_gains = kvect[-1] * np.hstack((np.logspace(0, 3, 4)))
363363
new_points = _RLFindRoots(num, den, new_gains[1:4])
364364
kvect = np.append(kvect, new_gains[1:4])
365-
mymat = np.concatenate((mymat, new_points), axis=0)
366-
mymat = _RLSortRoots(mymat)
367-
return kvect, mymat, xlim, ylim
365+
root_array = np.concatenate((root_array, new_points), axis=0)
366+
root_array = _RLSortRoots(root_array)
367+
return kvect, root_array, xlim, ylim
368368

369369

370-
def _indexes_filt(mymat, tolerance, zoom_xlim=None, zoom_ylim=None):
370+
def _indexes_filt(root_array, tolerance, zoom_xlim=None, zoom_ylim=None):
371371
"""Calculate the distance between points and return the indexes.
372372
373373
Filter the indexes so only the resolution of points within the xlim and
374374
ylim is improved when zoom is used.
375375
376376
"""
377-
distance_points = np.abs(np.diff(mymat, axis=0))
377+
distance_points = np.abs(np.diff(root_array, axis=0))
378378
indexes_too_far = list(np.unique(np.where(distance_points > tolerance)[0]))
379379

380380
if zoom_xlim is not None and zoom_ylim is not None:
@@ -386,23 +386,23 @@ def _indexes_filt(mymat, tolerance, zoom_xlim=None, zoom_ylim=None):
386386
indexes_too_far_filtered = []
387387

388388
for index in indexes_too_far_zoom:
389-
for point in mymat[index]:
389+
for point in root_array[index]:
390390
if (zoom_xlim[0] <= point.real <= zoom_xlim[1]) and \
391391
(zoom_ylim[0] <= point.imag <= zoom_ylim[1]):
392392
indexes_too_far_filtered.append(index)
393393
break
394394

395395
# Check if zoom box is not overshot & insert points where neccessary
396-
if len(indexes_too_far_filtered) == 0 and len(mymat) < 500:
396+
if len(indexes_too_far_filtered) == 0 and len(root_array) < 500:
397397
limits = [zoom_xlim[0], zoom_xlim[1], zoom_ylim[0], zoom_ylim[1]]
398398
for index, limit in enumerate(limits):
399399
if index <= 1:
400-
asign = np.sign(real(mymat)-limit)
400+
asign = np.sign(real(root_array)-limit)
401401
else:
402-
asign = np.sign(imag(mymat) - limit)
402+
asign = np.sign(imag(root_array) - limit)
403403
signchange = ((np.roll(asign, 1, axis=0)
404404
- asign) != 0).astype(int)
405-
signchange[0] = np.zeros((len(mymat[0])))
405+
signchange[0] = np.zeros((len(root_array[0])))
406406
if len(np.where(signchange == 1)[0]) > 0:
407407
indexes_too_far_filtered.append(
408408
np.where(signchange == 1)[0][0]-1)
@@ -411,7 +411,7 @@ def _indexes_filt(mymat, tolerance, zoom_xlim=None, zoom_ylim=None):
411411
if indexes_too_far_filtered[0] != 0:
412412
indexes_too_far_filtered.insert(
413413
0, indexes_too_far_filtered[0]-1)
414-
if not indexes_too_far_filtered[-1] + 1 >= len(mymat) - 2:
414+
if not indexes_too_far_filtered[-1] + 1 >= len(root_array) - 2:
415415
indexes_too_far_filtered.append(
416416
indexes_too_far_filtered[-1] + 1)
417417

@@ -441,10 +441,10 @@ def _break_points(num, den):
441441
return k_break, real_break_pts
442442

443443

444-
def _ax_lim(mymat):
444+
def _ax_lim(root_array):
445445
"""Utility to get the axis limits"""
446-
axmin = np.min(np.real(mymat))
447-
axmax = np.max(np.real(mymat))
446+
axmin = np.min(np.real(root_array))
447+
axmax = np.max(np.real(root_array))
448448
if axmax != axmin:
449449
deltax = (axmax - axmin) * 0.02
450450
else:
@@ -564,11 +564,11 @@ def _RLZoomDispatcher(event, sys, ax_rlocus, plotstr):
564564
nump, denp = _systopoly1d(sys_loop)
565565
xlim, ylim = ax_rlocus.get_xlim(), ax_rlocus.get_ylim()
566566

567-
kvect, mymat, xlim, ylim = _default_gains(
567+
kvect, root_array, xlim, ylim = _default_gains(
568568
nump, denp, xlim=None, ylim=None, zoom_xlim=xlim, zoom_ylim=ylim)
569569
_removeLine('rootlocus', ax_rlocus)
570570

571-
for i, col in enumerate(mymat.T):
571+
for i, col in enumerate(root_array.T):
572572
ax_rlocus.plot(real(col), imag(col), plotstr, label='rootlocus',
573573
scalex=False, scaley=False)
574574

@@ -640,10 +640,10 @@ def _RLFeedbackClicksPoint(event, sys, fig, ax_rlocus, sisotool=False):
640640

641641
# Visualise clicked point, display all roots for sisotool mode
642642
if sisotool:
643-
mymat = _RLFindRoots(nump, denp, K.real)
643+
root_array = _RLFindRoots(nump, denp, K.real)
644644
ax_rlocus.plot(
645-
[root.real for root in mymat],
646-
[root.imag for root in mymat],
645+
[root.real for root in root_array],
646+
[root.imag for root in root_array],
647647
marker='s', markersize=6, zorder=20, label='gain_point', color='k')
648648
else:
649649
ax_rlocus.plot(s.real, s.imag, 'k.', marker='s', markersize=8,

control/sisotool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def sisotool(sys, initial_gain=None, xlim_rlocus=None, ylim_rlocus=None,
117117
if kvect is not None:
118118
warnings.warn("'kvect' keyword is deprecated in sisotool; "
119119
"use 'initial_gain' instead", FutureWarning)
120-
initial_gain = np.atleast1d(kvect)[0]
120+
initial_gain = np.atleast_1d(kvect)[0]
121121
initial_gain = config._get_param('sisotool', 'initial_gain',
122122
initial_gain, _sisotool_defaults)
123123

0 commit comments

Comments
 (0)
0