class openfisca_core.variables.Variable(baseline_variable=None)[source]

A variable of the legislation.

Main attributes:


Name of the variable


The value type of the variable. Possible value types in OpenFisca are int float bool str date and Enum.


Entity the variable is defined for. For instance : Person, Household.


Period the variable is defined for. Possible value: MONTH, YEAR, ETERNITY.


Formulas used to calculate the variable


Description of the variable


Legislative reference describing the variable.


Default value of the variable.

Secondary attributes:


If the variable has been introduced in a reform to replace another variable, baseline_variable is the replaced variable.


Numpy dtype used under the hood for the variable.


Date when the variable disappears from the legislation.


True if the variable is neutralized. Neutralized variables never use their formula, and only return their default values when calculated.


JSON type corresponding to the variable.


If the value type of the variable is str, max length of the string allowed. None if there is no limit.


If the value type of the variable is Enum, contains the values the variable can take.


Function used to automatically process variable inputs defined for periods not matching the definition_period of the variable. See more on the documentation. Possible values are set_input_dispatch_by_period, set_input_divide_by_period, or nothing.


Free text field describing the unit of the variable. Only used as metadata.


Free multilines text field describing the variable context and usage.


Returns the formula used to compute the variable at the given period.

If no period is given and the variable has several formula, return the oldest formula.

Returns:Formula used to compute the variable
Return type:Formula
classmethod get_introspection_data(tax_benefit_system)[source]

Get instrospection data about the code of the variable.

Returns:(comments, source file path, source code, start line number)
Return type:tuple

Returns True if the variable is an input variable.


Returns the starting date of a formula based on its name.

Valid dated name formats are : ‘formula’, ‘formula_YYYY’, ‘formula_YYYY_MM’ and ‘formula_YYYY_MM_DD’ where YYYY, MM and DD are a year, month and day.

By convention, the starting date of:
  • formula is 0001-01-01 (minimal date in Python)
  • formula_YYYY is YYYY-01-01
  • formula_YYYY_MM is YYYY-MM-01
openfisca_core.variables.helpers.get_annualized_variable(variable: openfisca_core.variables.variable.Variable, annualization_period: typing.Union[openfisca_core.periods.period_.Period, NoneType] = None) → openfisca_core.variables.variable.Variable[source]

Returns a clone of variable that is annualized for the period annualization_period. When annualized, a variable’s formula is only called for a January calculation, and the results for other months are assumed to be identical.


Return a new neutralized variable (to be used by reforms). A neutralized variable always returns its default value, and does not cache anything.

openfisca_core.variables.typing.Formula = typing.Callable[[typing.Union[openfisca_core.populations.population.Population, openfisca_core.populations.group_population.GroupPopulation], openfisca_core.periods.period_.Period, typing.Callable[[openfisca_core.periods.instant_.Instant], openfisca_core.parameters.parameter_node_at_instant.ParameterNodeAtInstant]], numpy.ndarray]

A callable defining a calculation, or a rule, on a system.

openfisca_core.variables.typing.Params = typing.Callable[[openfisca_core.periods.instant_.Instant], openfisca_core.parameters.parameter_node_at_instant.ParameterNodeAtInstant]

A callable to get the parameters for the given instant.

openfisca_core.variables.typing.People = typing.Union[openfisca_core.populations.population.Population, openfisca_core.populations.group_population.GroupPopulation]

A collection of Entity or GroupEntity.