Skip to content

Commit 20f4bad

Browse files
committed
add unit test to insure all factor functions handle renaming
1 parent a2b55ab commit 20f4bad

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

control/tests/iosys_test.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import scipy
1818

1919
import control as ct
20+
import control.flatsys as fs
2021
from control.tests.conftest import slycotonly
2122

2223
class TestIOSys:
@@ -2356,3 +2357,23 @@ def test_loadable_system_repr(fcn, spec, expected, missing, format):
23562357
# Test 'iosys', either set explicitly or via config.defaults
23572358
out = repr(sys)
23582359
assert out == iosys_expected
2360+
2361+
2362+
@pytest.mark.parametrize("fcn", [ct.ss, ct.tf, ct.frd, ct.nlsys, fs.flatsys])
2363+
def test_relabeling(fcn):
2364+
sys = ct.rss(1, 1, 1, name="sys")
2365+
2366+
# Rename the inputs, outputs, (states,) system
2367+
match fcn:
2368+
case ct.tf:
2369+
sys = fcn(sys, inputs='u', outputs='y', name='new')
2370+
case ct.frd:
2371+
sys = fcn(sys, [0.1, 1, 10], inputs='u', outputs='y', name='new')
2372+
case _:
2373+
sys = fcn(sys, inputs='u', outputs='y', states='x', name='new')
2374+
2375+
assert sys.input_labels == ['u']
2376+
assert sys.output_labels == ['y']
2377+
if sys.nstates:
2378+
assert sys.state_labels == ['x']
2379+
assert sys.name == 'new'

0 commit comments

Comments
 (0)