euromod.introspect

Below are listed the main public classes of the euromod.introspect module.

Function

clear_cache()

Drop the cached spine extractions.

income_list_components(system, list_name, dataset, extensions)

Effective components of an income list under a dataset and extension set.

iter_real_policies(scope)

Yield the policies of a country or system, skipping reference policies.

system_constant_names(system)

$-prefixed constants defined via DefConst in a system.

system_constant_params(system)

All $-prefixed parameters overridable via run(constantsToOverwrite=...),

system_extension_names(system)

Extension short names the model accepts in run(switches=...).

Functions

euromod.introspect.clear_cache() None

Drop the cached spine extractions.

Only needed when a model is reloaded from changed files within one process; the model is otherwise read-only at run time.

euromod.introspect.income_list_components(system, list_name, dataset=None, extensions=None) list

Effective components of an income list under a dataset and extension set.

Income list membership is not fixed: extensions add and remove components, and a list may be redefined further down the spine. Expanding a list by reading one DefIl definition therefore gives the wrong variables as soon as an extension is switched.

Parameters:
  • system (euromod.System) – System whose spine defines the list.

  • list_name (str) – Income list name, e.g. "ils_dispy".

  • dataset (str, optional) – Dataset whose switch defaults apply. Default is the system’s best match.

  • extensions (list [ tuple [ str, bool ] ], optional) – Switch overrides on top of the dataset defaults, in the form taken by euromod.System.run(). Default is None.

Returns:

(variable, sign) pairs, where sign is '+' or '-'. Nested income lists are expanded recursively with signs multiplied through.

Return type:

list [ tuple [ str, str ] ]

Raises:

IncomeListLookupError – If the list is unknown, inactive under this configuration, or cyclic.

Example

>>> from euromod.introspect import income_list_components
>>> income_list_components(sys, "ils_dispy")
[('yem', '+'), ('yse', '+'), ('tin', '-'), ...]
euromod.introspect.iter_real_policies(scope)

Yield the policies of a country or system, skipping reference policies.

Parameters:

scope (euromod.Country or euromod.System) – Element whose policies container is walked.

Yields:

euromod.Policy – Policies excluding euromod.ReferencePolicy objects, which carry no functions or comment and raise on naive attribute access.

euromod.introspect.system_constant_names(system) set

$-prefixed constants defined via DefConst in a system.

Parameters:

system (euromod.System) – System to inspect.

Returns:

Constant names, extension-independent (every occurrence, whether or not it is active under a particular configuration).

Return type:

set [ str ]

euromod.introspect.system_constant_params(system) dict

All $-prefixed parameters overridable via run(constantsToOverwrite=...), mapped to the groups they are defined with.

constantsToOverwrite is keyed by (name, group), and uprating factors such as $f_cpi are parameters of the Uprate function keyed by year-group rather than DefConst entries — so validating an override against system_constant_names() alone would reject them. This walks every function.

Parameters:

system (euromod.System) – System to inspect.

Returns:

Parameter name -> the groups it is defined with ('' when ungrouped).

Return type:

dict [ str, set [ str ] ]

Example

>>> from euromod.introspect import system_constant_params
>>> params = system_constant_params(sys)
>>> sorted(params["$f_cpi"])[:3]
['2021', '2022', '2023']
euromod.introspect.system_extension_names(system) set

Extension short names the model accepts in run(switches=...).

A switch the model does not know is silently dropped by the engine, which only reports “An error occurred during the processing of the ExtensionSwitches” to the console: the simulation then completes normally while the behaviour the caller asked for never happened. Validate against this set before running.

Parameters:

system (euromod.System) – System whose country and dataset defaults are inspected.

Returns:

Short names from the country’s extensions (local plus model-wide, i.e. everything declared in Config/SWITCHABLEPOLICYCONFIG.xml, including add-on extensions) unioned with the per-dataset switch defaults observed for this system. Empty when neither can be read, which callers should treat as “cannot validate” rather than “nothing is valid”.

Return type:

set [ str ]

Example

>>> from euromod import Model
>>> from euromod.introspect import system_extension_names
>>> mod = Model("C:\EUROMOD_RELEASES_I6.0+")
>>> "LMA_trans" in system_extension_names(mod.countries['BE'].systems['BE_2025'])
True