@@ -97,3 +97,34 @@ def test_composition_override(dt):
9797 with pytest .raises (ValueError , match = "incompatible timebases" ):
9898 sys3 = ct .interconnect (
9999 [sys1 , sys2 ], inputs = 'u1' , outputs = 'y2' , dt = dt )
100+
101+
102+ # Make sure all system creation functions treat timebases uniformly
103+ @pytest .mark .parametrize (
104+ "fcn, args" , [
105+ (ct .ss , [- 1 , 1 , 1 , 1 ]),
106+ (ct .tf , [[1 , 2 ], [3 , 4 , 5 ]]),
107+ (ct .zpk , [[- 1 ], [- 2 , - 3 ], 1 ]),
108+ (ct .frd , [[1 , 1 , 1 ], [1 , 2 , 3 ]]),
109+ (ct .nlsys , [lambda t , x , u , params : - x , None ]),
110+ ])
111+ @pytest .mark .parametrize (
112+ "kwargs, expected" , [
113+ ({}, 0 ),
114+ ({'dt' : 0 }, 0 ),
115+ ({'dt' : 0.1 }, 0.1 ),
116+ ({'dt' : True }, True ),
117+ ({'dt' : None }, None ),
118+ ])
119+ def test_default (fcn , args , kwargs , expected ):
120+ sys = fcn (* args , ** kwargs )
121+ assert sys .dt == expected
122+
123+ # Some commands allow dt via extra argument
124+ if fcn in [ct .ss , ct .tf , ct .zpk , ct .frd ] and kwargs .get ('dt' ):
125+ sys = fcn (* args , kwargs ['dt' ])
126+ assert sys .dt == expected
127+
128+ # Make sure an error is generated if dt is redundant
129+ with pytest .warns (UserWarning , match = "received multiple dt" ):
130+ sys = fcn (* args , kwargs ['dt' ], ** kwargs )
0 commit comments