Skip to content

Commit 3dbaacd

Browse files
committed
test frd freqresp deprecation
1 parent 1bf445b commit 3dbaacd

3 files changed

Lines changed: 37 additions & 24 deletions

File tree

control/tests/frd_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,12 @@ def test_eval(self):
416416
with pytest.raises(ValueError, match="only accept purely imaginary"):
417417
frd_tf(2)
418418

419+
def test_freqresp_deprecated(self):
420+
sys_tf = ct.tf([1], [1, 2, 1])
421+
frd_tf = FRD(sys_tf, np.logspace(-1, 1, 3))
422+
with pytest.warns(DeprecationWarning):
423+
frd_tf.freqresp(1.)
424+
419425
def test_repr_str(self):
420426
# repr printing
421427
array = np.array

control/tests/freqresp_test.py

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,46 @@
2121
pytestmark = pytest.mark.usefixtures("mplcleanup")
2222

2323

24-
def test_siso():
25-
"""Test SISO frequency response"""
24+
@pytest.fixture
25+
def ss_siso():
2626
A = np.array([[1, 1], [0, 1]])
2727
B = np.array([[0], [1]])
2828
C = np.array([[1, 0]])
2929
D = 0
30-
sys = StateSpace(A, B, C, D)
30+
return StateSpace(A, B, C, D)
31+
32+
33+
@pytest.fixture
34+
def ss_mimo():
35+
A = np.array([[1, 1], [0, 1]])
36+
B = np.array([[1, 0], [0, 1]])
37+
C = np.array([[1, 0]])
38+
D = np.array([[0, 0]])
39+
return StateSpace(A, B, C, D)
40+
41+
def test_freqresp_siso(ss_siso):
42+
"""Test SISO frequency response"""
3143
omega = np.linspace(10e-2, 10e2, 1000)
3244

3345
# test frequency response
34-
sys.frequency_response(omega)
46+
ctrl.freqresp(ss_siso, omega)
3547

36-
# test bode plot
37-
bode(sys)
3848

39-
# Convert to transfer function and test bode
40-
systf = tf(sys)
41-
bode(systf)
49+
@slycotonly
50+
def test_freqresp_mimo(ss_mimo):
51+
"""Test MIMO frequency response calls"""
52+
omega = np.linspace(10e-2, 10e2, 1000)
53+
ctrl.freqresp(ss_mimo, omega)
54+
tf_mimo = tf(ss_mimo)
55+
ctrl.freqresp(tf_mimo, omega)
56+
57+
58+
def test_bode_basic(ss_siso):
59+
"""Test bode plot call (Very basic)"""
60+
# TODO: proper test
61+
tf_siso = tf(ss_siso)
62+
bode(ss_siso)
63+
bode(tf_siso)
4264

4365

4466
@pytest.mark.filterwarnings("ignore:.*non-positive left xlim:UserWarning")
@@ -106,20 +128,6 @@ def test_doubleint():
106128
bode(sys)
107129

108130

109-
@slycotonly
110-
def test_mimo():
111-
"""Test MIMO frequency response calls"""
112-
A = np.array([[1, 1], [0, 1]])
113-
B = np.array([[1, 0], [0, 1]])
114-
C = np.array([[1, 0]])
115-
D = np.array([[0, 0]])
116-
omega = np.linspace(10e-2, 10e2, 1000)
117-
sysMIMO = ss(A, B, C, D)
118-
119-
sysMIMO.frequency_response(omega)
120-
tf(sysMIMO)
121-
122-
123131
@pytest.mark.parametrize(
124132
"Hz, Wcp, Wcg",
125133
[pytest.param(False, 6.0782869, 10., id="omega"),

control/tests/statesp_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ def test_freq_resp(self):
378378

379379
# Deprecated version of the call (should return warning)
380380
with pytest.warns(DeprecationWarning, match="will be removed"):
381-
from control import freqresp
382381
mag, phase, omega = sys.freqresp(true_omega)
383382
np.testing.assert_almost_equal(mag, true_mag)
384383

0 commit comments

Comments
 (0)