@@ -1434,11 +1434,11 @@ def _convert_to_statespace(sys, **kw):
14341434
14351435
14361436# TODO: add discrete time option
1437- def _rss_generate (states , inputs , outputs , type , strictly_proper = False ):
1437+ def _rss_generate (states , inputs , outputs , cdtype , strictly_proper = False ):
14381438 """Generate a random state space.
14391439
14401440 This does the actual random state space generation expected from rss and
1441- drss. type is 'c' for continuous systems and 'd' for discrete systems.
1441+ drss. cdtype is 'c' for continuous systems and 'd' for discrete systems.
14421442
14431443 """
14441444
@@ -1465,6 +1465,8 @@ def _rss_generate(states, inputs, outputs, type, strictly_proper=False):
14651465 if outputs < 1 or outputs % 1 :
14661466 raise ValueError ("outputs must be a positive integer. outputs = %g." %
14671467 outputs )
1468+ if cdtype not in ['c' , 'd' ]: # pragma: no cover
1469+ raise ValueError ("cdtype must be `c` or `d`" )
14681470
14691471 # Make some poles for A. Preallocate a complex array.
14701472 poles = zeros (states ) + zeros (states ) * 0.j
@@ -1484,16 +1486,16 @@ def _rss_generate(states, inputs, outputs, type, strictly_proper=False):
14841486 i += 2
14851487 elif rand () < pReal or i == states - 1 :
14861488 # No-oscillation pole.
1487- if type == 'c' :
1489+ if cdtype == 'c' :
14881490 poles [i ] = - exp (randn ()) + 0.j
1489- elif type == 'd' :
1491+ else :
14901492 poles [i ] = 2. * rand () - 1.
14911493 i += 1
14921494 else :
14931495 # Complex conjugate pair of oscillating poles.
1494- if type == 'c' :
1496+ if cdtype == 'c' :
14951497 poles [i ] = complex (- exp (randn ()), 3. * exp (randn ()))
1496- elif type == 'd' :
1498+ else :
14971499 mag = rand ()
14981500 phase = 2. * math .pi * rand ()
14991501 poles [i ] = complex (mag * cos (phase ), mag * sin (phase ))
@@ -1546,7 +1548,11 @@ def _rss_generate(states, inputs, outputs, type, strictly_proper=False):
15461548 C = C * Cmask
15471549 D = D * Dmask if not strictly_proper else zeros (D .shape )
15481550
1549- return StateSpace (A , B , C , D )
1551+ if cdtype == 'c' :
1552+ ss_args = (A , B , C , D )
1553+ else :
1554+ ss_args = (A , B , C , D , True )
1555+ return StateSpace (* ss_args )
15501556
15511557
15521558# Convert a MIMO system to a SISO system
@@ -1825,15 +1831,14 @@ def rss(states=1, outputs=1, inputs=1, strictly_proper=False):
18251831
18261832 Parameters
18271833 ----------
1828- states : integer
1834+ states : int
18291835 Number of state variables
1830- inputs : integer
1836+ inputs : int
18311837 Number of system inputs
1832- outputs : integer
1838+ outputs : inte
18331839 Number of system outputs
18341840 strictly_proper : bool, optional
1835- If set to 'True', returns a proper system (no direct term). Default
1836- value is 'False'.
1841+ If set to 'True', returns a proper system (no direct term).
18371842
18381843 Returns
18391844 -------
@@ -1867,12 +1872,15 @@ def drss(states=1, outputs=1, inputs=1, strictly_proper=False):
18671872
18681873 Parameters
18691874 ----------
1870- states : integer
1875+ states : int
18711876 Number of state variables
18721877 inputs : integer
18731878 Number of system inputs
1874- outputs : integer
1879+ outputs : int
18751880 Number of system outputs
1881+ strictly_proper: bool, optional
1882+ If set to 'True', returns a proper system (no direct term).
1883+
18761884
18771885 Returns
18781886 -------
0 commit comments