|
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,11 @@ 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 len(infodict) == 9 |
| 222 | + |
218 | 223 | def testImpulse(self, siso):
|
219 | 224 | t = np.linspace(0, 1, 10)
|
220 | 225 | # test transfer function
|
@@ -344,31 +349,29 @@ def testMargin(self, siso):
|
344 | 349 |
|
345 | 350 | def testDcgain(self, siso):
|
346 | 351 | """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 |
| 352 | + # Create different forms of a SISO system using scipy.signal |
| 353 | + A, B, C, D = siso.ss1.A, siso.ss1.B, siso.ss1.C, siso.ss1.D |
350 | 354 | Z, P, k = sp.signal.ss2zpk(A, B, C, D)
|
351 | 355 | num, den = sp.signal.ss2tf(A, B, C, D)
|
352 | 356 | sys_ss = siso.ss1
|
353 | 357 |
|
354 |
| - #Compute the gain with ``dcgain`` |
| 358 | + # Compute the gain with ``dcgain`` |
355 | 359 | gain_abcd = dcgain(A, B, C, D)
|
356 | 360 | gain_zpk = dcgain(Z, P, k)
|
357 | 361 | gain_numden = dcgain(np.squeeze(num), den)
|
358 | 362 | gain_sys_ss = dcgain(sys_ss)
|
359 | 363 | # print('\ngain_abcd:', gain_abcd, 'gain_zpk:', gain_zpk)
|
360 | 364 | # print('gain_numden:', gain_numden, 'gain_sys_ss:', gain_sys_ss)
|
361 | 365 |
|
362 |
| - #Compute the gain with a long simulation |
| 366 | + # Compute the gain with a long simulation |
363 | 367 | t = linspace(0, 1000, 1000)
|
364 | 368 | y, _t = step(sys_ss, t)
|
365 | 369 | gain_sim = y[-1]
|
366 | 370 | # print('gain_sim:', gain_sim)
|
367 | 371 |
|
368 |
| - #All gain values must be approximately equal to the known gain |
| 372 | + # All gain values must be approximately equal to the known gain |
369 | 373 | np.testing.assert_array_almost_equal(
|
370 |
| - [gain_abcd, gain_zpk, gain_numden, gain_sys_ss, |
371 |
| - gain_sim], |
| 374 | + [gain_abcd, gain_zpk, gain_numden, gain_sys_ss, gain_sim], |
372 | 375 | [59, 59, 59, 59, 59])
|
373 | 376 |
|
374 | 377 | def testDcgain_mimo(self, mimo):
|
|
0 commit comments