Skip to content

Commit 7daed4b

Browse files
Test if labels are transferred to the response and we can still relabel them
1 parent 7b2a257 commit 7daed4b

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

control/tests/trdata_test.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,20 @@ def test_response_copy():
196196
with pytest.raises(ValueError, match="not enough"):
197197
t, y, x = response_mimo
198198

199-
# Labels
200-
assert response_mimo.output_labels is None
201-
assert response_mimo.state_labels is None
202-
assert response_mimo.input_labels is None
199+
# Make sure labels are transferred to the response
200+
assert response_siso.output_labels == sys_siso.output_labels
201+
assert response_siso.state_labels == sys_siso.state_labels
202+
assert response_siso.input_labels == sys_siso.input_labels
203+
assert response_mimo.output_labels == sys_mimo.output_labels
204+
assert response_mimo.state_labels == sys_mimo.state_labels
205+
assert response_mimo.input_labels == sys_mimo.input_labels
206+
207+
# Check relabelling
203208
response = response_mimo(
204209
output_labels=['y1', 'y2'], input_labels='u',
205-
state_labels=["x[%d]" % i for i in range(4)])
210+
state_labels=["x%d" % i for i in range(4)])
206211
assert response.output_labels == ['y1', 'y2']
207-
assert response.state_labels == ['x[0]', 'x[1]', 'x[2]', 'x[3]']
212+
assert response.state_labels == ['x0', 'x1', 'x2', 'x3']
208213
assert response.input_labels == ['u']
209214

210215
# Unknown keyword
@@ -231,6 +236,12 @@ def test_trdata_labels():
231236
np.testing.assert_equal(
232237
response.input_labels, ["u[%d]" % i for i in range(sys.ninputs)])
233238

239+
# Make sure the selected input and output are both correctly transferred to the response
240+
for n,_ in enumerate(U):
241+
step_response = ct.step_response(sys, T, input=n, output=n)
242+
assert step_response.input_labels == [sys.input_labels[n]]
243+
assert step_response.output_labels == [sys.output_labels[n]]
244+
234245

235246
def test_trdata_multitrace():
236247
#

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy