The policyengine_core.reforms module contains the definition for Reform, a class which can be used to edit a TaxBenefitSystem instance.


class policyengine_core.reforms.Reform(baseline: policyengine_core.taxbenefitsystems.tax_benefit_system.TaxBenefitSystem)[source]#

A modified TaxBenefitSystem

All reforms must subclass Reform and implement a method apply().

In this method, the reform can add or replace variables and call modify_parameters to modify the parameters of the legislation.


>>> from policyengine_core import reforms
>>> from policyengine_core.parameters import load_parameter_file
>>> def modify_my_parameters(parameters):
>>>     # Add new parameters
>>>     new_parameters = load_parameter_file(name='reform_name', file_path='path_to_yaml_file.yaml')
>>>     parameters.add_child('reform_name', new_parameters)
>>>     # Update a value
>>>     parameters.taxes.some_tax.some_param.update(period=some_period, value=1000.0)
>>>    return parameters
>>> class MyReform(reforms.Reform):
>>>    def apply(self):
>>>        self.add_variable(some_variable)
>>>        self.update_variable(some_other_variable)
>>>        self.modify_parameters(modifier_function = modify_my_parameters)
country_id: str = None#

The country id of the reform. This is used to inform any calls to the PolicyEngine API.

static from_dict(parameter_values: dict, country_id: Optional[str] = None, name: Optional[str] = None) policyengine_core.reforms.reform.Reform[source]#

Create a reform from a dictionary of parameters.


parameters – A dictionary of parameter -> { period -> value } pairs.


A reform.

modify_parameters(modifier_function: Callable[[policyengine_core.parameters.parameter_node.ParameterNode], policyengine_core.parameters.parameter_node.ParameterNode]) None[source]#

Make modifications on the parameters of the legislation.

Call this function in apply() if the reform asks for legislation parameter modifications.


modifier_function – A function that takes a ParameterNode and should return an object of the same type.

name: str = None#

The name of the reform. This is used to identify the reform in the UI.

parameter_values: dict = None#

The parameter values of the reform. This is used to inform any calls to the PolicyEngine API.