Skip to content

Commit 34a7a49

Browse files
Add missing labels when returning TimeResponseData
1 parent 9c26e22 commit 34a7a49

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

control/timeresp.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,8 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
11111111

11121112
return TimeResponseData(
11131113
tout, yout, xout, U, issiso=sys.issiso(),
1114+
output_labels=sys.output_labels, input_labels=sys.input_labels,
1115+
state_labels=sys.state_labels,
11141116
transpose=transpose, return_x=return_x, squeeze=squeeze)
11151117

11161118

@@ -1374,8 +1376,16 @@ def step_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
13741376
# Figure out if the system is SISO or not
13751377
issiso = sys.issiso() or (input is not None and output is not None)
13761378

1379+
# Select only the given input and output, if any
1380+
input_labels = sys.input_labels if input is None \
1381+
else sys.input_labels[input]
1382+
output_labels = sys.output_labels if output is None \
1383+
else sys.output_labels[output]
1384+
13771385
return TimeResponseData(
13781386
response.time, yout, xout, uout, issiso=issiso,
1387+
output_labels=output_labels, input_labels=input_labels,
1388+
state_labels=sys.state_labels,
13791389
transpose=transpose, return_x=return_x, squeeze=squeeze)
13801390

13811391

@@ -1704,9 +1714,15 @@ def initial_response(sys, T=None, X0=0., input=0, output=None, T_num=None,
17041714
# Figure out if the system is SISO or not
17051715
issiso = sys.issiso() or (input is not None and output is not None)
17061716

1717+
# Select only the given output, if any
1718+
output_labels = sys.output_labels if output is None \
1719+
else sys.output_labels[0]
1720+
17071721
# Store the response without an input
17081722
return TimeResponseData(
17091723
response.t, response.y, response.x, None, issiso=issiso,
1724+
output_labels=output_labels, input_labels=None,
1725+
state_labels=sys.state_labels,
17101726
transpose=transpose, return_x=return_x, squeeze=squeeze)
17111727

17121728

@@ -1798,7 +1814,7 @@ def impulse_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
17981814
-----
17991815
This function uses the `forced_response` function to compute the time
18001816
response. For continuous time systems, the initial condition is altered to
1801-
account for the initial impulse. For discrete-time aystems, the impulse is
1817+
account for the initial impulse. For discrete-time aystems, the impulse is
18021818
sized so that it has unit area.
18031819
18041820
Examples
@@ -1869,8 +1885,16 @@ def impulse_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
18691885
# Figure out if the system is SISO or not
18701886
issiso = sys.issiso() or (input is not None and output is not None)
18711887

1888+
# Select only the given input and output, if any
1889+
input_labels = sys.input_labels if input is None \
1890+
else sys.input_labels[input]
1891+
output_labels = sys.output_labels if output is None \
1892+
else sys.output_labels[output]
1893+
18721894
return TimeResponseData(
18731895
response.time, yout, xout, uout, issiso=issiso,
1896+
output_labels=output_labels, input_labels=input_labels,
1897+
state_labels=sys.state_labels,
18741898
transpose=transpose, return_x=return_x, squeeze=squeeze)
18751899

18761900

0 commit comments

Comments
 (0)