Skip to content

Commit bdd3e0d

Browse files
committed
fix: infer transposed input length
1 parent 146ccee commit bdd3e0d

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

control/tests/timeresp_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,17 @@ def test_response_transpose(
12451245
assert y.shape == ysh_no
12461246
assert x.shape == (T.size, sys.nstates)
12471247

1248+
def test_forced_response_transpose_without_time_vector(self):
1249+
sys = ct.ss(
1250+
[[0.5]], [[1.0, -0.25]], [[1.0]], [[0.0, 0.0]], dt=True)
1251+
U = np.column_stack((np.arange(5.0), np.arange(5.0) + 10))
1252+
1253+
response = ct.forced_response(sys, inputs=U, transpose=True)
1254+
1255+
np.testing.assert_allclose(response.time, np.arange(U.shape[0]))
1256+
np.testing.assert_allclose(response.inputs, U)
1257+
assert response.outputs.shape == (U.shape[0], sys.noutputs)
1258+
12481259

12491260
@pytest.mark.pandas
12501261
def test_to_pandas():

control/timeresp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,8 @@ def forced_response(
11141114
# Set T to equally spaced samples with same length as U
11151115
if U.ndim == 1:
11161116
n_steps = U.shape[0]
1117+
elif transpose:
1118+
n_steps = U.shape[0]
11171119
else:
11181120
n_steps = U.shape[1]
11191121
dt = 1. if sys.dt in [True, None] else sys.dt

0 commit comments

Comments
 (0)