openfisca_core.variables.
Variable
(baseline_variable=None)[source]¶A variable of the legislation.
Main attributes:
name
¶Name of the variable
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: | Formula |
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.
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.
openfisca_core.variables.helpers.
get_neutralized_variable
(variable)[source]¶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
.