🌐 AI搜索 & 代理 主页
Skip to content

Commit da1c517

Browse files
committed
add test for matlab.stepinfo
1 parent 79be09a commit da1c517

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

control/tests/matlab_test.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from control.matlab import ss, ss2tf, ssdata, tf, tf2ss, tfdata, rss, drss, frd
1717
from control.matlab import parallel, series, feedback
1818
from control.matlab import pole, zero, damp
19-
from control.matlab import step, impulse, initial, lsim
19+
from control.matlab import step, stepinfo, impulse, initial, lsim
2020
from control.matlab import margin, dcgain
2121
from control.matlab import linspace, logspace
2222
from control.matlab import bode, rlocus, nyquist, nichols, ngrid, pzmap
@@ -215,6 +215,12 @@ def testStep_mimo(self, mimo):
215215
np.testing.assert_array_almost_equal(y_00, youttrue, decimal=4)
216216
np.testing.assert_array_almost_equal(y_11, youttrue, decimal=4)
217217

218+
def testStepinfo(self, siso):
219+
"""Test the stepinfo function"""
220+
infodict = stepinfo(siso.ss1)
221+
assert isinstance(infodict, dict)
222+
assert len(infodict) == 9
223+
218224
def testImpulse(self, siso):
219225
t = np.linspace(0, 1, 10)
220226
# test transfer function
@@ -344,31 +350,29 @@ def testMargin(self, siso):
344350

345351
def testDcgain(self, siso):
346352
"""Test dcgain for SISO system"""
347-
#Create different forms of a SISO system
348-
A, B, C, D = siso.ss1.A, siso.ss1.B, siso.ss1.C, \
349-
siso.ss1.D
353+
# Create different forms of a SISO system using scipy.signal
354+
A, B, C, D = siso.ss1.A, siso.ss1.B, siso.ss1.C, siso.ss1.D
350355
Z, P, k = sp.signal.ss2zpk(A, B, C, D)
351356
num, den = sp.signal.ss2tf(A, B, C, D)
352357
sys_ss = siso.ss1
353358

354-
#Compute the gain with ``dcgain``
359+
# Compute the gain with ``dcgain``
355360
gain_abcd = dcgain(A, B, C, D)
356361
gain_zpk = dcgain(Z, P, k)
357362
gain_numden = dcgain(np.squeeze(num), den)
358363
gain_sys_ss = dcgain(sys_ss)
359364
# print('\ngain_abcd:', gain_abcd, 'gain_zpk:', gain_zpk)
360365
# print('gain_numden:', gain_numden, 'gain_sys_ss:', gain_sys_ss)
361366

362-
#Compute the gain with a long simulation
367+
# Compute the gain with a long simulation
363368
t = linspace(0, 1000, 1000)
364369
y, _t = step(sys_ss, t)
365370
gain_sim = y[-1]
366371
# print('gain_sim:', gain_sim)
367372

368-
#All gain values must be approximately equal to the known gain
373+
# All gain values must be approximately equal to the known gain
369374
np.testing.assert_array_almost_equal(
370-
[gain_abcd, gain_zpk, gain_numden, gain_sys_ss,
371-
gain_sim],
375+
[gain_abcd, gain_zpk, gain_numden, gain_sys_ss, gain_sim],
372376
[59, 59, 59, 59, 59])
373377

374378
def testDcgain_mimo(self, mimo):

0 commit comments

Comments
 (0)