Skip to content

Commit 90582e5

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

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

control/tests/matlab_test.py

Lines changed: 12 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,11 @@ 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 len(infodict) == 9
222+
218223
def testImpulse(self, siso):
219224
t = np.linspace(0, 1, 10)
220225
# test transfer function
@@ -344,31 +349,29 @@ def testMargin(self, siso):
344349

345350
def testDcgain(self, siso):
346351
"""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
350354
Z, P, k = sp.signal.ss2zpk(A, B, C, D)
351355
num, den = sp.signal.ss2tf(A, B, C, D)
352356
sys_ss = siso.ss1
353357

354-
#Compute the gain with ``dcgain``
358+
# Compute the gain with ``dcgain``
355359
gain_abcd = dcgain(A, B, C, D)
356360
gain_zpk = dcgain(Z, P, k)
357361
gain_numden = dcgain(np.squeeze(num), den)
358362
gain_sys_ss = dcgain(sys_ss)
359363
# print('\ngain_abcd:', gain_abcd, 'gain_zpk:', gain_zpk)
360364
# print('gain_numden:', gain_numden, 'gain_sys_ss:', gain_sys_ss)
361365

362-
#Compute the gain with a long simulation
366+
# Compute the gain with a long simulation
363367
t = linspace(0, 1000, 1000)
364368
y, _t = step(sys_ss, t)
365369
gain_sim = y[-1]
366370
# print('gain_sim:', gain_sim)
367371

368-
#All gain values must be approximately equal to the known gain
372+
# All gain values must be approximately equal to the known gain
369373
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],
372375
[59, 59, 59, 59, 59])
373376

374377
def testDcgain_mimo(self, mimo):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy