|
8 | 8 | import operator
|
9 | 9 |
|
10 | 10 | import control as ct
|
11 |
| -from control import StateSpace, TransferFunction, rss, ss2tf, evalfr |
| 11 | +from control import StateSpace, TransferFunction, rss, evalfr |
| 12 | +from control import ss, ss2tf, tf, tf2ss |
12 | 13 | from control import isctime, isdtime, sample_system, defaults
|
13 | 14 | from control.statesp import _convert_to_statespace
|
14 | 15 | from control.xferfcn import _convert_to_transfer_function
|
@@ -1111,3 +1112,34 @@ def test_zpk(zeros, poles, gain, args, kwargs):
|
1111 | 1112 |
|
1112 | 1113 | if kwargs.get('name'):
|
1113 | 1114 | assert sys.name == kwargs.get('name')
|
| 1115 | + |
| 1116 | +@pytest.mark.parametrize("create, args, kwargs, convert", [ |
| 1117 | + (StateSpace, ([-1], [1], [1], [0]), {}, ss2tf), |
| 1118 | + (StateSpace, ([-1], [1], [1], [0]), {}, ss), |
| 1119 | + (StateSpace, ([-1], [1], [1], [0]), {}, tf), |
| 1120 | + (StateSpace, ([-1], [1], [1], [0]), dict(inputs='i', outputs='o'), ss2tf), |
| 1121 | + (StateSpace, ([-1], [1], [1], [0]), dict(inputs=1, outputs=1), ss2tf), |
| 1122 | + (StateSpace, ([-1], [1], [1], [0]), dict(inputs='i', outputs='o'), ss), |
| 1123 | + (StateSpace, ([-1], [1], [1], [0]), dict(inputs='i', outputs='o'), tf), |
| 1124 | + (TransferFunction, ([1], [1, 1]), {}, tf2ss), |
| 1125 | + (TransferFunction, ([1], [1, 1]), {}, tf), |
| 1126 | + (TransferFunction, ([1], [1, 1]), {}, ss), |
| 1127 | + (TransferFunction, ([1], [1, 1]), dict(inputs='i', outputs='o'), tf2ss), |
| 1128 | + (TransferFunction, ([1], [1, 1]), dict(inputs=1, outputs=1), tf2ss), |
| 1129 | + (TransferFunction, ([1], [1, 1]), dict(inputs='i', outputs='o'), tf), |
| 1130 | + (TransferFunction, ([1], [1, 1]), dict(inputs='i', outputs='o'), ss), |
| 1131 | +]) |
| 1132 | +def test_copy_names(create, args, kwargs, convert): |
| 1133 | + # Convert a system with no renaming |
| 1134 | + sys = create(*args, **kwargs) |
| 1135 | + cpy = convert(sys) |
| 1136 | + |
| 1137 | + assert cpy.input_labels == sys.input_labels |
| 1138 | + assert cpy.input_labels == sys.input_labels |
| 1139 | + if cpy.nstates is not None and sys.nstates is not None: |
| 1140 | + assert cpy.state_labels == sys.state_labels |
| 1141 | + |
| 1142 | + # Relabel inputs and outputs |
| 1143 | + cpy = convert(sys, inputs='myin', outputs='myout') |
| 1144 | + assert cpy.input_labels == ['myin'] |
| 1145 | + assert cpy.output_labels == ['myout'] |
0 commit comments