Skip to content

Commit a9415a0

Browse files
committed
update documentation, processing of root_locus kvect keyword
1 parent c638362 commit a9415a0

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

control/rlocus.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ def root_locus_map(sysdata, gains=None):
4242
"""Compute the root locus map for an LTI system.
4343
4444
Calculate the root locus by finding the roots of 1 + k * G(s) where G
45-
is a linear system with transfer function num(s)/den(s) and each k is
46-
an element of kvect.
45+
is a linear system and k varies over a range of gains.
4746
4847
Parameters
4948
----------
5049
sys : LTI system or list of LTI systems
5150
Linear input/output systems (SISO only, for now).
5251
gains : array_like, optional
53-
Gains to use in computing plot of closed-loop poles.
52+
Gains to use in computing plot of closed-loop poles. If not given,
53+
gains are chosen to include the main features of the root locus map.
5454
5555
Returns
5656
-------
@@ -98,20 +98,20 @@ def root_locus_map(sysdata, gains=None):
9898

9999

100100
def root_locus_plot(
101-
sysdata, kvect=None, grid=None, plot=None, **kwargs):
101+
sysdata, gains=None, grid=None, plot=None, **kwargs):
102102

103103
"""Root locus plot.
104104
105105
Calculate the root locus by finding the roots of 1 + k * G(s) where G
106-
is a linear system with transfer function num(s)/den(s) and each k is
107-
an element of kvect.
106+
is a linear system and k varies over a range of gains.
108107
109108
Parameters
110109
----------
111110
sysdata : PoleZeroMap or LTI object or list
112111
Linear input/output systems (SISO only, for now).
113-
kvect : array_like, optional
114-
Gains to use in computing plot of closed-loop poles.
112+
gains : array_like, optional
113+
Gains to use in computing plot of closed-loop poles. If not given,
114+
gains are chosen to include the main features of the root locus map.
115115
xlim : tuple or list, optional
116116
Set limits of x axis, normally with tuple
117117
(see :doc:`matplotlib:api/axes_api`).
@@ -145,10 +145,10 @@ def root_locus_plot(
145145
* lines[idx, 2]: loci
146146
147147
roots, gains : ndarray
148-
(legacy) If the `plot` keyword is given, returns the
149-
closed-loop root locations, arranged such that each row
150-
corresponds to a gain in gains, and the array of gains (ame as
151-
kvect keyword argument if provided).
148+
(legacy) If the `plot` keyword is given, returns the closed-loop
149+
root locations, arranged such that each row corresponds to a gain
150+
in gains, and the array of gains (ame as gains keyword argument if
151+
provided).
152152
153153
Notes
154154
-----
@@ -160,13 +160,16 @@ def root_locus_plot(
160160
"""
161161
from .pzmap import pole_zero_plot
162162

163+
# Legacy parameters
164+
gains = config._process_legacy_keyword(kwargs, 'kvect', 'gains', gains)
165+
163166
# Set default parameters
164167
grid = config._get_param('rlocus', 'grid', grid, _rlocus_defaults)
165168

166169
if isinstance(sysdata, list) and all(
167170
[isinstance(sys, LTI) for sys in sysdata]) or \
168171
isinstance(sysdata, LTI):
169-
responses = root_locus_map(sysdata, gains=kvect)
172+
responses = root_locus_map(sysdata, gains=gains)
170173
else:
171174
responses = sysdata
172175

control/tests/rlocus_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ def test_root_locus_plots(sys, grid, xlim, ylim, interactive):
180180
# TODO: add tests to make sure everything "looks" OK
181181

182182

183+
# Test deprecated keywords
184+
def test_root_locus_legacy():
185+
sys = ct.rss(2, 1, 1)
186+
with pytest.warns(DeprecationWarning, match="'kvect' is deprecated"):
187+
ct.root_locus_plot(sys, kvect=[0, 1, 2])
188+
189+
183190
# Generate plots used in documentation
184191
def test_root_locus_documentation(savefigs=False):
185192
plt.figure()

0 commit comments

Comments
 (0)