72
72
# Define module default parameter values
73
73
_statesp_defaults = {
74
74
'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 ,
76
76
'statesp.latex_num_format' : '.3g' ,
77
77
'statesp.latex_repr_type' : 'partitioned' ,
78
78
}
@@ -217,8 +217,7 @@ class StateSpace(LTI):
217
217
__array_priority__ = 11 # override ndarray and matrix types
218
218
219
219
def __init__ (self , * args , ** kwargs ):
220
- """
221
- StateSpace(A, B, C, D[, dt])
220
+ """StateSpace(A, B, C, D[, dt])
222
221
223
222
Construct a state space object.
224
223
@@ -228,6 +227,13 @@ def __init__(self, *args, **kwargs):
228
227
True for unspecified sampling time). To call the copy constructor,
229
228
call StateSpace(sys), where sys is a StateSpace object.
230
229
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
+
231
237
"""
232
238
# first get A, B, C, D matrices
233
239
if len (args ) == 4 :
@@ -251,8 +257,8 @@ def __init__(self, *args, **kwargs):
251
257
"Expected 1, 4, or 5 arguments; received %i." % len (args ))
252
258
253
259
# Process keyword arguments
254
- remove_useless = kwargs .get (
255
- 'remove_useless ' ,
260
+ remove_useless_states = kwargs .get (
261
+ 'remove_useless_states ' ,
256
262
config .defaults ['statesp.remove_useless_states' ])
257
263
258
264
# Convert all matrices to standard form
@@ -321,7 +327,7 @@ def __init__(self, *args, **kwargs):
321
327
raise ValueError ("C and D must have the same number of rows." )
322
328
323
329
# Check for states that don't do anything, and remove them.
324
- if remove_useless :
330
+ if remove_useless_states :
325
331
self ._remove_useless_states ()
326
332
327
333
def _remove_useless_states (self ):
@@ -1274,7 +1280,7 @@ def _convert_to_statespace(sys, **kw):
1274
1280
# Generate a simple state space system of the desired dimension
1275
1281
# The following Doesn't work due to inconsistencies in ltisys:
1276
1282
# return StateSpace([[]], [[]], [[]], eye(outputs, inputs))
1277
- return StateSpace (0. , zeros ((1 , inputs )), zeros ((outputs , 1 )),
1283
+ return StateSpace ([] , zeros ((0 , inputs )), zeros ((outputs , 0 )),
1278
1284
sys * ones ((outputs , inputs )))
1279
1285
1280
1286
# If this is a matrix, try to create a constant feedthrough
0 commit comments