- class ModelsMixin¶
This class is meant to be combined by the Base class in multiple inheritence. This approach is used since Network and Algorithm do not need to have any
modelsattribute, while Phase, Geometry, and Physics do. By using a mixin class, all objects can inherit from Base while the model functionality can be added only where needed.
The following table gives a brief overview of the methods that are added to the object by this mixin. In addition to these methods, a
modelsattribute is also added, which is a dictionary that contains all of the models and their parameters.
Method or Attribute
Add a given model and parameters to the object
Runs the model(s) to recalculate data
Removes specified model as well as it’s data
- add_model(propname, model, regen_mode='', **kwargs)¶
Adds a new model to the models dictionary (
propname (string) – The name of the property to be calculated by the model.
model (function) – A reference (handle) to the function to be used.
regen_mode (string) –
Controls how/when the model is run (See Notes for more details). Options are:
’normal’ - (default) The model is run directly upon being assiged, and also run every time
’constant’ - The model is run directly upon being assigned, but is not called again, thus making it’s data act like a constant. If, however, the data is deleted from the object it will be regenerated again.
’deferred’ - Is not run upon being assigned, but is run the first time that
’explicit’ - Is only run if the model name is explicitly passed to the
regenerate_modelsmethod. This allows full control of when the model is run.
- regenerate_models(propnames=None, exclude=, deep=False)¶
Re-runs the specified model or models.
propnames (string or list of strings) – The list of property names to be regenerated. If None are given then ALL models are re-run (except for those whose
exclude (list of strings) – Since the default behavior is to run ALL models, this can be used to exclude specific models. It may be more convenient to supply as list of 2 models to exclude than to specify 8 models to include.
deep (boolean) – Specifies whether or not to regenerate models on all associated objects. For instance, if
True, then all Physics models will be regenerated when method is called on the corresponding Phase. The default is
False. The method does not work in reverse, so regenerating models on a Physics will not update a Phase.
- remove_model(propname=None, mode=['model', 'data'])¶
Removes model and data from object.
propname (string or list of strings) – The property or list of properties to remove
mode (list of strings) –
Controls what is removed. Options are:
’model’ : Removes the model but not any numerical data that may already exist.
’data’ : Removes the data but leaves the model.
both. (The default is) –