Base class for solvers with parameters stored in dictionaries.
Data dicts whose keys are fixed (non-extensible):
self.*_prm
These are filled in subclasses by, e.g.,
self.physical_prm['someprm'] = value
or
self.physical_prm.update({'someprm': value,
'another': other_value})
The dictionary with all legal keys should be defined in the subclass.
List of the dictionaries with fixed keys:
self._prm_list = [self.physical_prm, self.numerical_prm]
Subclasses define any self._*_prm dicts and append
them to self._prm_list.
Meta data given by the user can be stored in self.user_prm.
This attribute is None if meta data are not allowed,
otherwise it is a dictionary that holds parameters.
self._type_check[prm] is defined if we want to type check
a parameter prm.
if self._type_check[prm] is True (or False), prm must
be None, of the same type as the previous registered
value of prm, or any number (float, int, complex) if
the previous value prm was any number.
Methods
|
|
|
|
__init__
|
__init__ ( self )
|
|
_prm_dict_names
|
_prm_dict_names ( self )
Return the name of all self.*_prm dictionaries.
|
|
_update
|
_update ( self )
Check data consistency and make updates.
|
|
_usage_set
|
_usage_set ( self )
Print the name of parameters that can be set.
|
|
dicts2namespace
|
dicts2namespace (
self,
namespace,
dicts,
overwrite=True,
)
Make namespace variables out of dict items.
|
|
dicts2namespace2
|
dicts2namespace2 (
self,
namespace,
dicts,
)
As dicts2namespace2, but use exec.
|
|
namespace2dicts
|
namespace2dicts (
self,
namespace,
dicts,
)
Update dicts from short-form in a namespace.
|
|
properties
|
properties ( self, global_namespace )
Make properties out of local dictionaries.
|
|
set
|
set ( self, **kwargs )
Set kwargs data in parameter dictionaries.
Exceptions
|
|
NameError, 'parameter "%s" not registered' % prm
ValueError, 'self._prm_list is wrong (empty)'
|
|
|
set_in_dict
|
set_in_dict (
self,
prm,
value,
d,
)
Set d[prm]=value, but check if prm is registered in class
dictionaries, if the type is acceptable, etc.
Exceptions
|
|
TypeError, '%s has type %s, not %s or None' %(prm, type(kwargs [ prm ] ), type(d [ prm ] ) )
|
|
|