openfisca_core.taxbenefitsystems.
TaxBenefitSystem
(entities)[source]¶Represents the legislation.
It stores parameters (values defined for everyone) and variables (values defined for some given entity e.g. a person).
Parameters: |
|
---|
parameters
¶ParameterNode
containing the legislation parameters
add_variable
(variable)[source]¶Adds an OpenFisca variable to the tax and benefit system.
Parameters: | variable (Variable) – The variable to add. Must be a subclass of Variable. |
---|---|
Raises: | VariableNameConflict if a variable with the same name have previously been added to the tax and benefit system. |
add_variables
(*variables)[source]¶Adds a list of OpenFisca Variables to the TaxBenefitSystem.
See also add_variable
add_variables_from_directory
(directory)[source]¶Recursively explores a directory, and adds all OpenFisca variables found there to the tax and benefit system.
add_variables_from_file
(file_path)[source]¶Adds all OpenFisca variables contained in a given file to the tax and benefit system.
apply_reform
(reform_path)[source]¶Generates a new tax and benefit system applying a reform to the tax and benefit system.
The current tax and benefit system is not mutated.
Parameters: | reform_path (string) – The reform to apply. Must respect the format installed_package.sub_module.reform |
---|---|
Returns: | A reformed tax and benefit system. |
Exemple:
>>> self.apply_reform('openfisca_france.reforms.inversion_revenus')
get_package_metadata
()[source]¶Gets metatada relative to the country package the tax and benefit system is built from.
Returns: | Country package metadata |
---|---|
Return type: | dict |
Exemple:
>>> tax_benefit_system.get_package_metadata()
>>> {
>>> 'location': '/path/to/dir/containing/package',
>>> 'name': 'openfisca-france',
>>> 'repository_url': 'https://github.com/openfisca/openfisca-france',
>>> 'version': '17.2.0'
>>> }
get_parameters_at_instant
(instant)[source]¶Get the parameters of the legislation at a given instant
Parameters: | instant – string of the format ‘YYYY-MM-DD’ or openfisca_core.periods.Instant instance. |
---|---|
Returns: | The parameters of the legislation at a given instant. |
Return type: | ParameterNodeAtInstant |
get_variable
(variable_name, check_existence=False)[source]¶Get a variable from the tax and benefit system.
Parameters: |
|
---|
get_variables
(entity=None)[source]¶Gets all variables contained in a tax and benefit system.
Parameters: | subclass> entity (<Entity) – If set, returns only the variable defined for the given entity. |
---|---|
Returns: | A dictionnary, indexed by variable names. |
Return type: | dict |
load_extension
(extension)[source]¶Loads an extension to the tax and benefit system.
Parameters: | extension (string) – The extension to load. Can be an absolute path pointing to an extension directory, or the name of an OpenFisca extension installed as a pip package. |
---|
load_parameters
(path_to_yaml_dir)[source]¶Loads the legislation parameter for a directory containing YAML parameters files.
Parameters: | path_to_yaml_dir – Absolute path towards the YAML parameter directory. |
---|
Exemples:
>>> self.load_parameters('/path/to/yaml/parameters/dir')
neutralize_variable
(variable_name)[source]¶Neutralizes an OpenFisca variable existing in the tax and benefit system.
A neutralized variable always returns its default value when computed.
Trying to set inputs for a neutralized variable has no effect except raising a warning.
replace_variable
(variable)[source]¶Replaces an existing OpenFisca variable in the tax and benefit system by a new one.
The new variable must have the same name than the replaced one.
If no variable with the given name exists in the tax and benefit system, no error will be raised and the new variable will be simply added.
Parameters: | variable (Variable) – New variable to add. Must be a subclass of Variable. |
---|
update_variable
(variable)[source]¶Updates an existing OpenFisca variable in the tax and benefit system.
All attributes of the updated variable that are not explicitely overridden by the new variable
will stay unchanged.
The new variable must have the same name than the updated one.
If no variable with the given name exists in the tax and benefit system, no error will be raised and the new variable will be simply added.
Parameters: | variable (Variable) – Variable to add. Must be a subclass of Variable. |
---|