euromod.core

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

Classes

ConsumptionTaxFactor

-

ConsumptionTaxFactorYear

-

Country

Country-specific EUROMOD tax-benefit model.

Dataset

Dataset available in a country model.

DatasetInSystem

Datasets available in a system model.

Extension

EUROMOD extensions.

ExtensionSwitch

A class containing the extension switches of an object.

Function

Functions implemented in a country policy.

FunctionInSystem

Functions implemented in a policy for a specific system.

IndTaxInfoContainer

Container class storing Country objects.

Model

Base class of the Euromod Connector instantiating the microsimulation model

Parameter

Parameters set up in a function.

ParameterInSystem

Parameters set up in a function for a specific system.

Policy

Policy rules modeled in a country.

PolicyInSystem

Policy rules modeled in a system.

ReferencePolicy

Object storing the reference policies.

Simulation

Object storing the simulation results.

System

A EUROMOD tax-benefit system.

UprateFactor

-

UprateFactorYear

-

UprateFactorYearsContainer

Container class storing Country objects.

class euromod.core.ConsumptionTaxFactor(*args)

Overview

Attributes

ID

Identifier for ConsumptionTaxFactor

coicopCode

COICOP code related to consumption tax

coicopCodeVersion

Combined COICOP code and version

coicopLabel

Label for the COICOP code

coicopVersion

Version of the COICOP code

comment

Comment regarding the consumption tax factor

name

Name of the consumption tax factor

nameITT

ITT Name of the consumption tax factor

paramType

Parameter type, e.g., VAT Rates

parent

-

unit

Unit of the consumption tax factor, e.g., percentage

values

Container for the consumption tax values for respective years

Attributes

ID: str

Identifier for ConsumptionTaxFactor

coicopCode: str

COICOP code related to consumption tax

coicopCodeVersion: str

Combined COICOP code and version

coicopLabel: str

Label for the COICOP code

coicopVersion: str

Version of the COICOP code

comment: str

Comment regarding the consumption tax factor

name: str

Name of the consumption tax factor

nameITT: str

ITT Name of the consumption tax factor

paramType: str

Parameter type, e.g., VAT Rates

parent: Country
unit: str

Unit of the consumption tax factor, e.g., percentage

values: IndTaxInfoContainer

Container for the consumption tax values for respective years

class euromod.core.ConsumptionTaxFactorYear(*args)

Overview

Attributes

indTaxID

Identifier for the individual tax in this year

parent

-

value

Tax factor value for the specified year

year

Year associated with this tax factor

Attributes

indTaxID: str

Identifier for the individual tax in this year

parent: ConsumptionTaxFactor
value: str

Tax factor value for the specified year

year: str

Year associated with this tax factor

class euromod.core.Country(country: str, model: Model)

Country-specific EUROMOD tax-benefit model.

This class instantiates the EUROMOD tax benefit model for a given country. A class instance is automatically generated and stored in the attribute countries of the base class Model.

This class contains subclasses of type System, Policy, Dataset and Extension.

Parameters:
  • country (str) – Name of the country. Must be a two-letter country codes, see the Eurostat Glossary:Country codes.

  • model (Model) – A class containing the EUROMOD base model.

Returns:

A class containing the EUROMOD country models.

Return type:

Country

Example

>>> from euromod import Model
>>> mod=Model("C:\EUROMOD_RELEASES_I6.0+")
>>> mod.countries[0]

Overview

Attributes

ct_factors

A Container with ConsumptionTaxFactor objects.

datasets

A Container with Dataset objects.

extensions

A Container with Extension objects. These are the local + model extensions defined.

local_extensions

A Container with Extension objects. These are the local extensions defined for the country.

model

Model Returns the base Model object.

name

Two-letters country code.

policies

A Container with Policy objects.

systems

A Container with System objects.

upratefactors

A Container with UprateFactor objects.

Methods

get_switch_value(ext_name, dataset_name, sys_name)

Get the configuration of the switch.

load_data(ID_DATASET, PATH_DATA)

Load data as a pandas.DataFrame object.

Attributes

ct_factors: container.Container[ConsumptionTaxFactor] | None = None

