Skip to content

Commit 2f2e372

Browse files
committed
add unit test to insure all factory functions handle renaming
1 parent 319a8ea commit 2f2e372

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

control/tests/iosys_test.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import scipy
1818

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

2223
class TestIOSys:
2324

@@ -2284,3 +2285,21 @@ def test_signal_indexing():
22842285
with pytest.raises(IndexError, match=r"signal name\(s\) not valid"):
22852286
resp.outputs['y[0]', 'u[0]']
22862287

2288+
@pytest.mark.parametrize("fcn", [ct.ss, ct.tf, ct.frd, ct.nlsys, fs.flatsys])
2289+
def test_relabeling(fcn):
2290+
sys = ct.rss(1, 1, 1, name="sys")
2291+
2292+
# Rename the inputs, outputs, (states,) system
2293+
match fcn:
2294+
case ct.tf:
2295+
sys = fcn(sys, inputs='u', outputs='y', name='new')
2296+
case ct.frd:
2297+
sys = fcn(sys, [0.1, 1, 10], inputs='u', outputs='y', name='new')
2298+
case _:
2299+
sys = fcn(sys, inputs='u', outputs='y', states='x', name='new')
2300+
2301+
assert sys.input_labels == ['u']
2302+
assert sys.output_labels == ['y']
2303+
if sys.nstates:
2304+
assert sys.state_labels == ['x']
2305+
assert sys.name == 'new'

0 commit comments

Comments
 (0)