|
16 | 16 | from control.matlab import ss, ss2tf, ssdata, tf, tf2ss, tfdata, rss, drss, frd
|
17 | 17 | from control.matlab import parallel, series, feedback
|
18 | 18 | 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 |
20 | 20 | from control.matlab import margin, dcgain
|
21 | 21 | from control.matlab import linspace, logspace
|
22 | 22 | from control.matlab import bode, rlocus, nyquist, nichols, ngrid, pzmap
|
@@ -215,6 +215,12 @@ def testStep_mimo(self, mimo):
|
215 | 215 | np.testing.assert_array_almost_equal(y_00, youttrue, decimal=4)
|
216 | 216 | np.testing.assert_array_almost_equal(y_11, youttrue, decimal=4)
|
217 | 217 |
|
| 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 | + |
218 | 224 | def testImpulse(self, siso):
|
219 | 225 | t = np.linspace(0, 1, 10)
|
220 | 226 | # test transfer function
|
@@ -344,31 +350,29 @@ def testMargin(self, siso):
|
344 | 350 |
|
345 | 351 | def testDcgain(self, siso):
|
346 | 352 | """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 |
350 | 355 | Z, P, k = sp.signal.ss2zpk(A, B, C, D)
|
351 | 356 | num, den = sp.signal.ss2tf(A, B, C, D)
|
352 | 357 | sys_ss = siso.ss1
|
353 | 358 |
|
354 |
| - #Compute the gain with ``dcgain`` |
| 359 | + # Compute the gain with ``dcgain`` |
355 | 360 | gain_abcd = dcgain(A, B, C, D)
|
356 | 361 | gain_zpk = dcgain(Z, P, k)
|
357 | 362 | gain_numden = dcgain(np.squeeze(num), den)
|
358 | 363 | gain_sys_ss = dcgain(sys_ss)
|
359 | 364 | # print('\ngain_abcd:', gain_abcd, 'gain_zpk:', gain_zpk)
|
360 | 365 | # print('gain_numden:', gain_numden, 'gain_sys_ss:', gain_sys_ss)
|
361 | 366 |
|
362 |
| - #Compute the gain with a long simulation |
| 367 | + # Compute the gain with a long simulation |
363 | 368 | t = linspace(0, 1000, 1000)
|
364 | 369 | y, _t = step(sys_ss, t)
|
365 | 370 | gain_sim = y[-1]
|
366 | 371 | # print('gain_sim:', gain_sim)
|
367 | 372 |
|
368 |
| - #All gain values must be approximately equal to the known gain |
| 373 | + # All gain values must be approximately equal to the known gain |
369 | 374 | 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], |
372 | 376 | [59, 59, 59, 59, 59])
|
373 | 377 |
|
374 | 378 | def testDcgain_mimo(self, mimo):
|
|
0 commit comments