1515
1616# Package level default values
1717_control_defaults = {
18- # No package level defaults (yet)
18+ 'control.default_dt' : 0
1919}
2020defaults = dict (_control_defaults )
2121
@@ -59,6 +59,9 @@ def reset_defaults():
5959 from .statesp import _statesp_defaults
6060 defaults .update (_statesp_defaults )
6161
62+ from .iosys import _iosys_defaults
63+ defaults .update (_iosys_defaults )
64+
6265
6366def _get_param (module , param , argval = None , defval = None , pop = False ):
6467 """Return the default value for a configuration option.
@@ -144,7 +147,7 @@ def use_numpy_matrix(flag=True, warn=True):
144147 Parameters
145148 ----------
146149 flag : bool
147- If flag is `True` (default), use the Numpy (soon to be deprecated)
150+ If flag is `True` (default), use the deprecated Numpy
148151 `matrix` class to represent matrices in the `~control.StateSpace`
149152 class and functions. If flat is `False`, then matrices are
150153 represented by a 2D `ndarray` object.
@@ -154,10 +157,15 @@ class and functions. If flat is `False`, then matrices are
154157 of the Numpy `matrix` class. Set `warn` to false to omit display of
155158 the warning message.
156159
160+ Notes
161+ -----
162+ Prior to release 0.9.x, the default type for 2D arrays is the Numpy
163+ `matrix` class. Starting in release 0.9.0, the default type for state
164+ space operations is a 2D array.
157165 """
158166 if flag and warn :
159- warnings .warn ("Return type numpy.matrix is soon to be deprecated." ,
160- stacklevel = 2 )
167+ warnings .warn ("Return type numpy.matrix is deprecated." ,
168+ stacklevel = 2 , category = DeprecationWarning )
161169 set_defaults ('statesp' , use_numpy_matrix = flag )
162170
163171def use_legacy_defaults (version ):
@@ -166,9 +174,56 @@ def use_legacy_defaults(version):
166174 Parameters
167175 ----------
168176 version : string
169- version number of the defaults desired. Currently only supports ` 0.8.3`.
177+ Version number of the defaults desired. Ranges from '0.1' to ' 0.8.4'.
170178 """
171- if version == '0.8.3' :
172- use_numpy_matrix (True ) # alternatively: set_defaults('statesp', use_numpy_matrix=True)
173- else :
174- raise ValueError ('''version number not recognized. Possible values are: ['0.8.3']''' )
179+ import re
180+ (major , minor , patch ) = (None , None , None ) # default values
181+
182+ # Early release tag format: REL-0.N
183+ match = re .match ("REL-0.([12])" , version )
184+ if match : (major , minor , patch ) = (0 , int (match .group (1 )), 0 )
185+
186+ # Early release tag format: control-0.Np
187+ match = re .match ("control-0.([3-6])([a-d])" , version )
188+ if match : (major , minor , patch ) = \
189+ (0 , int (match .group (1 )), ord (match .group (2 )) - ord ('a' ) + 1 )
190+
191+ # Early release tag format: v0.Np
192+ match = re .match ("[vV]?0.([3-6])([a-d])" , version )
193+ if match : (major , minor , patch ) = \
194+ (0 , int (match .group (1 )), ord (match .group (2 )) - ord ('a' ) + 1 )
195+
196+ # Abbreviated version format: vM.N or M.N
197+ match = re .match ("([vV]?[0-9]).([0-9])" , version )
198+ if match : (major , minor , patch ) = \
199+ (int (match .group (1 )), int (match .group (2 )), 0 )
200+
201+ # Standard version format: vM.N.P or M.N.P
202+ match = re .match ("[vV]?([0-9]).([0-9]).([0-9])" , version )
203+ if match : (major , minor , patch ) = \
204+ (int (match .group (1 )), int (match .group (2 )), int (match .group (3 )))
205+
206+ # Make sure we found match
207+ if major is None or minor is None :
208+ raise ValueError ("Version number not recognized. Try M.N.P format." )
209+
210+ #
211+ # Go backwards through releases and reset defaults
212+ #
213+
214+ # Version 0.9.0:
215+ if major == 0 and minor < 9 :
216+ # switched to 'array' as default for state space objects
217+ set_defaults ('statesp' , use_numpy_matrix = True )
218+
219+ # switched to 0 (=continuous) as default timestep
220+ set_defaults ('control' , default_dt = None )
221+
222+ # changed iosys naming conventions
223+ set_defaults ('iosys' , state_name_delim = '.' ,
224+ duplicate_system_name_prefix = 'copy of ' ,
225+ duplicate_system_name_suffix = '' ,
226+ linearized_system_name_prefix = '' ,
227+ linearized_system_name_suffix = '_linearized' )
228+
229+ return (major , minor , patch )
0 commit comments