@@ -986,7 +986,7 @@ def test_repr(self, Hargs, ref):
986986 np .testing .assert_array_almost_equal (H .num [p ][m ], H2 .num [p ][m ])
987987 np .testing .assert_array_almost_equal (H .den [p ][m ], H2 .den [p ][m ])
988988 assert H .dt == H2 .dt
989-
989+
990990 def test_sample_named_signals (self ):
991991 sysc = ct .TransferFunction (1.1 , (1 , 2 ), inputs = 'u' , outputs = 'y' )
992992
@@ -1073,3 +1073,41 @@ def test_xferfcn_ndarray_precedence(op, tf, arr):
10731073 # Apply the operator to the array and transfer function
10741074 result = op (arr , tf )
10751075 assert isinstance (result , ct .TransferFunction )
1076+
1077+
1078+ @pytest .mark .parametrize (
1079+ "zeros, poles, gain, args, kwargs" , [
1080+ ([], [- 1 ], 1 , [], {}),
1081+ ([1 , 2 ], [- 1 , - 2 , - 3 ], 5 , [], {}),
1082+ ([1 , 2 ], [- 1 , - 2 , - 3 ], 5 , [], {'name' : "sys" }),
1083+ ([1 , 2 ], [- 1 , - 2 , - 3 ], 5 , [], {'inputs' : ["in" ], 'outputs' : ["out" ]}),
1084+ ([1 , 2 ], [- 1 , - 2 , - 3 ], 5 , [0.1 ], {}),
1085+ (np .array ([1 , 2 ]), np .array ([- 1 , - 2 , - 3 ]), 5 , [], {}),
1086+ ])
1087+ def test_zpk (zeros , poles , gain , args , kwargs ):
1088+ # Create the transfer function
1089+ sys = ct .zpk (zeros , poles , gain , * args , ** kwargs )
1090+
1091+ # Make sure the poles and zeros match
1092+ np .testing .assert_equal (sys .zeros ().sort (), zeros .sort ())
1093+ np .testing .assert_equal (sys .poles ().sort (), poles .sort ())
1094+
1095+ # Check to make sure the gain is OK
1096+ np .testing .assert_almost_equal (
1097+ gain , sys (0 ) * np .prod (- sys .poles ()) / np .prod (- sys .zeros ()))
1098+
1099+ # Check time base
1100+ if args :
1101+ assert sys .dt == args [0 ]
1102+
1103+ # Check inputs, outputs, name
1104+ input_labels = kwargs .get ('inputs' , [])
1105+ for i , label in enumerate (input_labels ):
1106+ assert sys .input_labels [i ] == label
1107+
1108+ output_labels = kwargs .get ('outputs' , [])
1109+ for i , label in enumerate (output_labels ):
1110+ assert sys .output_labels [i ] == label
1111+
1112+ if kwargs .get ('name' ):
1113+ assert sys .name == kwargs .get ('name' )
0 commit comments