1010
1111# Python 3 compatibility (needs to go here)
1212from __future__ import print_function
13- from __future__ import division # for _convertToStateSpace
13+ from __future__ import division # for _convert_to_statespace
1414
1515"""Copyright (c) 2010 by California Institute of Technology
1616All rights reserved.
@@ -527,7 +527,7 @@ def __add__(self, other):
527527 D = self .D + other
528528 dt = self .dt
529529 else :
530- other = _convertToStateSpace (other )
530+ other = _convert_to_statespace (other )
531531
532532 # Check to make sure the dimensions are OK
533533 if ((self .inputs != other .inputs ) or
@@ -577,7 +577,7 @@ def __mul__(self, other):
577577 D = self .D * other
578578 dt = self .dt
579579 else :
580- other = _convertToStateSpace (other )
580+ other = _convert_to_statespace (other )
581581
582582 # Check to make sure the dimensions are OK
583583 if self .inputs != other .outputs :
@@ -614,7 +614,7 @@ def __rmul__(self, other):
614614
615615 # is lti, and convertible?
616616 if isinstance (other , LTI ):
617- return _convertToStateSpace (other ) * self
617+ return _convert_to_statespace (other ) * self
618618
619619 # try to treat this as a matrix
620620 try :
@@ -839,7 +839,7 @@ def zero(self):
839839 def feedback (self , other = 1 , sign = - 1 ):
840840 """Feedback interconnection between two LTI systems."""
841841
842- other = _convertToStateSpace (other )
842+ other = _convert_to_statespace (other )
843843
844844 # Check to make sure the dimensions are OK
845845 if (self .inputs != other .outputs ) or (self .outputs != other .inputs ):
@@ -907,7 +907,7 @@ def lft(self, other, nu=-1, ny=-1):
907907 Dimension of (plant) control input.
908908
909909 """
910- other = _convertToStateSpace (other )
910+ other = _convert_to_statespace (other )
911911 # maximal values for nu, ny
912912 if ny == - 1 :
913913 ny = min (other .inputs , self .outputs )
@@ -1061,7 +1061,7 @@ def append(self, other):
10611061 The second model is converted to state-space if necessary, inputs and
10621062 outputs are appended and their order is preserved"""
10631063 if not isinstance (other , StateSpace ):
1064- other = _convertToStateSpace (other )
1064+ other = _convert_to_statespace (other )
10651065
10661066 self .dt = common_timebase (self .dt , other .dt )
10671067
@@ -1186,16 +1186,16 @@ def is_static_gain(self):
11861186
11871187
11881188# TODO: add discrete time check
1189- def _convertToStateSpace (sys , ** kw ):
1189+ def _convert_to_statespace (sys , ** kw ):
11901190 """Convert a system to state space form (if needed).
11911191
11921192 If sys is already a state space, then it is returned. If sys is a
11931193 transfer function object, then it is converted to a state space and
11941194 returned. If sys is a scalar, then the number of inputs and outputs can
11951195 be specified manually, as in:
11961196
1197- >>> sys = _convertToStateSpace (3.) # Assumes inputs = outputs = 1
1198- >>> sys = _convertToStateSpace (1., inputs=3, outputs=2)
1197+ >>> sys = _convert_to_statespace (3.) # Assumes inputs = outputs = 1
1198+ >>> sys = _convert_to_statespace (1., inputs=3, outputs=2)
11991199
12001200 In the latter example, A = B = C = 0 and D = [[1., 1., 1.]
12011201 [1., 1., 1.]].
@@ -1205,7 +1205,7 @@ def _convertToStateSpace(sys, **kw):
12051205
12061206 if isinstance (sys , StateSpace ):
12071207 if len (kw ):
1208- raise TypeError ("If sys is a StateSpace, _convertToStateSpace "
1208+ raise TypeError ("If sys is a StateSpace, _convert_to_statespace "
12091209 "cannot take keywords." )
12101210
12111211 # Already a state space system; just return it
@@ -1221,7 +1221,7 @@ def _convertToStateSpace(sys, **kw):
12211221 from slycot import td04ad
12221222 if len (kw ):
12231223 raise TypeError ("If sys is a TransferFunction, "
1224- "_convertToStateSpace cannot take keywords." )
1224+ "_convert_to_statespace cannot take keywords." )
12251225
12261226 # Change the numerator and denominator arrays so that the transfer
12271227 # function matrix has a common denominator.
@@ -1281,11 +1281,8 @@ def _convertToStateSpace(sys, **kw):
12811281 try :
12821282 D = _ssmatrix (sys )
12831283 return StateSpace ([], [], [], D )
1284- except Exception as e :
1285- print ("Failure to assume argument is matrix-like in"
1286- " _convertToStateSpace, result %s" % e )
1287-
1288- raise TypeError ("Can't convert given type to StateSpace system." )
1284+ except :
1285+ raise TypeError ("Can't convert given type to StateSpace system." )
12891286
12901287
12911288# TODO: add discrete time option
@@ -1662,14 +1659,14 @@ def tf2ss(*args):
16621659 from .xferfcn import TransferFunction
16631660 if len (args ) == 2 or len (args ) == 3 :
16641661 # Assume we were given the num, den
1665- return _convertToStateSpace (TransferFunction (* args ))
1662+ return _convert_to_statespace (TransferFunction (* args ))
16661663
16671664 elif len (args ) == 1 :
16681665 sys = args [0 ]
16691666 if not isinstance (sys , TransferFunction ):
16701667 raise TypeError ("tf2ss(sys): sys must be a TransferFunction "
16711668 "object." )
1672- return _convertToStateSpace (sys )
1669+ return _convert_to_statespace (sys )
16731670 else :
16741671 raise ValueError ("Needs 1 or 2 arguments; received %i." % len (args ))
16751672
@@ -1769,5 +1766,5 @@ def ssdata(sys):
17691766 (A, B, C, D): list of matrices
17701767 State space data for the system
17711768 """
1772- ss = _convertToStateSpace (sys )
1769+ ss = _convert_to_statespace (sys )
17731770 return ss .A , ss .B , ss .C , ss .D
0 commit comments