Skip to content

Commit 1a27e62

Browse files
committed
Rudimentary test for stability_margin with discrete TF
1 parent b305075 commit 1a27e62

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

control/tests/margin_test.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
margin_test.py - test suite for stability margin commands
44
55
RMM, 15 Jul 2011
6-
BG, 30 June 2020 -- convert to pytest, gh-425
6+
BG, 30 Jun 2020 -- convert to pytest, gh-425
7+
BG, 16 Nov 2020 -- pick from gh-438 and add discrete test
78
"""
89
from __future__ import print_function
910

@@ -134,7 +135,6 @@ def test_phase_crossover_frequencies():
134135
omega, gain = phase_crossover_frequencies(tf)
135136

136137

137-
138138
def test_mag_phase_omega():
139139
"""Test for bug reported in gh-58"""
140140
sys = TransferFunction(15, [1, 6, 11, 6])
@@ -327,3 +327,14 @@ def test_zmore_stability_margins(tsys_zmore):
327327
tsys_zmore['result'],
328328
atol=tsys_zmore['atol'],
329329
rtol=tsys_zmore['rtol'])
330+
331+
332+
@pytest.mark.parametrize(
333+
'cnum, cden, dt, ref',
334+
[([2], [1, 3, 2, 0], 1e-2, # gh-465
335+
(2.9558, 32.8170, 0.43584, 1.4037, 0.74953, 0.97079))])
336+
def test_stability_margins_discrete(cnum, cden, dt, ref):
337+
"""Test stability_margins with discrete TF input"""
338+
tf = TransferFunction(cnum, cden).sample(dt)
339+
out = stability_margins(tf)
340+
assert_allclose(out, ref, atol=1.5e-2)

0 commit comments

Comments
 (0)