From 74e5aa242b8e5bbff74acb9567f45922a47199ae Mon Sep 17 00:00:00 2001 From: marko1olo Date: Mon, 8 Jun 2026 14:42:15 +0400 Subject: [PATCH] Fix root locus initial limit sampling --- control/rlocus.py | 4 +++- control/tests/rlocus_test.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/control/rlocus.py b/control/rlocus.py index b7344e31d..801403fb4 100644 --- a/control/rlocus.py +++ b/control/rlocus.py @@ -188,7 +188,9 @@ def root_locus_plot( if isinstance(sysdata, list) and all( [isinstance(sys, LTI) for sys in sysdata]) or \ isinstance(sysdata, LTI): - responses = root_locus_map(sysdata, gains=gains) + responses = root_locus_map( + sysdata, gains=gains, xlim=kwargs.get('xlim'), + ylim=kwargs.get('ylim')) else: responses = sysdata diff --git a/control/tests/rlocus_test.py b/control/tests/rlocus_test.py index 4d3a08206..fb5615b9e 100644 --- a/control/tests/rlocus_test.py +++ b/control/tests/rlocus_test.py @@ -180,6 +180,19 @@ def test_root_locus_plots(sys, grid, xlim, ylim, interactive): # TODO: add tests to make sure everything "looks" OK +@pytest.mark.usefixtures("mplcleanup") +def test_root_locus_plot_initial_limits_refine_gains(): + sys = ct.tf([1000], [1, 25, 100, 0]) + xlim = (-10.813628105112421, 14.760795435937652) + ylim = (-35.61713798641108, 33.879716621220311) + + cplt = ct.root_locus_plot( + sys, grid=False, xlim=xlim, ylim=ylim, interactive=False) + expected = ct.root_locus_map(sys, xlim=xlim, ylim=ylim) + + assert len(cplt.lines[0, 2][0].get_xdata()) == len(expected.gains) + + # Test deprecated keywords @pytest.mark.parametrize("keyword", ["kvect", "k"]) @pytest.mark.usefixtures("mplcleanup")