openfisca_core.variables.
Variable
(baseline_variable=None)[source]¶A variable of the legislation.
Main attributes:
value_type
¶The value type of the variable. Possible value types in OpenFisca are
int
float
bool
str
date
andEnum
.
formulas
¶Formulas used to calculate the variable
label
¶Description of the variable
reference
¶Legislative reference describing the variable.
default_value
¶Default value of the variable.
Secondary attributes:
baseline_variable
¶If the variable has been introduced in a reform to replace another variable, baseline_variable is the replaced variable.
is_neutralized
¶True if the variable is neutralized. Neutralized variables never use their formula, and only return their default values when calculated.
json_type
¶JSON type corresponding to the variable.
max_length
¶If the value type of the variable is
str
, max length of the string allowed.None
if there is no limit.
possible_values
¶If the value type of the variable is
Enum
, contains the values the variable can take.
set_input
¶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.
unit
¶Free text field describing the unit of the variable. Only used as metadata.
documentation
¶Free multilines text field describing the variable context and usage.
get_formula
(period=None)[source]¶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: | function |
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 |
parse_formula_name
(attribute_name)[source]¶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.