OpenFisca-Core-test 46.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openfisca_core/__init__.py +0 -0
- openfisca_core/commons/__init__.py +18 -0
- openfisca_core/commons/dummy.py +25 -0
- openfisca_core/commons/formulas.py +121 -0
- openfisca_core/commons/misc.py +109 -0
- openfisca_core/commons/py.typed +0 -0
- openfisca_core/commons/rates.py +114 -0
- openfisca_core/commons/tests/__init__.py +0 -0
- openfisca_core/commons/tests/test_dummy.py +9 -0
- openfisca_core/commons/tests/test_formulas.py +75 -0
- openfisca_core/commons/tests/test_rates.py +26 -0
- openfisca_core/data_storage/__init__.py +7 -0
- openfisca_core/data_storage/in_memory_storage.py +198 -0
- openfisca_core/data_storage/on_disk_storage.py +307 -0
- openfisca_core/data_storage/types.py +14 -0
- openfisca_core/entities/__init__.py +23 -0
- openfisca_core/entities/_core_entity.py +217 -0
- openfisca_core/entities/_description.py +55 -0
- openfisca_core/entities/entity.py +60 -0
- openfisca_core/entities/group_entity.py +123 -0
- openfisca_core/entities/helpers.py +165 -0
- openfisca_core/entities/py.typed +0 -0
- openfisca_core/entities/role.py +92 -0
- openfisca_core/entities/tests/__init__.py +0 -0
- openfisca_core/entities/tests/test_entity.py +10 -0
- openfisca_core/entities/tests/test_group_entity.py +70 -0
- openfisca_core/entities/tests/test_role.py +11 -0
- openfisca_core/entities/types.py +44 -0
- openfisca_core/errors/__init__.py +64 -0
- openfisca_core/errors/cycle_error.py +2 -0
- openfisca_core/errors/empty_argument_error.py +39 -0
- openfisca_core/errors/nan_creation_error.py +2 -0
- openfisca_core/errors/parameter_not_found_error.py +16 -0
- openfisca_core/errors/parameter_parsing_error.py +18 -0
- openfisca_core/errors/period_mismatch_error.py +9 -0
- openfisca_core/errors/situation_parsing_error.py +26 -0
- openfisca_core/errors/spiral_error.py +2 -0
- openfisca_core/errors/variable_name_config_error.py +2 -0
- openfisca_core/errors/variable_not_found_error.py +29 -0
- openfisca_core/experimental/__init__.py +9 -0
- openfisca_core/experimental/_errors.py +5 -0
- openfisca_core/experimental/_memory_config.py +41 -0
- openfisca_core/formula_helpers.py +9 -0
- openfisca_core/holders/__init__.py +33 -0
- openfisca_core/holders/helpers.py +93 -0
- openfisca_core/holders/holder.py +328 -0
- openfisca_core/holders/tests/__init__.py +0 -0
- openfisca_core/holders/tests/test_helpers.py +134 -0
- openfisca_core/holders/types.py +3 -0
- openfisca_core/indexed_enums/__init__.py +18 -0
- openfisca_core/indexed_enums/_enum_type.py +79 -0
- openfisca_core/indexed_enums/_errors.py +35 -0
- openfisca_core/indexed_enums/_guards.py +209 -0
- openfisca_core/indexed_enums/_utils.py +180 -0
- openfisca_core/indexed_enums/config.py +6 -0
- openfisca_core/indexed_enums/enum.py +218 -0
- openfisca_core/indexed_enums/enum_array.py +316 -0
- openfisca_core/indexed_enums/py.typed +0 -0
- openfisca_core/indexed_enums/tests/__init__.py +0 -0
- openfisca_core/indexed_enums/tests/test_enum.py +135 -0
- openfisca_core/indexed_enums/tests/test_enum_array.py +30 -0
- openfisca_core/indexed_enums/types.py +49 -0
- openfisca_core/memory_config.py +9 -0
- openfisca_core/model_api.py +71 -0
- openfisca_core/parameters/__init__.py +71 -0
- openfisca_core/parameters/at_instant_like.py +17 -0
- openfisca_core/parameters/config.py +55 -0
- openfisca_core/parameters/helpers.py +106 -0
- openfisca_core/parameters/parameter.py +217 -0
- openfisca_core/parameters/parameter_at_instant.py +75 -0
- openfisca_core/parameters/parameter_node.py +176 -0
- openfisca_core/parameters/parameter_node_at_instant.py +57 -0
- openfisca_core/parameters/parameter_scale.py +121 -0
- openfisca_core/parameters/parameter_scale_bracket.py +7 -0
- openfisca_core/parameters/values_history.py +5 -0
- openfisca_core/parameters/vectorial_parameter_node_at_instant.py +179 -0
- openfisca_core/periods/__init__.py +77 -0
- openfisca_core/periods/_errors.py +28 -0
- openfisca_core/periods/_parsers.py +122 -0
- openfisca_core/periods/config.py +20 -0
- openfisca_core/periods/date_unit.py +110 -0
- openfisca_core/periods/helpers.py +314 -0
- openfisca_core/periods/instant_.py +226 -0
- openfisca_core/periods/period_.py +919 -0
- openfisca_core/periods/py.typed +0 -0
- openfisca_core/periods/tests/__init__.py +0 -0
- openfisca_core/periods/tests/helpers/__init__.py +0 -0
- openfisca_core/periods/tests/helpers/test_helpers.py +65 -0
- openfisca_core/periods/tests/helpers/test_instant.py +73 -0
- openfisca_core/periods/tests/helpers/test_period.py +134 -0
- openfisca_core/periods/tests/test_instant.py +32 -0
- openfisca_core/periods/tests/test_parsers.py +129 -0
- openfisca_core/periods/tests/test_period.py +283 -0
- openfisca_core/populations/__init__.py +64 -0
- openfisca_core/populations/_core_population.py +454 -0
- openfisca_core/populations/_errors.py +65 -0
- openfisca_core/populations/group_population.py +326 -0
- openfisca_core/populations/population.py +142 -0
- openfisca_core/populations/tests/__init__.py +0 -0
- openfisca_core/populations/tests/test_members_position.py +116 -0
- openfisca_core/populations/types.py +110 -0
- openfisca_core/projectors/__init__.py +39 -0
- openfisca_core/projectors/entity_to_person_projector.py +12 -0
- openfisca_core/projectors/first_person_to_entity_projector.py +13 -0
- openfisca_core/projectors/helpers.py +139 -0
- openfisca_core/projectors/projector.py +38 -0
- openfisca_core/projectors/typing.py +27 -0
- openfisca_core/projectors/unique_role_to_entity_projector.py +14 -0
- openfisca_core/rates.py +9 -0
- openfisca_core/reforms/__init__.py +24 -0
- openfisca_core/reforms/in_yaml_test_reform.py +28 -0
- openfisca_core/reforms/reform.py +86 -0
- openfisca_core/scripts/__init__.py +106 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-310-pytest-8.3.3.pyc +0 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-310-pytest-8.4.2.pyc +0 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-310.pyc +0 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-311-pytest-8.3.3.pyc +0 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-311-pytest-8.4.2.pyc +0 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-311.pyc +0 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-312-pytest-8.4.2.pyc +0 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-312.pyc +0 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-313-pytest-8.3.3.pyc +0 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-313-pytest-8.4.2.pyc +0 -0
- openfisca_core/scripts/__pycache__/__init__.cpython-313.pyc +0 -0
- openfisca_core/scripts/__pycache__/find_placeholders.cpython-311.pyc +0 -0
- openfisca_core/scripts/__pycache__/find_placeholders.cpython-313.pyc +0 -0
- openfisca_core/scripts/__pycache__/measure_numpy_condition_notations.cpython-311.pyc +0 -0
- openfisca_core/scripts/__pycache__/measure_numpy_condition_notations.cpython-313.pyc +0 -0
- openfisca_core/scripts/__pycache__/measure_performances.cpython-311.pyc +0 -0
- openfisca_core/scripts/__pycache__/measure_performances.cpython-313.pyc +0 -0
- openfisca_core/scripts/__pycache__/measure_performances_fancy_indexing.cpython-311.pyc +0 -0
- openfisca_core/scripts/__pycache__/measure_performances_fancy_indexing.cpython-313.pyc +0 -0
- openfisca_core/scripts/__pycache__/openfisca_command.cpython-310.pyc +0 -0
- openfisca_core/scripts/__pycache__/openfisca_command.cpython-311.pyc +0 -0
- openfisca_core/scripts/__pycache__/openfisca_command.cpython-312.pyc +0 -0
- openfisca_core/scripts/__pycache__/openfisca_command.cpython-313.pyc +0 -0
- openfisca_core/scripts/__pycache__/remove_fuzzy.cpython-311.pyc +0 -0
- openfisca_core/scripts/__pycache__/remove_fuzzy.cpython-313.pyc +0 -0
- openfisca_core/scripts/__pycache__/run_test.cpython-310.pyc +0 -0
- openfisca_core/scripts/__pycache__/run_test.cpython-311.pyc +0 -0
- openfisca_core/scripts/__pycache__/run_test.cpython-312.pyc +0 -0
- openfisca_core/scripts/__pycache__/run_test.cpython-313.pyc +0 -0
- openfisca_core/scripts/__pycache__/simulation_generator.cpython-311.pyc +0 -0
- openfisca_core/scripts/__pycache__/simulation_generator.cpython-313.pyc +0 -0
- openfisca_core/scripts/assets/__init__.py +0 -0
- openfisca_core/scripts/assets/__pycache__/__init__.cpython-311.pyc +0 -0
- openfisca_core/scripts/assets/__pycache__/__init__.cpython-313.pyc +0 -0
- openfisca_core/scripts/assets/index.html +140 -0
- openfisca_core/scripts/find_placeholders.py +51 -0
- openfisca_core/scripts/measure_numpy_condition_notations.py +137 -0
- openfisca_core/scripts/measure_performances.py +291 -0
- openfisca_core/scripts/measure_performances_fancy_indexing.py +89 -0
- openfisca_core/scripts/migrations/__init__.py +0 -0
- openfisca_core/scripts/migrations/__pycache__/__init__.cpython-311.pyc +0 -0
- openfisca_core/scripts/migrations/__pycache__/__init__.cpython-313.pyc +0 -0
- openfisca_core/scripts/migrations/__pycache__/v24_to_25.cpython-311.pyc +0 -0
- openfisca_core/scripts/migrations/__pycache__/v24_to_25.cpython-313.pyc +0 -0
- openfisca_core/scripts/migrations/v16_2_to_v17/__init__.py +0 -0
- openfisca_core/scripts/migrations/v16_2_to_v17/__pycache__/__init__.cpython-311.pyc +0 -0
- openfisca_core/scripts/migrations/v16_2_to_v17/__pycache__/__init__.cpython-313.pyc +0 -0
- openfisca_core/scripts/migrations/v16_2_to_v17/__pycache__/xml_to_yaml_country_template.cpython-311.pyc +0 -0
- openfisca_core/scripts/migrations/v16_2_to_v17/__pycache__/xml_to_yaml_country_template.cpython-313.pyc +0 -0
- openfisca_core/scripts/migrations/v16_2_to_v17/__pycache__/xml_to_yaml_extension_template.cpython-311.pyc +0 -0
- openfisca_core/scripts/migrations/v16_2_to_v17/__pycache__/xml_to_yaml_extension_template.cpython-313.pyc +0 -0
- openfisca_core/scripts/migrations/v16_2_to_v17/legislation.xsd +102 -0
- openfisca_core/scripts/migrations/v16_2_to_v17/xml_to_yaml_country_template.py +30 -0
- openfisca_core/scripts/migrations/v16_2_to_v17/xml_to_yaml_extension_template.py +26 -0
- openfisca_core/scripts/migrations/v24_to_25.py +156 -0
- openfisca_core/scripts/openfisca_command.py +192 -0
- openfisca_core/scripts/remove_fuzzy.py +213 -0
- openfisca_core/scripts/run_test.py +51 -0
- openfisca_core/scripts/simulation_generator.py +90 -0
- openfisca_core/simulation_builder.py +16 -0
- openfisca_core/simulations/__init__.py +45 -0
- openfisca_core/simulations/_build_default_simulation.py +158 -0
- openfisca_core/simulations/_build_from_variables.py +230 -0
- openfisca_core/simulations/_type_guards.py +298 -0
- openfisca_core/simulations/helpers.py +111 -0
- openfisca_core/simulations/simulation.py +618 -0
- openfisca_core/simulations/simulation_builder.py +855 -0
- openfisca_core/simulations/typing.py +203 -0
- openfisca_core/taxbenefitsystems/__init__.py +26 -0
- openfisca_core/taxbenefitsystems/tax_benefit_system.py +584 -0
- openfisca_core/taxscales/__init__.py +35 -0
- openfisca_core/taxscales/abstract_rate_tax_scale.py +41 -0
- openfisca_core/taxscales/abstract_tax_scale.py +53 -0
- openfisca_core/taxscales/amount_tax_scale_like.py +55 -0
- openfisca_core/taxscales/helpers.py +44 -0
- openfisca_core/taxscales/linear_average_rate_tax_scale.py +76 -0
- openfisca_core/taxscales/marginal_amount_tax_scale.py +34 -0
- openfisca_core/taxscales/marginal_rate_tax_scale.py +286 -0
- openfisca_core/taxscales/rate_tax_scale_like.py +214 -0
- openfisca_core/taxscales/single_amount_tax_scale.py +32 -0
- openfisca_core/taxscales/tax_scale_like.py +65 -0
- openfisca_core/tools/__init__.py +94 -0
- openfisca_core/tools/parallel_plugin.py +55 -0
- openfisca_core/tools/simulation_dumper.py +137 -0
- openfisca_core/tools/test_runner.py +802 -0
- openfisca_core/tracers/__init__.py +40 -0
- openfisca_core/tracers/computation_log.py +196 -0
- openfisca_core/tracers/flat_trace.py +87 -0
- openfisca_core/tracers/full_tracer.py +172 -0
- openfisca_core/tracers/performance_log.py +133 -0
- openfisca_core/tracers/simple_tracer.py +64 -0
- openfisca_core/tracers/trace_node.py +121 -0
- openfisca_core/tracers/tracing_parameter_node_at_instant.py +81 -0
- openfisca_core/types.py +548 -0
- openfisca_core/variables/__init__.py +26 -0
- openfisca_core/variables/config.py +53 -0
- openfisca_core/variables/helpers.py +67 -0
- openfisca_core/variables/tests/__init__.py +0 -0
- openfisca_core/variables/tests/test_definition_period.py +43 -0
- openfisca_core/variables/variable.py +474 -0
- openfisca_core/warnings/__init__.py +25 -0
- openfisca_core/warnings/libyaml_warning.py +2 -0
- openfisca_core/warnings/tempfile_warning.py +2 -0
- openfisca_core_test-46.0.0.data/data/share/openfisca/openfisca-core/CHANGELOG.md +4209 -0
- openfisca_core_test-46.0.0.data/data/share/openfisca/openfisca-core/README.md +152 -0
- openfisca_core_test-46.0.0.dist-info/METADATA +194 -0
- openfisca_core_test-46.0.0.dist-info/RECORD +237 -0
- openfisca_core_test-46.0.0.dist-info/WHEEL +5 -0
- openfisca_core_test-46.0.0.dist-info/entry_points.txt +3 -0
- openfisca_core_test-46.0.0.dist-info/licenses/LICENSE +661 -0
- openfisca_core_test-46.0.0.dist-info/top_level.txt +2 -0
- openfisca_web_api/__init__.py +0 -0
- openfisca_web_api/app.py +226 -0
- openfisca_web_api/errors.py +11 -0
- openfisca_web_api/handlers.py +90 -0
- openfisca_web_api/loader/__init__.py +22 -0
- openfisca_web_api/loader/entities.py +28 -0
- openfisca_web_api/loader/parameters.py +122 -0
- openfisca_web_api/loader/spec.py +168 -0
- openfisca_web_api/loader/tax_benefit_system.py +27 -0
- openfisca_web_api/loader/variables.py +121 -0
- openfisca_web_api/openAPI.yml +434 -0
- openfisca_web_api/scripts/__init__.py +0 -0
- openfisca_web_api/scripts/serve.py +99 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
3
|
+
|
|
4
|
+
<xs:element name="NODE" type="nodeType"/>
|
|
5
|
+
|
|
6
|
+
<xs:group name="valuesHistory">
|
|
7
|
+
<xs:sequence>
|
|
8
|
+
<xs:choice maxOccurs="unbounded">
|
|
9
|
+
<xs:element name="VALUE" type="valueType"/>
|
|
10
|
+
<xs:element name="END" type="endType"/>
|
|
11
|
+
<xs:element name="PLACEHOLDER" type="placeholderType"/>
|
|
12
|
+
</xs:choice>
|
|
13
|
+
</xs:sequence>
|
|
14
|
+
</xs:group>
|
|
15
|
+
|
|
16
|
+
<xs:complexType name="nodeType">
|
|
17
|
+
<xs:sequence>
|
|
18
|
+
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
|
19
|
+
<xs:element name="NODE" type="nodeType"/>
|
|
20
|
+
<xs:element name="CODE" type="codeType"/>
|
|
21
|
+
<xs:element name="BAREME" type="baremeType"/>
|
|
22
|
+
</xs:choice>
|
|
23
|
+
</xs:sequence>
|
|
24
|
+
<xs:attribute name="code" type="xs:string" use="required"/>
|
|
25
|
+
<xs:attribute name="description" type="xs:string"/>
|
|
26
|
+
<xs:attribute name="origin" type="xs:string"/>
|
|
27
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
28
|
+
</xs:complexType>
|
|
29
|
+
|
|
30
|
+
<xs:complexType name="codeType">
|
|
31
|
+
<xs:group ref="valuesHistory"/>
|
|
32
|
+
<xs:attribute name="code" type="xs:string" use="required"/>
|
|
33
|
+
<xs:attribute name="description" type="xs:string"/>
|
|
34
|
+
<xs:attribute name="format" type="xs:string"/>
|
|
35
|
+
<xs:attribute name="origin" type="xs:string"/>
|
|
36
|
+
<xs:attribute name="type" type="xs:string"/>
|
|
37
|
+
<xs:attribute name="conflicts" type="xs:string"/>
|
|
38
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
39
|
+
</xs:complexType>
|
|
40
|
+
|
|
41
|
+
<xs:complexType name="endType">
|
|
42
|
+
<xs:attribute name="deb" type="xs:date" use="required"/>
|
|
43
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
44
|
+
</xs:complexType>
|
|
45
|
+
|
|
46
|
+
<xs:complexType name="valueType">
|
|
47
|
+
<xs:attribute name="deb" type="xs:date" use="required"/>
|
|
48
|
+
<xs:attribute name="valeur" type="xs:float" use="required"/>
|
|
49
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
50
|
+
</xs:complexType>
|
|
51
|
+
|
|
52
|
+
<xs:complexType name="baremeType">
|
|
53
|
+
<xs:sequence>
|
|
54
|
+
<xs:element name="TRANCHE" type="trancheType" minOccurs="0" maxOccurs="unbounded"/>
|
|
55
|
+
</xs:sequence>
|
|
56
|
+
<xs:attribute name="code" type="xs:string" use="required"/>
|
|
57
|
+
<xs:attribute name="description" type="xs:string"/>
|
|
58
|
+
<xs:attribute name="origin" type="xs:string"/>
|
|
59
|
+
<xs:attribute name="type" type="xs:string"/>
|
|
60
|
+
<xs:attribute name="conflicts" type="xs:string"/>
|
|
61
|
+
<xs:attribute name="option" type="xs:string"/>
|
|
62
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
63
|
+
</xs:complexType>
|
|
64
|
+
|
|
65
|
+
<xs:complexType name="trancheType">
|
|
66
|
+
<xs:all>
|
|
67
|
+
<xs:element name="ASSIETTE" type="assietteType" minOccurs="0"/>
|
|
68
|
+
<xs:element name="SEUIL" type="seuilType"/>
|
|
69
|
+
<xs:element name="TAUX" type="tauxType" minOccurs="0"/>
|
|
70
|
+
<xs:element name="MONTANT" type="montantType" minOccurs="0"/>
|
|
71
|
+
</xs:all>
|
|
72
|
+
<xs:attribute name="code" type="xs:string"/>
|
|
73
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
74
|
+
</xs:complexType>
|
|
75
|
+
|
|
76
|
+
<xs:complexType name="assietteType">
|
|
77
|
+
<xs:group ref="valuesHistory"/>
|
|
78
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
79
|
+
</xs:complexType>
|
|
80
|
+
|
|
81
|
+
<xs:complexType name="tauxType">
|
|
82
|
+
<xs:group ref="valuesHistory"/>
|
|
83
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
84
|
+
</xs:complexType>
|
|
85
|
+
|
|
86
|
+
<xs:complexType name="montantType">
|
|
87
|
+
<xs:group ref="valuesHistory"/>
|
|
88
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
89
|
+
</xs:complexType>
|
|
90
|
+
|
|
91
|
+
<xs:complexType name="seuilType">
|
|
92
|
+
<xs:group ref="valuesHistory"/>
|
|
93
|
+
<xs:attribute name="conflicts" type="xs:string"/>
|
|
94
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
95
|
+
</xs:complexType>
|
|
96
|
+
|
|
97
|
+
<xs:complexType name="placeholderType">
|
|
98
|
+
<xs:attribute name="deb" type="xs:date" use="required"/>
|
|
99
|
+
<xs:attribute name="reference" type="xs:string"/>
|
|
100
|
+
</xs:complexType>
|
|
101
|
+
|
|
102
|
+
</xs:schema>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""xml_to_yaml_country_template.py : Parse XML parameter files for Country-Template and convert them to YAML files. Comments are NOT transformed.
|
|
2
|
+
|
|
3
|
+
Usage :
|
|
4
|
+
`python xml_to_yaml_country_template.py output_dir`
|
|
5
|
+
or just (output is written in a directory called `yaml_parameters`):
|
|
6
|
+
`python xml_to_yaml_country_template.py`
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
from openfisca_country_template import COUNTRY_DIR, CountryTaxBenefitSystem
|
|
13
|
+
|
|
14
|
+
from . import xml_to_yaml
|
|
15
|
+
|
|
16
|
+
tax_benefit_system = CountryTaxBenefitSystem()
|
|
17
|
+
|
|
18
|
+
target_path = sys.argv[1] if len(sys.argv) > 1 else "yaml_parameters"
|
|
19
|
+
|
|
20
|
+
param_dir = os.path.join(COUNTRY_DIR, "parameters")
|
|
21
|
+
param_files = [
|
|
22
|
+
"benefits.xml",
|
|
23
|
+
"general.xml",
|
|
24
|
+
"taxes.xml",
|
|
25
|
+
]
|
|
26
|
+
legislation_xml_info_list = [
|
|
27
|
+
(os.path.join(param_dir, param_file), []) for param_file in param_files
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
xml_to_yaml.write_parameters(legislation_xml_info_list, target_path)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""xml_to_yaml_extension_template.py : Parse XML parameter files for Extension-Template and convert them to YAML files. Comments are NOT transformed.
|
|
2
|
+
|
|
3
|
+
Usage :
|
|
4
|
+
`python xml_to_yaml_extension_template.py output_dir`
|
|
5
|
+
or just (output is written in a directory called `yaml_parameters`):
|
|
6
|
+
`python xml_to_yaml_extension_template.py`
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
import openfisca_extension_template
|
|
13
|
+
|
|
14
|
+
from . import xml_to_yaml
|
|
15
|
+
|
|
16
|
+
target_path = sys.argv[1] if len(sys.argv) > 1 else "yaml_parameters"
|
|
17
|
+
|
|
18
|
+
param_dir = os.path.dirname(openfisca_extension_template.__file__)
|
|
19
|
+
param_files = [
|
|
20
|
+
"parameters.xml",
|
|
21
|
+
]
|
|
22
|
+
legislation_xml_info_list = [
|
|
23
|
+
(os.path.join(param_dir, param_file), []) for param_file in param_files
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
xml_to_yaml.write_parameters(legislation_xml_info_list, target_path)
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# flake8: noqa T001
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import glob
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
from ruamel.yaml import YAML
|
|
8
|
+
from ruamel.yaml.comments import CommentedSeq
|
|
9
|
+
|
|
10
|
+
from openfisca_core.scripts import (
|
|
11
|
+
add_tax_benefit_system_arguments,
|
|
12
|
+
build_tax_benefit_system,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
yaml = YAML()
|
|
16
|
+
yaml.default_flow_style = False
|
|
17
|
+
yaml.width = 4096
|
|
18
|
+
|
|
19
|
+
TEST_METADATA = {
|
|
20
|
+
"period",
|
|
21
|
+
"name",
|
|
22
|
+
"reforms",
|
|
23
|
+
"only_variables",
|
|
24
|
+
"ignore_variables",
|
|
25
|
+
"absolute_error_margin",
|
|
26
|
+
"relative_error_margin",
|
|
27
|
+
"description",
|
|
28
|
+
"keywords",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def build_parser():
|
|
33
|
+
parser = argparse.ArgumentParser()
|
|
34
|
+
parser.add_argument(
|
|
35
|
+
"path",
|
|
36
|
+
help="paths (files or directories) of tests to execute",
|
|
37
|
+
nargs="+",
|
|
38
|
+
)
|
|
39
|
+
return add_tax_benefit_system_arguments(parser)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Migrator:
|
|
43
|
+
def __init__(self, tax_benefit_system) -> None:
|
|
44
|
+
self.tax_benefit_system = tax_benefit_system
|
|
45
|
+
self.entities_by_plural = {
|
|
46
|
+
entity.plural: entity for entity in self.tax_benefit_system.entities
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
def migrate(self, path) -> None:
|
|
50
|
+
if isinstance(path, list):
|
|
51
|
+
for item in path:
|
|
52
|
+
self.migrate(item)
|
|
53
|
+
return
|
|
54
|
+
|
|
55
|
+
if os.path.isdir(path):
|
|
56
|
+
yaml_paths = glob.glob(os.path.join(path, "*.yaml"))
|
|
57
|
+
subdirectories = glob.glob(os.path.join(path, "*/"))
|
|
58
|
+
|
|
59
|
+
for yaml_path in yaml_paths:
|
|
60
|
+
self.migrate(yaml_path)
|
|
61
|
+
|
|
62
|
+
for subdirectory in subdirectories:
|
|
63
|
+
self.migrate(subdirectory)
|
|
64
|
+
|
|
65
|
+
return
|
|
66
|
+
|
|
67
|
+
with open(path) as yaml_file:
|
|
68
|
+
tests = yaml.safe_load(yaml_file)
|
|
69
|
+
if isinstance(tests, CommentedSeq):
|
|
70
|
+
migrated_tests = [self.convert_test(test) for test in tests]
|
|
71
|
+
else:
|
|
72
|
+
migrated_tests = self.convert_test(tests)
|
|
73
|
+
|
|
74
|
+
with open(path, "w") as yaml_file:
|
|
75
|
+
yaml.dump(migrated_tests, yaml_file)
|
|
76
|
+
|
|
77
|
+
def convert_test(self, test):
|
|
78
|
+
if test.get("output"):
|
|
79
|
+
# This test is already converted, ignoring it
|
|
80
|
+
return test
|
|
81
|
+
result = {}
|
|
82
|
+
outputs = test.pop("output_variables")
|
|
83
|
+
inputs = test.pop("input_variables", {})
|
|
84
|
+
for key, value in test.items():
|
|
85
|
+
if key in TEST_METADATA:
|
|
86
|
+
result[key] = value
|
|
87
|
+
else:
|
|
88
|
+
inputs[key] = value
|
|
89
|
+
result["input"] = self.convert_inputs(inputs)
|
|
90
|
+
result["output"] = outputs
|
|
91
|
+
return result
|
|
92
|
+
|
|
93
|
+
def convert_inputs(self, inputs):
|
|
94
|
+
first_key = next(iter(inputs.keys()), None)
|
|
95
|
+
if first_key not in self.entities_by_plural:
|
|
96
|
+
return inputs
|
|
97
|
+
results = {}
|
|
98
|
+
for entity_plural, entities_description in inputs.items():
|
|
99
|
+
entity = self.entities_by_plural[entity_plural]
|
|
100
|
+
if not isinstance(entities_description, (CommentedSeq, list)):
|
|
101
|
+
entities_description = [entities_description]
|
|
102
|
+
if not entity.is_person and len(entities_description) == 1:
|
|
103
|
+
results[entity.key] = remove_id(entities_description[0])
|
|
104
|
+
continue
|
|
105
|
+
results[entity_plural] = self.convert_entities(entity, entities_description)
|
|
106
|
+
|
|
107
|
+
return self.generate_missing_entities(results)
|
|
108
|
+
|
|
109
|
+
def convert_entities(self, entity, entities_description):
|
|
110
|
+
return {
|
|
111
|
+
entity_description.get("id", f"{entity.key}_{index}"): remove_id(
|
|
112
|
+
entity_description,
|
|
113
|
+
)
|
|
114
|
+
for index, entity_description in enumerate(entities_description)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
def generate_missing_entities(self, inputs):
|
|
118
|
+
for entity in self.tax_benefit_system.entities:
|
|
119
|
+
if entity.plural in inputs or entity.key in inputs:
|
|
120
|
+
continue
|
|
121
|
+
persons = inputs[self.tax_benefit_system.person_entity.plural]
|
|
122
|
+
if len(persons) == 1:
|
|
123
|
+
person_id = next(iter(persons))
|
|
124
|
+
inputs[entity.key] = {
|
|
125
|
+
entity.roles[0].plural or entity.roles[0].key: [person_id],
|
|
126
|
+
}
|
|
127
|
+
else:
|
|
128
|
+
inputs[entity.plural] = {
|
|
129
|
+
f"{entity.key}_{index}": {
|
|
130
|
+
entity.roles[0].plural or entity.roles[0].key: [person_id],
|
|
131
|
+
}
|
|
132
|
+
for index, person_id in enumerate(persons.keys())
|
|
133
|
+
}
|
|
134
|
+
return inputs
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def remove_id(input_dict):
|
|
138
|
+
return {key: value for (key, value) in input_dict.items() if key != "id"}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def main() -> None:
|
|
142
|
+
parser = build_parser()
|
|
143
|
+
args = parser.parse_args()
|
|
144
|
+
paths = [os.path.abspath(path) for path in args.path]
|
|
145
|
+
|
|
146
|
+
tax_benefit_system = build_tax_benefit_system(
|
|
147
|
+
args.country_package,
|
|
148
|
+
args.extensions,
|
|
149
|
+
args.reforms,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
Migrator(tax_benefit_system).migrate(paths)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if __name__ == "__main__":
|
|
156
|
+
main()
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
import warnings
|
|
4
|
+
from importlib.metadata import version
|
|
5
|
+
|
|
6
|
+
from openfisca_core.scripts import add_tax_benefit_system_arguments
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
Define the `openfisca` command line interface.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_parser():
|
|
14
|
+
parser = argparse.ArgumentParser()
|
|
15
|
+
parser.add_argument(
|
|
16
|
+
"--version",
|
|
17
|
+
action="version",
|
|
18
|
+
version=f"OpenFisca-Core {version('OpenFisca-Core')}",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
subparsers = parser.add_subparsers(help="Available commands", dest="command")
|
|
22
|
+
subparsers.required = (
|
|
23
|
+
True # Can be added as an argument of add_subparsers in Python 3
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
def build_serve_parser(parser):
|
|
27
|
+
# Define OpenFisca modules configuration
|
|
28
|
+
parser = add_tax_benefit_system_arguments(parser)
|
|
29
|
+
|
|
30
|
+
# Define server configuration
|
|
31
|
+
parser.add_argument(
|
|
32
|
+
"-p",
|
|
33
|
+
"--port",
|
|
34
|
+
action="store",
|
|
35
|
+
help="port to serve on (use --bind to specify host and port)",
|
|
36
|
+
type=int,
|
|
37
|
+
)
|
|
38
|
+
parser.add_argument(
|
|
39
|
+
"--tracker-url",
|
|
40
|
+
action="store",
|
|
41
|
+
help="tracking service url",
|
|
42
|
+
type=str,
|
|
43
|
+
)
|
|
44
|
+
parser.add_argument(
|
|
45
|
+
"--tracker-idsite",
|
|
46
|
+
action="store",
|
|
47
|
+
help="tracking service id site",
|
|
48
|
+
type=int,
|
|
49
|
+
)
|
|
50
|
+
parser.add_argument(
|
|
51
|
+
"--tracker-token",
|
|
52
|
+
action="store",
|
|
53
|
+
help="tracking service authentication token",
|
|
54
|
+
type=str,
|
|
55
|
+
)
|
|
56
|
+
parser.add_argument(
|
|
57
|
+
"--welcome-message",
|
|
58
|
+
action="store",
|
|
59
|
+
help="welcome message users will get when visiting the API root",
|
|
60
|
+
type=str,
|
|
61
|
+
)
|
|
62
|
+
parser.add_argument(
|
|
63
|
+
"-f",
|
|
64
|
+
"--configuration-file",
|
|
65
|
+
action="store",
|
|
66
|
+
help="configuration file",
|
|
67
|
+
type=str,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
return parser
|
|
71
|
+
|
|
72
|
+
parser_serve = subparsers.add_parser("serve", help="Run the OpenFisca Web API")
|
|
73
|
+
parser_serve = build_serve_parser(parser_serve)
|
|
74
|
+
|
|
75
|
+
def build_test_parser(parser):
|
|
76
|
+
parser.add_argument(
|
|
77
|
+
"path",
|
|
78
|
+
help="paths (files or directories) of tests to execute",
|
|
79
|
+
nargs="+",
|
|
80
|
+
)
|
|
81
|
+
parser = add_tax_benefit_system_arguments(parser)
|
|
82
|
+
parser.add_argument(
|
|
83
|
+
"-n",
|
|
84
|
+
"--name_filter",
|
|
85
|
+
default=None,
|
|
86
|
+
help="partial name of tests to execute. Only tests with the given name_filter in their name, file name, or keywords will be run.",
|
|
87
|
+
)
|
|
88
|
+
parser.add_argument(
|
|
89
|
+
"-p",
|
|
90
|
+
"--pdb",
|
|
91
|
+
action="store_true",
|
|
92
|
+
default=False,
|
|
93
|
+
help="drop into debugger on failures or errors",
|
|
94
|
+
)
|
|
95
|
+
parser.add_argument(
|
|
96
|
+
"--performance-graph",
|
|
97
|
+
"--performance",
|
|
98
|
+
action="store_true",
|
|
99
|
+
default=False,
|
|
100
|
+
help="output a performance graph in a 'performance_graph.html' file",
|
|
101
|
+
)
|
|
102
|
+
parser.add_argument(
|
|
103
|
+
"--performance-tables",
|
|
104
|
+
action="store_true",
|
|
105
|
+
default=False,
|
|
106
|
+
help="output performance CSV tables",
|
|
107
|
+
)
|
|
108
|
+
parser.add_argument(
|
|
109
|
+
"-v",
|
|
110
|
+
"--verbose",
|
|
111
|
+
action="store_true",
|
|
112
|
+
default=False,
|
|
113
|
+
help="increase output verbosity. If specified, output the entire calculation trace.",
|
|
114
|
+
)
|
|
115
|
+
parser.add_argument(
|
|
116
|
+
"-a",
|
|
117
|
+
"--aggregate",
|
|
118
|
+
action="store_true",
|
|
119
|
+
default=False,
|
|
120
|
+
help="increase output verbosity to aggregate. If specified, output the avg, max, and min values of the calculation trace. This flag has no effect without --verbose.",
|
|
121
|
+
)
|
|
122
|
+
parser.add_argument(
|
|
123
|
+
"-d",
|
|
124
|
+
"--max-depth",
|
|
125
|
+
type=int,
|
|
126
|
+
default=sys.maxsize,
|
|
127
|
+
help="set maximal verbosity depth. If specified, output the calculation trace up to the provided depth. This flag has no effect without --verbose.",
|
|
128
|
+
)
|
|
129
|
+
parser.add_argument(
|
|
130
|
+
"-o",
|
|
131
|
+
"--only-variables",
|
|
132
|
+
nargs="*",
|
|
133
|
+
default=None,
|
|
134
|
+
help="variables to test. If specified, only test the given variables.",
|
|
135
|
+
)
|
|
136
|
+
parser.add_argument(
|
|
137
|
+
"-i",
|
|
138
|
+
"--ignore-variables",
|
|
139
|
+
nargs="*",
|
|
140
|
+
default=None,
|
|
141
|
+
help="variables to ignore. If specified, do not test the given variables.",
|
|
142
|
+
)
|
|
143
|
+
parser.add_argument(
|
|
144
|
+
"--in-parallel",
|
|
145
|
+
action="store_true",
|
|
146
|
+
default=False,
|
|
147
|
+
help="run tests in parallel",
|
|
148
|
+
)
|
|
149
|
+
parser.add_argument(
|
|
150
|
+
"--num-workers",
|
|
151
|
+
type=int,
|
|
152
|
+
default=0,
|
|
153
|
+
help="number of parallel workers (default: CPU count - 1)",
|
|
154
|
+
)
|
|
155
|
+
parser.add_argument(
|
|
156
|
+
"--ignore-default",
|
|
157
|
+
action="store_true",
|
|
158
|
+
default=False,
|
|
159
|
+
help="in verbose mode, do not display variables that have their default value",
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
return parser
|
|
163
|
+
|
|
164
|
+
parser_test = subparsers.add_parser("test", help="Run OpenFisca YAML tests")
|
|
165
|
+
parser_test = build_test_parser(parser_test)
|
|
166
|
+
|
|
167
|
+
return parser
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def main():
|
|
171
|
+
if sys.argv[0].endswith("openfisca-run-test"):
|
|
172
|
+
sys.argv[0:1] = ["openfisca", "test"]
|
|
173
|
+
message = "The 'openfisca-run-test' command has been deprecated in favor of 'openfisca test' since version 25.0, and will be removed in the future."
|
|
174
|
+
warnings.warn(message, Warning, stacklevel=2)
|
|
175
|
+
|
|
176
|
+
parser = get_parser()
|
|
177
|
+
|
|
178
|
+
args, _ = parser.parse_known_args()
|
|
179
|
+
|
|
180
|
+
if args.command == "serve":
|
|
181
|
+
from openfisca_web_api.scripts.serve import main
|
|
182
|
+
|
|
183
|
+
return sys.exit(main(parser))
|
|
184
|
+
if args.command == "test":
|
|
185
|
+
from openfisca_core.scripts.run_test import main
|
|
186
|
+
|
|
187
|
+
return sys.exit(main(parser))
|
|
188
|
+
return None
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
if __name__ == "__main__":
|
|
192
|
+
sys.exit(main())
|