@@ -1434,11 +1434,11 @@ def _convert_to_statespace(sys, **kw):
1434
1434
1435
1435
1436
1436
# 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 ):
1438
1438
"""Generate a random state space.
1439
1439
1440
1440
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.
1442
1442
1443
1443
"""
1444
1444
@@ -1465,6 +1465,8 @@ def _rss_generate(states, inputs, outputs, type, strictly_proper=False):
1465
1465
if outputs < 1 or outputs % 1 :
1466
1466
raise ValueError ("outputs must be a positive integer. outputs = %g." %
1467
1467
outputs )
1468
+ if cdtype not in ['c' , 'd' ]: # pragma: no cover
1469
+ raise ValueError ("cdtype must be `c` or `d`" )
1468
1470
1469
1471
# Make some poles for A. Preallocate a complex array.
1470
1472
poles = zeros (states ) + zeros (states ) * 0.j
@@ -1484,16 +1486,16 @@ def _rss_generate(states, inputs, outputs, type, strictly_proper=False):
1484
1486
i += 2
1485
1487
elif rand () < pReal or i == states - 1 :
1486
1488
# No-oscillation pole.
1487
- if type == 'c' :
1489
+ if cdtype == 'c' :
1488
1490
poles [i ] = - exp (randn ()) + 0.j
1489
- elif type == 'd' :
1491
+ else :
1490
1492
poles [i ] = 2. * rand () - 1.
1491
1493
i += 1
1492
1494
else :
1493
1495
# Complex conjugate pair of oscillating poles.
1494
- if type == 'c' :
1496
+ if cdtype == 'c' :
1495
1497
poles [i ] = complex (- exp (randn ()), 3. * exp (randn ()))
1496
- elif type == 'd' :
1498
+ else :
1497
1499
mag = rand ()
1498
1500
phase = 2. * math .pi * rand ()
1499
1501
poles [i ] = complex (mag * cos (phase ), mag * sin (phase ))
@@ -1546,7 +1548,11 @@ def _rss_generate(states, inputs, outputs, type, strictly_proper=False):
1546
1548
C = C * Cmask
1547
1549
D = D * Dmask if not strictly_proper else zeros (D .shape )
1548
1550
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 )
1550
1556
1551
1557
1552
1558
# Convert a MIMO system to a SISO system
@@ -1825,15 +1831,14 @@ def rss(states=1, outputs=1, inputs=1, strictly_proper=False):
1825
1831
1826
1832
Parameters
1827
1833
----------
1828
- states : integer
1834
+ states : int
1829
1835
Number of state variables
1830
- inputs : integer
1836
+ inputs : int
1831
1837
Number of system inputs
1832
- outputs : integer
1838
+ outputs : inte
1833
1839
Number of system outputs
1834
1840
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).
1837
1842
1838
1843
Returns
1839
1844
-------
@@ -1867,12 +1872,15 @@ def drss(states=1, outputs=1, inputs=1, strictly_proper=False):
1867
1872
1868
1873
Parameters
1869
1874
----------
1870
- states : integer
1875
+ states : int
1871
1876
Number of state variables
1872
1877
inputs : integer
1873
1878
Number of system inputs
1874
- outputs : integer
1879
+ outputs : int
1875
1880
Number of system outputs
1881
+ strictly_proper: bool, optional
1882
+ If set to 'True', returns a proper system (no direct term).
1883
+
1876
1884
1877
1885
Returns
1878
1886
-------
0 commit comments