|
3 | 3 | margin_test.py - test suite for stability margin commands |
4 | 4 |
|
5 | 5 | 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 |
7 | 8 | """ |
8 | 9 | from __future__ import print_function |
9 | 10 |
|
@@ -134,7 +135,6 @@ def test_phase_crossover_frequencies(): |
134 | 135 | omega, gain = phase_crossover_frequencies(tf) |
135 | 136 |
|
136 | 137 |
|
137 | | - |
138 | 138 | def test_mag_phase_omega(): |
139 | 139 | """Test for bug reported in gh-58""" |
140 | 140 | sys = TransferFunction(15, [1, 6, 11, 6]) |
@@ -327,3 +327,14 @@ def test_zmore_stability_margins(tsys_zmore): |
327 | 327 | tsys_zmore['result'], |
328 | 328 | atol=tsys_zmore['atol'], |
329 | 329 | 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