A Container with ConsumptionTaxFactor objects.

datasets: container.Container[Dataset] | None = None

A Container with Dataset objects.

extensions: container.Container[Extension] | None = None

A Container with Extension objects. These are the local + model extensions defined.

local_extensions: container.Container[Extension] | None = None

A Container with Extension objects. These are the local extensions defined for the country.

model: Model

Model Returns the base Model object.

name: str

Two-letters country code.

policies: container.Container[Policy] | None = None

A Container with Policy objects.

systems: container.Container[System] | None = None

A Container with System objects.

upratefactors: container.Container[UprateFactor] | None = None

A Container with UprateFactor objects.

Methods

get_switch_value(ext_name: str | None = None, dataset_name: str | None = None, sys_name: str | None = None)

Get the configuration of the switch.

Parameters:
  • ext_name (str , optional) – Name of the extension. The default is None.

  • dataset_name (str , optional) – Name of the dataset. The default is None.

  • sys_name (str, optional) – Name of the system. The default is None.

Raises:

KeyError – Is raised if ext_name, dataset_name or sys_name, but is not configured in the model.

Returns:

Object containing information how the switch is configured. Note that there is only a value returned if the switch is either explicitly ‘off’ or ‘on’. When it’s configured as n/a in the model no value will be included.

Return type:

Container[ExtensionSwitch]

load_data(ID_DATASET, PATH_DATA=None)

Load data as a pandas.DataFrame object.

Parameters:
  • ID_DATASET (str) – Name of the dataset excluding extension (Note: must be a txt file).

  • PATH_DATA (str, optional) – Path to the dataset. Default is the folder “PATH_TO_EUROMOD_PROJECT/Input”.

Returns:

Dataset is returned as a pandas.DataFrame object.

Return type:

pandas.DataFrame

class euromod.core.Dataset(*args)

Dataset available in a country model.

This class contains the relevant information about a dataset.

Returns:

A class with the country-specific dataset.

Return type:

Dataset

Overview

Attributes

ID

Dataset identifier number.

coicopVersion

COICOP version.

comment

Comment about the dataset.

currency

Currency of the monetary values in the dataset.

decimalSign

Decimal sign

name

Name of the dataset.

parent

The country-specific class.

private

Access type.

readXVariables

Read variables.

system_elements

-

useCommonDefault

Use default.

yearCollection

Year of the dataset collection.

yearInc

Reference year for the income variables.

Attributes

ID: str

Dataset identifier number.

coicopVersion: str = ''

COICOP version.

comment: str = ''

Comment about the dataset.

currency: str = ''

Currency of the monetary values in the dataset.

decimalSign: str = ''

Decimal sign

name: str

Name of the dataset.

parent: Country

The country-specific class.

private: str = 'no'

Access type.

readXVariables: str = 'no'

Read variables.

system_elements: container.Container
useCommonDefault: str = 'no'

Use default.

yearCollection: str

Year of the dataset collection.

yearInc: str

Reference year for the income variables.

class euromod.core.DatasetInSystem

Datasets available in a system model.

Returns:

A class with the system-specific dataset.

Return type:

DatasetInSystem

Overview

Attributes

ID

Dataset identifier number.

bestMatch

If yes, the current dataset is a best match for the specific system.

coicopVersion

COICOP version.

comment

Comment about the dataset.

currency

Currency of the monetary values in the dataset.

dataID

Identifier number of the reference dataset at the country level.

decimalSign

Decimal sign

name

Name of the dataset.

parent

The country specific class.

private

Access type.

readXVariables

Read variables.

sysID

Identifier number of the reference system.

useCommonDefault

Use default.

yearCollection

Year of the dataset collection.

yearInc

Reference year for the income variables.

Attributes

ID: str

Dataset identifier number.

bestMatch: str

If yes, the current dataset is a best match for the specific system.

coicopVersion: str

COICOP version.

comment: str

Comment about the dataset.

currency: str

Currency of the monetary values in the dataset.

dataID: str

Identifier number of the reference dataset at the country level.

decimalSign: str

Decimal sign

name: str

Name of the dataset.

parent: Country

The country specific class.

private: str

Access type.

