@@ -31,8 +31,9 @@ class TestXferFcn:
3131 def test_constructor_bad_input_type (self ):
3232 """Give the constructor invalid input types."""
3333 # MIMO requires lists of lists of vectors (not lists of vectors)
34- with pytest .raises (TypeError ):
35- TransferFunction ([[0. , 1. ], [2. , 3. ]], [[5. , 2. ], [3. , 0. ]])
34+ # 13 Dec 2024: This now works correctly: creates static array (as tf)
35+ # with pytest.raises(TypeError):
36+ # TransferFunction([[0., 1.], [2., 3.]], [[5., 2.], [3., 0.]])
3637 # good input
3738 TransferFunction ([[[0. , 1. ], [2. , 3. ]]],
3839 [[[5. , 2. ], [3. , 0. ]]])
@@ -1298,3 +1299,35 @@ def test_copy_names(create, args, kwargs, convert):
12981299 cpy = convert (sys , inputs = 'myin' , outputs = 'myout' )
12991300 assert cpy .input_labels == ['myin' ]
13001301 assert cpy .output_labels == ['myout' ]
1302+
1303+ s = ct .TransferFunction .s
1304+ @pytest .mark .parametrize ("args, num, den" , [
1305+ (('s' , ), [[[1 , 0 ]]], [[[1 ]]]), # ctime
1306+ (('z' , ), [[[1 , 0 ]]], [[[1 ]]]), # dtime
1307+ ((1 , 1 ), [[[1 ]]], [[[1 ]]]), # scalars as scalars
1308+ (([[1 ]], [[1 ]]), [[[1 ]]], [[[1 ]]]), # scalars as lists
1309+ (([[[1 , 2 ]]], [[[3 , 4 ]]]), [[[1 , 2 ]]], [[[3 , 4 ]]]), # SISO as lists
1310+ (([[np .array ([1 , 2 ])]], [[np .array ([3 , 4 ])]]), # SISO as arrays
1311+ [[[1 , 2 ]]], [[[3 , 4 ]]]),
1312+ (([[ [1 ], [2 ] ], [[1 , 1 ], [1 , 0 ] ]], # MIMO
1313+ [[ [1 , 0 ], [1 , 0 ] ], [[1 , 2 ], [1 ] ]]),
1314+ [[ [1 ], [2 ] ], [[1 , 1 ], [1 , 0 ] ]],
1315+ [[ [1 , 0 ], [1 , 0 ] ], [[1 , 2 ], [1 ] ]]),
1316+ (([[[1 , 2 ], [3 , 4 ]]], [[[5 , 6 ]]]), # common denominator
1317+ [[[1 , 2 ], [3 , 4 ]]], [[[5 , 6 ], [5 , 6 ]]]),
1318+ (([ [1 / s , 2 / s ], [(s + 1 )/ (s + 2 ), s ]], ), # 2x2 from SISO
1319+ [[ [1 ], [2 ] ], [[1 , 1 ], [1 , 0 ] ]], # num
1320+ [[ [1 , 0 ], [1 , 0 ] ], [[1 , 2 ], [1 ] ]]), # den
1321+ (([[1 , 2 ], [3 , 4 ]], [[[1 , 0 ], [1 , 0 ]]]), ValueError ,
1322+ r"numerator has 2 output\(s\), but the denominator has 1 output" ),
1323+ ])
1324+ def test_tf_args (args , num , den ):
1325+ if isinstance (num , type ):
1326+ exception , match = num , den
1327+ with pytest .raises (exception , match = match ):
1328+ sys = ct .tf (* args )
1329+ else :
1330+ sys = ct .tf (* args )
1331+ chk = ct .tf (num , den )
1332+ np .testing .assert_equal (sys .num , chk .num )
1333+ np .testing .assert_equal (sys .den , chk .den )
0 commit comments