Parameters

Handle legislative parameters.

class openfisca_core.parameters.Bracket(name='', directory_path=None, data=None, file_path=None)[source]

A scale bracket.

class openfisca_core.parameters.Parameter(name, data, file_path=None)[source]

A parameter of the legislation. Parameters can change over time.

Parameters:
  • name (string) – Name of the parameter, e.g. “taxes.some_tax.some_param”
  • data (dict) – Data loaded from a YAML file.
  • file_path (string) – File the parameter was loaded from.
  • documentation (string) – Documentation describing parameter usage and context.

Instantiate a parameter without metadata:

>>>  Parameter('rate', data = {
        "2015-01-01": 550,
        "2016-01-01": 600
        })

Instantiate a parameter with metadata:

>>>  Parameter('rate', data = {
        'description': 'Income tax rate applied on salaries',
        'values': {
            "2015-01-01": {'value': 550, 'metadata': {'reference': 'http://taxes.gov/income_tax/2015'}},
            "2016-01-01": {'value': 600, 'metadata': {'reference': 'http://taxes.gov/income_tax/2016'}}
            }
        })
values_list

List of the values, in reverse chronological order

update(period=None, start=None, stop=None, value=None)[source]

Change the value for a given period.

Parameters:
  • period – Period where the value is modified. If set, start and stop should be None.
  • start – Start of the period. Instance of openfisca_core.periods.Instant. If set, period should be None.
  • stop – Stop of the period. Instance of openfisca_core.periods.Instant. If set, period should be None.
  • value – New value. If None, the parameter is removed from the legislation parameters for the given period.
class openfisca_core.parameters.ParameterAtInstant(name, instant_str, data=None, file_path=None, metadata=None)[source]

A value of a parameter at a given instant.

class openfisca_core.parameters.ParameterNode(name='', directory_path=None, data=None, file_path=None)[source]

A node in the legislation parameter tree.

add_child(name, child)[source]

Add a new child to the node.

Parameters:
  • name – Name of the child that must be used to access that child. Should not contain anything that could interfere with the operator . (dot).
  • child – The new child, an instance of Scale or Parameter or ParameterNode.
get_descendants()[source]

Return a generator containing all the parameters and nodes recursively contained in this ParameterNode

merge(other)[source]

Merges another ParameterNode into the current node.

In case of child name conflict, the other node child will replace the current node child.

class openfisca_core.parameters.ParameterNodeAtInstant(name, node, instant_str)[source]

Parameter node of the legislation, at a given instant.

exception openfisca_core.parameters.ParameterNotFound(name, instant_str, variable_name=None)[source]

Exception raised when a parameter is not found in the parameters.

exception openfisca_core.parameters.ParameterParsingError(message, file=None, traceback=None)[source]

Exception raised when a parameter cannot be parsed.

class openfisca_core.parameters.Scale(name, data, file_path)[source]

A parameter scale (for instance a marginal scale).

class openfisca_core.parameters.VectorialParameterNodeAtInstant(name, vector, instant_str)[source]

Parameter node of the legislation at a given instant which has been vectorized. Vectorized parameters allow requests such as parameters.housing_benefit[zipcode], where zipcode is a vector

static check_node_vectorisable(node)[source]

Check that a node can be casted to a vectorial node, in order to be able to use fancy indexing.

openfisca_core.parameters.load_parameter_file(file_path, name='')[source]

Load parameters from a YAML file (or a directory containing YAML files).

Returns:An instance of ParameterNode or Scale or Parameter.