Skip to content

Commit 7624aeb

Browse files
committed
Add regression test for discrete impulse response input
1 parent a03ed38 commit 7624aeb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

control/tests/timeresp_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,32 @@ def test_discrete_time_impulse(self, tsystem):
536536
sysdt = sys.sample(dt, 'impulse')
537537
np.testing.assert_array_almost_equal(impulse_response(sys, t)[1],
538538
impulse_response(sysdt, t)[1])
539+
540+
def test_discrete_time_impulse_input(self):
541+
# discrete time impulse input, Only one active input for each trace
542+
A = [[.5, 0.25],[.0, .5]]
543+
B = [[1., 0,],[0., 1.]]
544+
C = [[1., 0.],[0., 1.]]
545+
D = [[0., 0.],[0., 0.]]
546+
dt = True
547+
sysd = ct.ss(A,B,C,D, dt=dt)
548+
response = ct.impulse_response(sysd,T=dt*3)
549+
550+
Uexpected = np.zeros((2,2,4), dtype=float).astype(object)
551+
Uexpected[0,0,0] = 1./dt
552+
Uexpected[1,1,0] = 1./dt
553+
554+
np.testing.assert_array_equal(response.inputs,Uexpected)
555+
556+
dt = 0.5
557+
sysd = ct.ss(A,B,C,D, dt=dt)
558+
response = ct.impulse_response(sysd,T=dt*3)
559+
560+
Uexpected = np.zeros((2,2,4), dtype=float).astype(object)
561+
Uexpected[0,0,0] = 1./dt
562+
Uexpected[1,1,0] = 1./dt
563+
564+
np.testing.assert_array_equal(response.inputs,Uexpected)
539565

540566
@pytest.mark.parametrize("tsystem", ["siso_ss1"], indirect=True)
541567
def test_impulse_response_warnD(self, tsystem):

0 commit comments

Comments
 (0)