@@ -265,6 +265,10 @@ def __init__(self, *args, **kwargs):
265265 dt = config .defaults ['control.default_dt' ]
266266 self .dt = dt
267267
268+ # Make sure there were no extraneous keywords
269+ if kwargs :
270+ raise TypeError ("unrecognized keywords: " , str (kwargs ))
271+
268272 #
269273 # Class attributes
270274 #
@@ -1297,7 +1301,7 @@ def _add_siso(num1, den1, num2, den2):
12971301 return num , den
12981302
12991303
1300- def _convert_to_transfer_function (sys , ** kw ):
1304+ def _convert_to_transfer_function (sys , inputs = 1 , outputs = 1 ):
13011305 """Convert a system to transfer function form (if needed).
13021306
13031307 If sys is already a transfer function, then it is returned. If sys is a
@@ -1324,13 +1328,9 @@ def _convert_to_transfer_function(sys, **kw):
13241328 from .statesp import StateSpace
13251329
13261330 if isinstance (sys , TransferFunction ):
1327- if len (kw ):
1328- raise TypeError ("If sys is a TransferFunction, " +
1329- "_convertToTransferFunction cannot take keywords." )
1330-
13311331 return sys
1332- elif isinstance (sys , StateSpace ):
13331332
1333+ elif isinstance (sys , StateSpace ):
13341334 if 0 == sys .nstates :
13351335 # Slycot doesn't like static SS->TF conversion, so handle
13361336 # it first. Can't join this with the no-Slycot branch,
@@ -1341,14 +1341,9 @@ def _convert_to_transfer_function(sys, **kw):
13411341 for i in range (sys .noutputs )]
13421342 else :
13431343 try :
1344- from slycot import tb04ad
1345- if len (kw ):
1346- raise TypeError (
1347- "If sys is a StateSpace, " +
1348- "_convertToTransferFunction cannot take keywords." )
1349-
13501344 # Use Slycot to make the transformation
13511345 # Make sure to convert system matrices to numpy arrays
1346+ from slycot import tb04ad
13521347 tfout = tb04ad (
13531348 sys .nstates , sys .ninputs , sys .noutputs , array (sys .A ),
13541349 array (sys .B ), array (sys .C ), array (sys .D ), tol1 = 0.0 )
@@ -1381,15 +1376,6 @@ def _convert_to_transfer_function(sys, **kw):
13811376 return TransferFunction (num , den , sys .dt )
13821377
13831378 elif isinstance (sys , (int , float , complex , np .number )):
1384- if "inputs" in kw :
1385- inputs = kw ["inputs" ]
1386- else :
1387- inputs = 1
1388- if "outputs" in kw :
1389- outputs = kw ["outputs" ]
1390- else :
1391- outputs = 1
1392-
13931379 num = [[[sys ] for j in range (inputs )] for i in range (outputs )]
13941380 den = [[[1 ] for j in range (inputs )] for i in range (outputs )]
13951381
@@ -1498,6 +1484,10 @@ def tf(*args, **kwargs):
14981484 if len (args ) == 2 or len (args ) == 3 :
14991485 return TransferFunction (* args , ** kwargs )
15001486 elif len (args ) == 1 :
1487+ # Make sure there were no extraneous keywords
1488+ if kwargs :
1489+ raise TypeError ("unrecognized keywords: " , str (kwargs ))
1490+
15011491 # Look for special cases defining differential/delay operator
15021492 if args [0 ] == 's' :
15031493 return TransferFunction .s
@@ -1525,8 +1515,8 @@ def ss2tf(*args, **kwargs):
15251515 The function accepts either 1 or 4 parameters:
15261516
15271517 ``ss2tf(sys)``
1528- Convert a linear system from state space into transfer function form. Always creates a
1529- new system.
1518+ Convert a linear system from state space into transfer function
1519+ form. Always creates a new system.
15301520
15311521 ``ss2tf(A, B, C, D)``
15321522 Create a transfer function system from the matrices of its state and
0 commit comments