macrostat.models.model_manager#

Model Manager

This module provides a manager for all models in the MacroStat library. It allows for easy access to all models, as well as the ability to get the classes for a specific model.

Functions

get_available_models([model_directory])

Get all available models in the models directory.

get_model(modelname[, model_directory])

Get a model from the models directory.

get_model_classes(modelname[, model_directory])

Get a model from the models directory.

Classes

ModelClasses(Behavior, Parameters, ...)

Container for all model component classes of a specific version.

class macrostat.models.model_manager.ModelClasses(Behavior: Type[Behavior], Parameters: Type[Parameters], Scenarios: Type[Scenarios], Variables: Type[Variables], Model: Type[Model])[source]#

Bases: NamedTuple

Container for all model component classes of a specific version.

Behavior: Type[Behavior]#

Alias for field number 0

Model: Type[Model]#

Alias for field number 4

Parameters: Type[Parameters]#

Alias for field number 1

Scenarios: Type[Scenarios]#

Alias for field number 2

Variables: Type[Variables]#

Alias for field number 3

macrostat.models.model_manager.get_available_models(model_directory=None)[source]#

Get all available models in the models directory.

Parse the models directory and return a list of all available models, which are in subdirectories of the models directory and are named after the model. They are valid when they contain a __init__.py, parameters.py, variables.py, scenarios.py, behavior.py file.

Parameters:

model_directory (str, optional) – The directory to look for models in. If None, uses the directory of this file.

Returns:

A list of all available models.

Return type:

list

macrostat.models.model_manager.get_model(modelname: str, model_directory=None)[source]#

Get a model from the models directory.

Parameters:

modelname (str) – The name of the model to get.

Returns:

Named tuple containing all model component classes

Return type:

ModelClasses

Raises:
  • ValueError – If model name is invalid or model is not available

  • ImportError – If there are problems importing the model components

macrostat.models.model_manager.get_model_classes(modelname: str, model_directory=None)[source]#

Get a model from the models directory.

Parameters:

modelname (str) – The name of the model to get.

Returns:

Named tuple containing all model component classes

Return type:

ModelClasses

Raises:
  • ValueError – If model name is invalid or model is not available

  • ImportError – If there are problems importing the model components