8000 more coverage · python-control/python-control@fae38af · GitHub
[go: up one dir, main page]

Skip to content

Commit fae38af

Browse files
committed
more coverage
1 parent 39dee6f commit fae38af

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

control/rlocus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
137137
print_gain = config._get_param(
138138
'rlocus', 'print_gain', print_gain, _rlocus_defaults)
139139

140-
sys_loop = sys if sys.issiso() else sys[0,0]
140+
sys_loop = sys if sys.issiso() else sys[0, 0]
141141

142142
# Convert numerator and denominator to polynomials if they aren't
143143
(nump, denp) = _systopoly1d(sys_loop)

control/setup.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

control/tests/rlocus_test.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from control.bdalg import feedback
1616

1717

18+
@pytest.mark.usefixtures("mplcleanup")
1819
class TestRootLocus:
1920
"""These are tests for the feedback function in rlocus.py."""
2021

@@ -32,7 +33,7 @@ class TestRootLocus:
3233
(True, 'dtime')]
3334
])
3435
def sys(self, request):
35-
"""Return some simple LTI system for testing"""
36+
"""Return some simple LTI systems for testing"""
3637
# avoid construction during collection time: prevent unfiltered
3738
# deprecation warning
3839
sysfn, args = request.param
@@ -45,7 +46,7 @@ def check_cl_poles(self, sys, pole_list, k_list):
4546
np.testing.assert_array_almost_equal(poles, poles_expected)
4647

4748
def testRootLocus(self, sys):
48-
"""Basic root locus plot"""
49+
"""Basic root locus (no plot)"""
4950
klist = [-1, 0, 1]
5051

5152
roots, k_out = root_locus(sys, klist, plot=False)
@@ -57,6 +58,33 @@ def test_without_gains(self, sys):
5758
roots, kvect = root_locus(sys, plot=False)
5859
self.check_cl_poles(sys, roots, kvect)
5960

61+
@pytest.mark.parametrize('grid', [None, True, False])
62+
def test_root_locus_plot_grid(self, sys, grid):
63+
rlist, klist = root_locus(sys, grid=grid)
64+
ax = plt.gca()
65+
n_gridlines = sum([int(line.get_linestyle() in [':', 'dotted',
66+
'--', 'dashed'])
67+
for line in ax.lines])
68+
if grid is False:
69+
assert n_gridlines == 2
70+
else:
71+
assert n_gridlines > 2
72+
# TODO check validity of grid
73+
74+
def test_root_locus_warnings(self):
75+
sys = TransferFunction([1000], [1, 25, 100, 0])
76+
with pytest.warns(FutureWarning, match="Plot.*deprecated"):
77+
rlist, klist = root_locus(sys, Plot=True)
78+
with pytest.warns(FutureWarning, match="PrintGain.*deprecated"):
79+
rlist, klist = root_locus(sys, PrintGain=True)
80+
81+
def test_root_locus_neg_false_gain_nonproper(self):
82+
""" Non proper TranferFunction with negative gain: Not implemented"""
83+
with pytest.raises(ValueError, match="with equal order"):
84+
root_locus(TransferFunction([-1, 2], [1, 2]))
85+
86+
# TODO: cover and validate negative false_gain branch in _default_gains()
87+
6088
def test_root_locus_zoom(self):
6189
"""Check the zooming functionality of the Root locus plot"""
6290
system = TransferFunction([1000], [1, 25, 100, 0])
@@ -104,4 +132,3 @@ def test_rlocus_default_wn(self):
104132
[-1e-2, 1-1e7j, 1+1e7j], [0, -1e7j, 1e7j], 1))
105133

106134
ct.root_locus(sys)
107-

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ universal=1
55
addopts = -ra
66
filterwarnings =
77
error:.*matrix subclass:PendingDeprecationWarning
8-

0 commit comments

Comments
 (0)
0