readXVariables: str

Read variables.

sysID: str

Identifier number of the reference system.

useCommonDefault: str

Use default.

yearCollection: str

Year of the dataset collection.

yearInc: str

Reference year for the income variables.

class euromod.core.Extension(*arg)

EUROMOD extensions.

Returns:

A class with the model extensions.

Return type:

Extension

Overview

Attributes

name

Long name of the extension.

parent

The model base class.

shortName

Short name of the extension.

Attributes

name: str = None

Long name of the extension.

parent: Model

The model base class.

shortName: str = None

Short name of the extension.

class euromod.core.ExtensionSwitch(info, ctry)

A class containing the extension switches of an object.

This class is returned by get_switch_value() method and should not be used by the user as a stand alone.

Returns:

A class with relevant information on the extension switch.

Return type:

ExtensionSwitch

Overview

Attributes

data_name

Name of the applicable dataset.

extension_name

Short name of the extension.

parent

The country-specific class.

sys_name

Name of the applicable system.

value

Value of the switch as configured in EUROOMOD.

Attributes

data_name: str

Name of the applicable dataset.

extension_name: str

Short name of the extension.

parent: Country

The country-specific class.

sys_name: str

Name of the applicable system.

value: str = ''

Value of the switch as configured in EUROOMOD.

class euromod.core.Function(*arg)

Functions implemented in a country policy.

Returns:

A class with country-specific function.

Return type:

Function

Overview

Attributes

ID

Identifier number of the function.

comment

Comment specific to the function.

extensions

A Container of Extension objects in a country.

name

Name of the function.

order

Order of the function in the specific spine.

parameters

A Container of Parameter objects in a country.

parent

The class of the country-specific policy.

polID

Identifier number of the reference policy.

private

Access type.

spineOrder

Order of the function in the spine.

Attributes

ID: str

Identifier number of the function.

comment: str

Comment specific to the function.

extensions: container.Container[Extension] | None = None

A Container of Extension objects in a country.

name: str

Name of the function.

order: str

Order of the function in the specific spine.

parameters: container.Container[Parameter] | None = None

A Container of Parameter objects in a country.

parent: Policy

The class of the country-specific policy.

polID: str

Identifier number of the reference policy.

private: str

Access type.

spineOrder: str

Order of the function in the spine.

class euromod.core.FunctionInSystem(*arg)

Functions implemented in a policy for a specific system.

Returns:

A class with the system-specific function.

Return type:

FunctionInSystem

Overview

Attributes

ID

Identifier number of the function.

comment

Comment specific to the function.

extensions

A Container of Extension objects in a system.

funID

Identifier number of the reference function at country level.

name

Name of the function.

order

Order of the function in the specific spine.

parameters

A Container with ParameterInSystem objects specific to a function.

parent

The class of the country-specific policy.

polID

Identifier number of the reference policy.

private

Access type.

spineOrder

Order of the function in the spine.

switch

Policy switch action.

sysID

Identifier number of the reference policy.

Attributes

ID: str

Identifier number of the function.

comment: str

Comment specific to the function.

extensions: container.Container[Extension]

A Container of Extension objects in a system.

funID: str

Identifier number of the reference function at country level.

name: str

Name of the function.

order: str

Order of the function in the specific spine.

parameters: container.Container[ParameterInSystem] | None = None

A Container with ParameterInSystem objects specific to a function.

parent: Policy

The class of the country-specific policy.

polID: str

Identifier number of the reference policy.

private: str

Access type.

spineOrder: str

Order of the function in the spine.

switch: str

Policy switch action.

sysID: str

Identifier number of the reference policy.

class euromod.core.IndTaxInfoContainer

Container class storing Country objects.

class euromod.core.Model(model_path: str)

Base class of the Euromod Connector instantiating the microsimulation model EUROMOD.

Parameters:

model_path (str) – Path to the EUROMOD project.

Returns:

A class containing the EUROMOD base model.

Return type:

Model

Example

>>> from euromod import Model
>>> mod=Model("C:\EUROMOD_RELEASES_I6.0+")

Overview

Attributes

countries

A Container with Country objects.

extensions

A Container with Model extensions.

