@@ -215,23 +215,84 @@ def test_signal_table(capsys, show_names):
215215 # break the following strings separately because the printout order varies
216216 # because signal names are stored as a set
217217 mystrings = \
218- ["signal | source | destination" ,
219- " -------------------------------------------------------------" ]
218+ ["signal | source | destination" ,
219+ "----- -------------------------------------------------------------" ]
220220 if show_names :
221221 mystrings += \
222- ["e | input | C" ,
223- "u | C | P" ,
224- "y | P | output" ]
222+ ["e | input | C" ,
223+ "u | C | P" ,
224+ "y | P | output" ]
225225 else :
226226 mystrings += \
227- ["e | input | system 0" ,
228- "u | system 0 | system 1" ,
229- "y | system 1 | output" ]
227+ ["e | input | system 0" ,
228+ "u | system 0 | system 1" ,
229+ "y | system 1 | output" ]
230230
231231 for str_ in mystrings :
232232 assert str_ in captured_from_method
233233 assert str_ in captured_from_function
234234
235+ # check auto-sum
236+ P1 = ct .ss (1 ,1 ,1 ,0 , inputs = 'u' , outputs = 'y' , name = 'P1' )
237+ P2 = ct .tf (10 , [.1 , 1 ], inputs = 'e' , outputs = 'y' , name = 'P2' )
238+ P3 = ct .tf (10 , [.1 , 1 ], inputs = 'x' , outputs = 'y' , name = 'P3' )
239+ P = ct .interconnect ([P1 , P2 , P3 ], inputs = ['e' , 'u' , 'x' ], outputs = 'y' )
240+ P .signal_table (show_names = show_names )
241+ captured_from_method = capsys .readouterr ().out
242+
243+ ct .signal_table (P , show_names = show_names )
244+ captured_from_function = capsys .readouterr ().out
245+
246+ mystrings = \
247+ ["signal | source | destination" ,
248+ "-------------------------------------------------------------------" ]
249+ if show_names :
250+ mystrings += \
251+ ["u | input | P1" ,
252+ "e | input | P2" ,
253+ "x | input | P3" ,
254+ "y | P1, P2, P3 | output" ]
255+ else :
256+ mystrings += \
257+ ["u | input | system 0" ,
258+ "e | input | system 1" ,
259+ "x | input | system 2" ,
260+ "y | system 0, system 1, system 2 | output" ]
261+
262+ for str_ in mystrings :
263+ assert str_ in captured_from_method
264+ assert str_ in captured_from_function
265+
266+ # check auto-split
267+ P1 = ct .ss (1 ,1 ,1 ,0 , inputs = 'u' , outputs = 'x' , name = 'P1' )
268+ P2 = ct .tf (10 , [.1 , 1 ], inputs = 'u' , outputs = 'y' , name = 'P2' )
269+ P3 = ct .tf (10 , [.1 , 1 ], inputs = 'u' , outputs = 'z' , name = 'P3' )
270+ P = ct .interconnect ([P1 , P2 , P3 ], inputs = ['u' ], outputs = ['x' ,'y' ,'z' ])
271+ P .signal_table (show_names = show_names )
272+ captured_from_method = capsys .readouterr ().out
273+
274+ ct .signal_table (P , show_names = show_names )
275+ captured_from_function = capsys .readouterr ().out
276+
277+ mystrings = \
278+ ["signal | source | destination" ,
279+ "-------------------------------------------------------------------" ]
280+ if show_names :
281+ mystrings += \
282+ ["u | input | P1, P2, P3" ,
283+ "x | P1 | output " ,
284+ "y | P2 | output" ,
285+ "z | P3 | output" ]
286+ else :
287+ mystrings += \
288+ ["u | input | system 0, system 1, system 2" ,
289+ "x | system 0 | output " ,
290+ "y | system 1 | output" ,
291+ "z | system 2 | output" ]
292+
293+ for str_ in mystrings :
294+ assert str_ in captured_from_method
295+ assert str_ in captured_from_function
235296
236297def test_interconnect_exceptions ():
237298 # First make sure the docstring example works
0 commit comments