Skip to content

Commit 8b08481

Browse files
author
Andrew D. McGuire
committed
Addressing PR comments
1 parent efc42c8 commit 8b08481

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

control/tests/timeresp_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def test_forced_response(self):
252252
# first system: initial value, second system: step response
253253
u = np.array([[0., 0, 0, 0, 0, 0, 0, 0, 0, 0],
254254
[1., 1, 1, 1, 1, 1, 1, 1, 1, 1]])
255-
x0 = np.matrix(".5; 1; 0; 0")
255+
x0 = np.array([[.5], [1], [0], [0]])
256256
youttrue = np.array([[11., 8.1494, 5.9361, 4.2258, 2.9118, 1.9092,
257257
1.1508, 0.5833, 0.1645, -0.1391],
258258
[9., 17.6457, 24.7072, 30.4855, 35.2234, 39.1165,
@@ -273,7 +273,7 @@ def test_forced_response(self):
273273
# Test discrete MIMO system without default T argument
274274
u = np.array([[0., 0, 0, 0, 0, 0, 0, 0, 0, 0],
275275
[1., 1, 1, 1, 1, 1, 1, 1, 1, 1]])
276-
x0 = np.matrix(".5; 1; 0; 0")
276+
x0 = np.array([[.5], [1], [0], [0]])
277277
youttrue = np.array([[11., 8.1494, 5.9361, 4.2258, 2.9118, 1.9092,
278278
1.1508, 0.5833, 0.1645, -0.1391],
279279
[9., 17.6457, 24.7072, 30.4855, 35.2234, 39.1165,

control/timeresp.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,16 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
273273
raise ValueError('Parameters ``T`` and ``U`` can\'t both be'
274274
'zero for discrete-time simulation')
275275
# Set T to equally spaced samples with same length as U
276-
if len(U.shape) == 1:
276+
if U.ndim == 1:
277277
n_steps = U.shape[0]
278278
else:
279279
n_steps = U.shape[1]
280280
T = np.array(range(n_steps)) * (1 if sys.dt is True else sys.dt)
281281
else:
282282
# Make sure the input vector and time vector have same length
283-
if (len(U.shape) == 1 and U.shape[0] != T.shape[0]) or (len(U.shape) > 1 and U.shape[1] != T.shape[0]):
283+
# TODO: allow interpolation of the input vector
284+
if (U.ndim == 1 and U.shape[0] != T.shape[0]) or \
285+
(U.ndim > 1 and U.shape[1] != T.shape[0]):
284286
ValueError('Pamameter ``T`` must have same elements as'
285287
' the number of columns in input array ``U``')
286288

0 commit comments

Comments
 (0)