model_path

Path to the EUROMOD project.

Attributes

countries: container.Container[Country]

A Container with Country objects.

extensions: container.Container[Extension]

A Container with Model extensions.

model_path: str

Path to the EUROMOD project.

class euromod.core.Parameter(*arg)

Parameters set up in a function.

Returns:

A class with country-specific parameter.

Return type:

Parameter

Overview

Attributes

ID

Identifier number of the parameter.

comment

Comment specific to the parameter.

extensions

A Container with Extension objects.

funID

Identifier number of the reference function at country level.

group

Parameter group value.

name

Name of the parameter.

order

Order of the parameter in the specific spine.

parent

The class of the country-specific function.

spineOrder

Order of the parameter in the spine.

Attributes

ID: str

Identifier number of the parameter.

comment: str

Comment specific to the parameter.

extensions: container.Container[Extension] | None = None

A Container with Extension objects.

funID: str

Identifier number of the reference function at country level.

group: str = ''

Parameter group value.

Type:

str

name: str

Name of the parameter.

order: str

Order of the parameter in the specific spine.

parent: Function

The class of the country-specific function.

spineOrder: str

Order of the parameter in the spine.

class euromod.core.ParameterInSystem

Parameters set up in a function for a specific system.

Returns:

A class with the system-specific function parameter.

Return type:

ParameterInSystem

Overview

Attributes

ID

Identifier number of the parameter.

comment

Comment specific to the parameter.

extensions

A Container with Extension objects.

funID

Identifier number of the reference function at country level.

group

Parameter group number.

name

Name of the parameter.

order

Order of the parameter in the specific spine.

parID

Identifier number of the reference parameter at country level.

parent

The class of the country-specific function.

spineOrder

Order of the parameter in the spine.

sysID

Identifier number of the reference system.

value

Value of the parameter.

Methods

evaluate(var_dict)

-

Attributes

ID: str

Identifier number of the parameter.

comment: str

Comment specific to the parameter.

extensions: container.Container

A Container with Extension objects.

funID: str

Identifier number of the reference function at country level.

group: str

Parameter group number.

name: str

Name of the parameter.

order: str

Order of the parameter in the specific spine.

parID: str

Identifier number of the reference parameter at country level.

parent: Function

The class of the country-specific function.

spineOrder: str

Order of the parameter in the spine.

sysID: str

Identifier number of the reference system.

value: str

Value of the parameter.

Methods

evaluate(var_dict=dict())
class euromod.core.Policy(*arg)

Policy rules modeled in a country.

Returns:

A class with the country-specific policies.

Return type:

Policy

Overview

Attributes

ID

Identifier number of the policy.

comment

Comment specific to the policy.

extensions

A Container of policy-specific Extension objects.

functions

A Container of policy-specific Function objects.

name

Name of the policy.

order

Order of the policy in the specific spine.

parent

The country-specific class.

private

Access type. Default is ‘no’.

spineOrder

Order of the policy in the spine.

Attributes

ID: str

Identifier number of the policy.

comment: str

Comment specific to the policy.

extensions: container.Container[Extension] | None = None

A Container of policy-specific Extension objects.

functions: container.Container[Function] | None = None

A Container of policy-specific Function objects.

name: str

Name of the policy.

order: str

Order of the policy in the specific spine.

parent: Country

The country-specific class.

private: str = 'no'

Access type. Default is ‘no’.

spineOrder: str

Order of the policy in the spine.

class euromod.core.PolicyInSystem(*arg)

Policy rules modeled in a system.

Returns:

A class with system-specific policies.

Return type:

PolicyInSystem

Overview

Attributes

ID

Identifier number of the policy.

comment

Comment specific to the policy.

extensions

A Container of policy-specific Extension objects.

functions

A Container with FunctionInSystem objects specific to the system

name

Name of the policy.

order

Order of the policy in the specific spine.

parent

The country-specific class.

polID

Identifier number of the reference policy at country level.

private

Access type. Default is ‘no’.

spineOrder

Order of the policy in the spine.

switch

Policy switch action.

sysID

Identifier number of the reference system.

Attributes

ID: str

Identifier number of the policy.

comment: str

