FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: infer transposed input length · python-control/python-control@9dca3fe · GitHub

Commit 9dca3fe

Browse files
marko1olo
committed
fix: infer transposed input length
1 parent a775479 commit 9dca3fe

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎control/tests/timeresp_test.py‎

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

1257+
def test_forced_response_transpose_without_time_vector(self):
1258+
sys = ct.ss(
1259+
[[0.5]], [[1.0, -0.25]], [[1.0]], [[0.0, 0.0]], dt=True)
1260+
U = np.column_stack((np.arange(5.0), np.arange(5.0) + 10))
1261+
1262+
response = ct.forced_response(sys, inputs=U, transpose=True)
1263+
1264+
np.testing.assert_allclose(response.time, np.arange(U.shape[0]))
1265+
np.testing.assert_allclose(response.inputs, U)
1266+
assert response.outputs.shape == (U.shape[0], sys.noutputs)
1267+
12571268

12581269
@pytest.mark.pandas
12591270
def test_to_pandas():

‎control/timeresp.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ def forced_response(
11121112
raise ValueError('Parameters `T` and `U` can\'t both be '
11131113
'zero for discrete-time simulation')
11141114
# Set T to equally spaced samples with same length as U
1115-
if U.ndim == 1:
1115+
if U.ndim == 1 or transpose:
11161116
n_steps = U.shape[0]
11171117
else:
11181118
n_steps = U.shape[1]

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL