Skip to content

Commit 74e5aa2

Browse files
committed
Fix root locus initial limit sampling
1 parent 146ccee commit 74e5aa2

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

control/rlocus.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ def root_locus_plot(
188188
if isinstance(sysdata, list) and all(
189189
[isinstance(sys, LTI) for sys in sysdata]) or \
190190
isinstance(sysdata, LTI):
191-
responses = root_locus_map(sysdata, gains=gains)
191+
responses = root_locus_map(
192+
sysdata, gains=gains, xlim=kwargs.get('xlim'),
193+
ylim=kwargs.get('ylim'))
192194
else:
193195
responses = sysdata
194196

control/tests/rlocus_test.py

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

182182

183+
@pytest.mark.usefixtures("mplcleanup")
184+
def test_root_locus_plot_initial_limits_refine_gains():
185+
sys = ct.tf([1000], [1, 25, 100, 0])
186+
xlim = (-10.813628105112421, 14.760795435937652)
187+
ylim = (-35.61713798641108, 33.879716621220311)
188+
189+
cplt = ct.root_locus_plot(
190+
sys, grid=False, xlim=xlim, ylim=ylim, interactive=False)
191+
expected = ct.root_locus_map(sys, xlim=xlim, ylim=ylim)
192+
193+
assert len(cplt.lines[0, 2][0].get_xdata()) == len(expected.gains)
194+
195+
183196
# Test deprecated keywords
184197
@pytest.mark.parametrize("keyword", ["kvect", "k"])
185198
@pytest.mark.usefixtures("mplcleanup")

0 commit comments

Comments
 (0)