Comment specific to the policy.

extensions: container.Container[Extension]

A Container of policy-specific Extension objects.

functions: container.Container[FunctionInSystem] | None = None

A Container with FunctionInSystem objects specific to the system

name: str

Name of the policy.

order: str

Order of the policy in the specific spine.

parent: Country

The country-specific class.

polID: str

Identifier number of the reference policy at country level.

private: str

Access type. Default is ‘no’.

spineOrder: str

Order of the policy in the spine.

switch: str

Policy switch action.

sysID: str

Identifier number of the reference system.

class euromod.core.ReferencePolicy(info, parent)

Object storing the reference policies.

Returns:

A class with the country-specific reference policies.

Return type:

ReferencePolicy

Overview

Attributes

extensions

A Container of reference policy-specific Extension objects.

name

Name of the reference policy.

parent

The country-specific class.

Attributes

extensions: container.Container[Extension] | None = None

A Container of reference policy-specific Extension objects.

name: str

Name of the reference policy.

parent: Country

The country-specific class.

class euromod.core.Simulation(out, constantsToOverwrite, polars)

Object storing the simulation results.

This is a class containing results from the simulation run() and other related configuration information.

Returns:

A class with simulation output.

Return type:

Simulation

Overview

Attributes

constantsToOverwrite

A dict-type object with user-defined constants.

errors

A list with errors and warnings from the simulation run.

output_filenames

A list of file-names of simulation output.

outputs

A Container with pandas.DataFrame-type simulation results.

Attributes

constantsToOverwrite: dict[tuple(str, str), str]

A dict-type object with user-defined constants.

errors: list[str]

A list with errors and warnings from the simulation run.

output_filenames: list[str] | [] = []

A list of file-names of simulation output.

outputs: container.Container[pandas.DataFrame]

A Container with pandas.DataFrame-type simulation results. For indexing use an integer or a label from output_filenames.

class euromod.core.System(*arg)

A EUROMOD tax-benefit system.

This class represents a EUROMOD tax system. Instances of this class are generated when loading the EUROMOD base model. These are collected in a Container as attribute systems of the Country.

Returns:

A class with country systems.

Return type:

System

Example

>>> from euromod import Model
>>> mod=Model("C:\EUROMOD_RELEASES_I6.0+")
>>> mod.countries[0].systems[-1]

Overview

Attributes

ID

Identifier number of the system.

bestmatch_datasets

A Container with best-match Dataset objects in the system.

comment

Comment specific to the system.

currencyOutput

Currency of the simulation results.

currencyParam

Currency of the monetary parameters in the system.

datasets

A Container of DatasetInSystem objects in the system.

headDefInc

Main income definition.

name

Name of the system.

order

System order in the spine.

parent

The country-specific class.

policies

A Container of PolicyInSystem objects in the system.

private

Access type.

year

System year.

Methods

get_default_extensions(dataset)

param dataset:

Name of Dataset.

run(data, dataset_id, constantsToOverwrite, verbose, outputpath, addons, switches, nowarnings, euro, public_components_only, requested_vars, requested_incomelists, requested_vargroups, requested_ilgroups, suppress_other_output, breakfun_id)

Run the simulation of a EUROMOD tax-benefit system by passing the pandas or polars dataframe in memory to EUROMOD. Note that string variables will not be passed.

Attributes

ID: str

Identifier number of the system.

bestmatch_datasets: container.Container[Dataset] | None = None

A Container with best-match Dataset objects in the system.

comment: str

Comment specific to the system.

currencyOutput: str

Currency of the simulation results.

currencyParam: str

Currency of the monetary parameters in the system.

datasets: container.Container[DatasetInSystem] | None = None

A Container of DatasetInSystem objects in the system.

headDefInc: str

Main income definition.

name: str

Name of the system.

order: str

System order in the spine.

parent: Country

The country-specific class.

policies: container.Container[PolicyInSystem] | None = None

A Container of PolicyInSystem objects in the system.

private: str

Access type.

year: str

System year.

Methods

get_default_extensions(dataset)
Parameters:

dataset (str) – Name of Dataset.

Returns:

