7272# Define module default parameter values
7373_statesp_defaults = {
7474 'statesp.use_numpy_matrix' : False , # False is default in 0.9.0 and above
75- 'statesp.remove_useless_states' : True ,
75+ 'statesp.remove_useless_states' : False ,
7676 'statesp.latex_num_format' : '.3g' ,
7777 'statesp.latex_repr_type' : 'partitioned' ,
7878 }
@@ -217,8 +217,7 @@ class StateSpace(LTI):
217217 __array_priority__ = 11 # override ndarray and matrix types
218218
219219 def __init__ (self , * args , ** kwargs ):
220- """
221- StateSpace(A, B, C, D[, dt])
220+ """StateSpace(A, B, C, D[, dt])
222221
223222 Construct a state space object.
224223
@@ -228,6 +227,13 @@ def __init__(self, *args, **kwargs):
228227 True for unspecified sampling time). To call the copy constructor,
229228 call StateSpace(sys), where sys is a StateSpace object.
230229
230+ The `remove_useless_states` keyword can be used to scan the A, B, and
231+ C matrices for rows or columns of zeros. If the zeros are such that a
232+ particular state has no effect on the input-output dynamics, then that
233+ state is removed from the A, B, and C matrices. If not specified, the
234+ value is read from `config.defaults['statesp.remove_useless_states']
235+ (default = False).
236+
231237 """
232238 # first get A, B, C, D matrices
233239 if len (args ) == 4 :
@@ -251,8 +257,8 @@ def __init__(self, *args, **kwargs):
251257 "Expected 1, 4, or 5 arguments; received %i." % len (args ))
252258
253259 # Process keyword arguments
254- remove_useless = kwargs .get (
255- 'remove_useless ' ,
260+ remove_useless_states = kwargs .get (
261+ 'remove_useless_states ' ,
256262 config .defaults ['statesp.remove_useless_states' ])
257263
258264 # Convert all matrices to standard form
@@ -321,7 +327,7 @@ def __init__(self, *args, **kwargs):
321327 raise ValueError ("C and D must have the same number of rows." )
322328
323329 # Check for states that don't do anything, and remove them.
324- if remove_useless :
330+ if remove_useless_states :
325331 self ._remove_useless_states ()
326332
327333 def _remove_useless_states (self ):
@@ -1274,7 +1280,7 @@ def _convert_to_statespace(sys, **kw):
12741280 # Generate a simple state space system of the desired dimension
12751281 # The following Doesn't work due to inconsistencies in ltisys:
12761282 # return StateSpace([[]], [[]], [[]], eye(outputs, inputs))
1277- return StateSpace (0. , zeros ((1 , inputs )), zeros ((outputs , 1 )),
1283+ return StateSpace ([] , zeros ((0 , inputs )), zeros ((outputs , 0 )),
12781284 sys * ones ((outputs , inputs )))
12791285
12801286 # If this is a matrix, try to create a constant feedthrough
0 commit comments