Skip to content

Commit 6e3113a

Browse files
committed
remove bad dimension check in forced_response for dtime systems
1 parent 4c954d2 commit 6e3113a

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

control/tests/matlab_test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,25 @@ def testLsim_mimo(self, mimo):
348348
yout, _t, _xout = lsim(mimo.ss1, u, t, x0)
349349
np.testing.assert_array_almost_equal(yout, youttrue, decimal=4)
350350

351+
def test_lsim_mimo_dtime(self):
352+
# https://github.com/python-control/python-control/issues/764
353+
time = np.linspace(0.0, 511.0e-6, 512)
354+
DAC = np.sin(time)
355+
ADC = np.cos(time)
356+
357+
input_Kalman = np.transpose(
358+
np.concatenate(([[DAC]], [[ADC]]), axis=1)[0])
359+
Af = [[0.45768416, -0.42025511], [-0.43354791, 0.51961178]]
360+
Bf = [[2.84368641, 52.05922305], [-1.47286557, -19.94861943]]
361+
Cf = [[1.0, 0.0], [0.0, 1.0]]
362+
Df = [[0.0, 0.0], [0.0, 0.0]]
363+
364+
ss_Kalman = ss(Af, Bf, Cf, Df, 1.0e-6)
365+
y_est, t, x_est = lsim(ss_Kalman, input_Kalman, time)
366+
assert y_est.shape == (time.size, ss_Kalman.ninputs)
367+
assert t.shape == (time.size, )
368+
assert x_est.shape == (time.size, ss_Kalman.nstates)
369+
351370
def testMargin(self, siso):
352371
"""Test margin()"""
353372
#! TODO: check results to make sure they are OK

control/tests/timeresp_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,10 +698,10 @@ def test_forced_response_invalid_d(self, tsystem):
698698
"""Test invalid parameters dtime with sys.dt > 0."""
699699
with pytest.raises(ValueError, match="can't both be zero"):
700700
forced_response(tsystem.sys)
701-
with pytest.raises(ValueError, match="must have same elements"):
701+
with pytest.raises(ValueError, match="Parameter ``U``: Wrong shape"):
702702
forced_response(tsystem.sys,
703703
T=tsystem.t, U=np.random.randn(1, 12))
704-
with pytest.raises(ValueError, match="must have same elements"):
704+
with pytest.raises(ValueError, match="Parameter ``U``: Wrong shape"):
705705
forced_response(tsystem.sys,
706706
T=tsystem.t, U=np.random.randn(12))
707707
with pytest.raises(ValueError, match="must match sampling time"):

control/timeresp.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -972,11 +972,6 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
972972
dt = 1. if sys.dt in [True, None] else sys.dt
973973
T = np.array(range(n_steps)) * dt
974974
else:
975-
# Make sure the input vector and time vector have same length
976-
if (U.ndim == 1 and U.shape[0] != T.shape[0]) or \
977-
(U.ndim > 1 and U.shape[1] != T.shape[0]):
978-
raise ValueError('Parameter ``T`` must have same elements as'
979-
' the number of columns in input array ``U``')
980975
if U.ndim == 0:
981976
U = np.full((n_inputs, T.shape[0]), U)
982977
else:

0 commit comments

Comments
 (0)