extensions – key is name of the extension, value, is boolean indicating true for on, false for off

Return type:

dict[bool,str]

run(data: pandas.DataFrame, dataset_id: str, constantsToOverwrite: Dict[Tuple[str, str], str] | None = None, verbose: bool = True, outputpath: str = '', addons: List[Tuple[str, str]] = [], switches: List[Tuple[str, bool]] = [], nowarnings=False, euro=False, public_components_only=False, requested_vars: List[str] = [], requested_incomelists: List[str] = [], requested_vargroups: List[str] = [], requested_ilgroups: List[str] = [], suppress_other_output: bool = False, breakfun_id: str = None) Simulation

Run the simulation of a EUROMOD tax-benefit system by passing the pandas or polars dataframe in memory to EUROMOD. Note that string variables will not be passed.

Parameters:
  • data (pandas.DataFrame) – input dataframe passed to the EUROMOD model.

  • dataset_id (str) – ID of the dataset.

  • constantsToOverwrite (dict [ tuple [ str, str ], str ], optional) – A dict with constants to overwrite. Note that the key is a tuple of two strings, for which the first element is the name of the constant and the second is the groupnumber. Note that the values must be defined as strings. Default is None.

  • verbose (bool, optional) – If True then information on the output will be printed. Default is True.

  • outputpath (str, optional) – When the output path is provided, there will be anoutput file generated. Default is “”.

  • addons (list [ tuple [ str, str ]], optional) – List of tuples with addons to be integrated in the spine. The first element of the tuple is the name of the addon and the second element is the name of the system in the Addon to be integrated. Default is [].

  • switches (list [ tuple [ str, bool ]], optional) – List of tuples with extensions to be switched on or of. The first element of the tuple is the short name of the extension. The second element is a boolean Default is [].

  • nowarnings (bool, optional) – If True, the warning messages resulting from the simulations will be suppressed. Default is False.

  • euro (bool, optional) – If True, the monetary variables will be converted to euro for the simulation. Default value is False.

  • public_compoments_only (bool, optional) – If True, the the model will be on with only the public compoments. Default value is False.

  • nowarnings – If True then warnings returned by the model do not get printed. The default is False.

  • requested_vars (List[str], optional) – Variables requested in a new separate output. The default is [].

  • requested_incomelists (List[str], optional) – Income lists requested in a new separate output. The default is [].

  • requested_vargroups (List[str], optional) – Vargroups requested in a new separate output. The default is [].

  • requested_ilgroups (List[str], optional) – ilgroups requested in a new separate output. The default is [].

  • suppress_other_output (bool, optional) – If True and custom output is specified then DefOutput from the model get suppressed. The default is False.

Raises:

Exception – Exception when simulation does not finish succesfully, i.e. without errors.

Returns:

A class containing simulation output and error messages.

Return type:

Simulation

Example

>>> # Load the dataset
>>> import pandas as pd
>>> data = pd.read_csv("C:\EUROMOD_RELEASES_I6.0+\Input\sl_demo_v4.txt",sep="   ")
>>> # Load EUROMOD
>>> from euromod import Model
>>> mod=Model("C:\EUROMOD_RELEASES_I6.0+")
>>> # Run simulation
>>> out=mod.countries['SL'].systems['SL_1996'].run(data,'sl_demo_v4')
class euromod.core.UprateFactor(*args)

Overview

Attributes

ID

Identifier UprateFactor

comment

Comment of uprating factor

description

Description of uprating factor

name

Name of uprating factor

parent

-

values

Container of the uprating values for the respective years

Attributes

ID: str

Identifier UprateFactor

comment: str

Comment of uprating factor

description: str

Description of uprating factor

name: str

Name of uprating factor

parent: Country
values: UprateFactorYearsContainer

Container of the uprating values for the respective years

class euromod.core.UprateFactorYear(*args)

Overview

Attributes

ID

Identifier UprateFactor

parent

-

value

Value of uprating factor

year

Year of uprating factor

Attributes

ID: str

Identifier UprateFactor

parent: UprateFactor
value: str

Value of uprating factor

year: str

Year of uprating factor

class euromod.core.UprateFactorYearsContainer

Container class storing Country objects.