Skip to content

Commit e5b4cb3

Browse files
committed
add documentation on predict keyword + input_output_response list processing
1 parent 983726c commit e5b4cb3

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

control/iosys.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,23 @@ def input_output_response(
17361736
U = U.reshape(-1, ntimepts)
17371737
ninputs = U.shape[0]
17381738

1739+
# If we were passed a list of initial states, concatenate them
1740+
if isinstance(X0, (tuple, list)):
1741+
X0_list = []
1742+
for i, x0 in enumerate(X0):
1743+
x0 = np.array(x0).reshape(-1) # convert everyting to 1D array
1744+
X0_list += x0.tolist() # add elements to initial state
1745+
1746+
# Save the newly created input vector
1747+
X0 = np.array(X0_list)
1748+
1749+
# If the initial state is too short, make it longer (NB: sys.nstates
1750+
# could be None if nstates comes from size of initial condition)
1751+
if sys.nstates and isinstance(X0, np.ndarray) and X0.size < sys.nstates:
1752+
if X0[-1] != 0:
1753+
warn("initial state too short; padding with zeros")
1754+
X0 = np.hstack([X0, np.zeros(sys.nstates - X0.size)])
1755+
17391756
# If we were passed a list of initial states, concatenate them
17401757
if isinstance(X0, (tuple, list)):
17411758
X0_list = []

control/tests/iosys_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,7 @@ def test_interconnect_unused_output():
17111711
outputs=['y'],
17121712
ignore_outputs=['v'])
17131713

1714+
17141715
def test_input_output_broadcasting():
17151716
# Create a system, time vector, and noisy input
17161717
sys = ct.rss(6, 2, 3)
@@ -1752,6 +1753,7 @@ def test_input_output_broadcasting():
17521753
resp_bad = ct.input_output_response(
17531754
sys, T, (U[0, :], U[:2, :-1]), [X0, P0])
17541755

1756+
17551757
def test_nonuniform_timepts():
17561758
"""Test non-uniform time points for simulations"""
17571759
sys = ct.LinearIOSystem(ct.rss(2, 1, 1))

0 commit comments

Comments
 (0)