@@ -1519,7 +1519,7 @@ def output(self, t, x, u=None, params=None):
15191519
15201520
15211521# TODO: add discrete time check
1522- def _convert_to_statespace (sys ):
1522+ def _convert_to_statespace (sys , use_prefix_suffix = False ):
15231523 """Convert a system to state space form (if needed).
15241524
15251525 If sys is already a state space, then it is returned. If sys is a
@@ -1556,11 +1556,10 @@ def _convert_to_statespace(sys):
15561556 denorder , den , num , tol = 0 )
15571557
15581558 states = ssout [0 ]
1559- return StateSpace (
1559+ newsys = StateSpace (
15601560 ssout [1 ][:states , :states ], ssout [2 ][:states , :sys .ninputs ],
1561- ssout [3 ][:sys .noutputs , :states ], ssout [4 ], sys .dt ,
1562- inputs = sys .input_labels , outputs = sys .output_labels ,
1563- name = sys .name )
1561+ ssout [3 ][:sys .noutputs , :states ], ssout [4 ], sys .dt )
1562+
15641563 except ImportError :
15651564 # No Slycot. Scipy tf->ss can't handle MIMO, but static
15661565 # MIMO is an easy special case we can check for here
@@ -1585,9 +1584,13 @@ def _convert_to_statespace(sys):
15851584 # the squeeze
15861585 A , B , C , D = \
15871586 sp .signal .tf2ss (squeeze (sys .num ), squeeze (sys .den ))
1588- return StateSpace (
1589- A , B , C , D , sys .dt , inputs = sys .input_labels ,
1590- outputs = sys .output_labels , name = sys .name )
1587+ newsys = StateSpace (A , B , C , D , sys .dt )
1588+
1589+ # Copy over the signal (and system) names
1590+ newsys ._copy_names (
1591+ sys ,
1592+ prefix_suffix_name = 'converted' if use_prefix_suffix else None )
1593+ return newsys
15911594
15921595 elif isinstance (sys , FrequencyResponseData ):
15931596 raise TypeError ("Can't convert FRD to StateSpace system." )
@@ -1600,7 +1603,6 @@ def _convert_to_statespace(sys):
16001603 except Exception :
16011604 raise TypeError ("Can't convert given type to StateSpace system." )
16021605
1603-
16041606# TODO: add discrete time option
16051607def _rss_generate (
16061608 states , inputs , outputs , cdtype , strictly_proper = False , name = None ):
@@ -1914,7 +1916,8 @@ def tf2ss(*args, **kwargs):
19141916 if not isinstance (sys , TransferFunction ):
19151917 raise TypeError ("tf2ss(sys): sys must be a TransferFunction "
19161918 "object." )
1917- return StateSpace (_convert_to_statespace (sys ), ** kwargs )
1919+ return StateSpace (_convert_to_statespace (sys , use_prefix_suffix = True ),
1920+ ** kwargs )
19181921 else :
19191922 raise ValueError ("Needs 1 or 2 arguments; received %i." % len (args ))
19201923
0 commit comments