7777
7878# Define module default parameter values
7979_statesp_defaults = {
80- 'statesp.use_numpy_matrix' : False , # False is default in 0.9.0 and above
8180 'statesp.remove_useless_states' : False ,
8281 'statesp.latex_num_format' : '.3g' ,
8382 'statesp.latex_repr_type' : 'partitioned' ,
@@ -104,11 +103,8 @@ def _ssmatrix(data, axis=1):
104103 arr : 2D array, with shape (0, 0) if a is empty
105104
106105 """
107- # Convert the data into an array or matrix, as configured
108- if config .defaults ['statesp.use_numpy_matrix' ]:
109- arr = np .matrix (data , dtype = float )
110- else :
111- arr = np .array (data , dtype = float )
106+ # Convert the data into an array
107+ arr = np .array (data , dtype = float )
112108 ndim = arr .ndim
113109 shape = arr .shape
114110
@@ -202,12 +198,7 @@ class StateSpace(LTI):
202198 -----
203199 The main data members in the ``StateSpace`` class are the A, B, C, and D
204200 matrices. The class also keeps track of the number of states (i.e.,
205- the size of A). The data format used to store state space matrices is
206- set using the value of `config.defaults['use_numpy_matrix']`. If True
207- (default), the state space elements are stored as `numpy.matrix` objects;
208- otherwise they are `numpy.ndarray` objects. The
209- :func:`~control.use_numpy_matrix` function can be used to set the storage
210- type.
201+ the size of A).
211202
212203 A discrete time system is created by specifying a nonzero 'timebase', dt
213204 when the system is constructed:
@@ -355,10 +346,8 @@ def __init__(self, *args, init_namedio=True, **kwargs):
355346 elif kwargs :
356347 raise TypeError ("unrecognized keyword(s): " , str (kwargs ))
357348
358- # Reset shapes (may not be needed once np.matrix support is removed)
349+ # Reset shape if system is static
359350 if self ._isstatic ():
360- # static gain
361- # matrix's default "empty" shape is 1x0
362351 A .shape = (0 , 0 )
363352 B .shape = (0 , self .ninputs )
364353 C .shape = (self .noutputs , 0 )
@@ -927,18 +916,17 @@ def horner(self, x, warn_infinite=True):
927916 x_arr = np .atleast_1d (x ).astype (complex , copy = False )
928917
929918 # return fast on systems with 0 or 1 state
930- if not config .defaults ['statesp.use_numpy_matrix' ]:
931- if self .nstates == 0 :
932- return self .D [:, :, np .newaxis ] \
933- * np .ones_like (x_arr , dtype = complex )
934- if self .nstates == 1 :
935- with np .errstate (divide = 'ignore' , invalid = 'ignore' ):
936- out = self .C [:, :, np .newaxis ] \
937- / (x_arr - self .A [0 , 0 ]) \
938- * self .B [:, :, np .newaxis ] \
939- + self .D [:, :, np .newaxis ]
940- out [np .isnan (out )] = complex (np .inf , np .nan )
941- return out
919+ if self .nstates == 0 :
920+ return self .D [:, :, np .newaxis ] \
921+ * np .ones_like (x_arr , dtype = complex )
922+ elif self .nstates == 1 :
923+ with np .errstate (divide = 'ignore' , invalid = 'ignore' ):
924+ out = self .C [:, :, np .newaxis ] \
925+ / (x_arr - self .A [0 , 0 ]) \
926+ * self .B [:, :, np .newaxis ] \
927+ + self .D [:, :, np .newaxis ]
928+ out [np .isnan (out )] = complex (np .inf , np .nan )
929+ return out
942930
943931 try :
944932 out = self .slycot_laub (x_arr )
0 commit comments