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
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"""Type aliases of OpenFisca models to use in the context of simulations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import datetime
|
|
6
|
+
from abc import abstractmethod
|
|
7
|
+
from collections.abc import Iterable, Sequence
|
|
8
|
+
from typing import NotRequired, Protocol, Required, TypeAlias, TypedDict, TypeVar
|
|
9
|
+
|
|
10
|
+
from numpy import (
|
|
11
|
+
bool_ as Bool,
|
|
12
|
+
)
|
|
13
|
+
from numpy import (
|
|
14
|
+
datetime64 as Date,
|
|
15
|
+
)
|
|
16
|
+
from numpy import (
|
|
17
|
+
float32 as Float,
|
|
18
|
+
)
|
|
19
|
+
from numpy import (
|
|
20
|
+
int16 as Enum,
|
|
21
|
+
)
|
|
22
|
+
from numpy import (
|
|
23
|
+
int32 as Int,
|
|
24
|
+
)
|
|
25
|
+
from numpy import (
|
|
26
|
+
str_ as String,
|
|
27
|
+
)
|
|
28
|
+
from numpy.typing import NDArray as Array
|
|
29
|
+
|
|
30
|
+
#: Generic type variables.
|
|
31
|
+
E = TypeVar("E")
|
|
32
|
+
G = TypeVar("G", covariant=True)
|
|
33
|
+
T = TypeVar("T", Bool, Date, Enum, Float, Int, String, covariant=True)
|
|
34
|
+
U = TypeVar("U", bool, datetime.date, float, str)
|
|
35
|
+
V = TypeVar("V", covariant=True)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
#: Type alias for a simulation dictionary defining the roles.
|
|
39
|
+
Roles: TypeAlias = dict[str, str | Iterable[str]]
|
|
40
|
+
|
|
41
|
+
#: Type alias for a simulation dictionary with undated variables.
|
|
42
|
+
UndatedVariable: TypeAlias = dict[str, object]
|
|
43
|
+
|
|
44
|
+
#: Type alias for a simulation dictionary with dated variables.
|
|
45
|
+
DatedVariable: TypeAlias = dict[str, UndatedVariable]
|
|
46
|
+
|
|
47
|
+
#: Type alias for a simulation dictionary with abbreviated entities.
|
|
48
|
+
Variables: TypeAlias = dict[str, UndatedVariable | DatedVariable]
|
|
49
|
+
|
|
50
|
+
#: Type alias for a simulation with fully specified single entities.
|
|
51
|
+
SingleEntities: TypeAlias = dict[str, dict[str, Variables]]
|
|
52
|
+
|
|
53
|
+
#: Type alias for a simulation dictionary with implicit group entities.
|
|
54
|
+
ImplicitGroupEntities: TypeAlias = dict[str, Roles | Variables]
|
|
55
|
+
|
|
56
|
+
#: Type alias for a simulation dictionary with explicit group entities.
|
|
57
|
+
GroupEntities: TypeAlias = dict[str, ImplicitGroupEntities]
|
|
58
|
+
|
|
59
|
+
#: Type alias for a simulation dictionary with fully specified entities.
|
|
60
|
+
FullySpecifiedEntities: TypeAlias = SingleEntities | GroupEntities
|
|
61
|
+
|
|
62
|
+
#: Type alias for a simulation dictionary with axes parameters.
|
|
63
|
+
Axes: TypeAlias = dict[str, Iterable[Iterable["Axis"]]]
|
|
64
|
+
|
|
65
|
+
#: Type alias for a simulation dictionary without axes parameters.
|
|
66
|
+
ParamsWithoutAxes: TypeAlias = (
|
|
67
|
+
Variables | ImplicitGroupEntities | FullySpecifiedEntities
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
#: Type alias for a simulation dictionary with axes parameters.
|
|
71
|
+
ParamsWithAxes: TypeAlias = Axes | ParamsWithoutAxes
|
|
72
|
+
|
|
73
|
+
#: Type alias for a simulation dictionary with all the possible scenarios.
|
|
74
|
+
Params: TypeAlias = ParamsWithAxes
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class Axis(TypedDict, total=False):
|
|
78
|
+
"""Interface representing an axis of a simulation."""
|
|
79
|
+
|
|
80
|
+
count: Required[int]
|
|
81
|
+
index: NotRequired[int]
|
|
82
|
+
max: Required[float]
|
|
83
|
+
min: Required[float]
|
|
84
|
+
name: Required[str]
|
|
85
|
+
period: NotRequired[str | int]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class Entity(Protocol):
|
|
89
|
+
"""Interface representing an entity of a simulation."""
|
|
90
|
+
|
|
91
|
+
key: str
|
|
92
|
+
plural: str | None
|
|
93
|
+
|
|
94
|
+
def get_variable(
|
|
95
|
+
self, variable_name: str, check_existence: bool = ..., /
|
|
96
|
+
) -> Variable[T] | None:
|
|
97
|
+
"""Get a variable."""
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class SingleEntity(Entity, Protocol):
|
|
101
|
+
"""Interface representing a single entity of a simulation."""
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class GroupEntity(Entity, Protocol):
|
|
105
|
+
"""Interface representing a group entity of a simulation."""
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
@abstractmethod
|
|
109
|
+
def flattened_roles(self) -> Iterable[Role[G]]:
|
|
110
|
+
"""Get the flattened roles of the GroupEntity."""
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class Holder(Protocol[V]):
|
|
114
|
+
"""Interface representing a holder of a simulation's computed values."""
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
@abstractmethod
|
|
118
|
+
def variable(self) -> Variable[T]:
|
|
119
|
+
"""Get the Variable of the Holder."""
|
|
120
|
+
|
|
121
|
+
def get_array(self, period: str, /) -> Array[T] | None:
|
|
122
|
+
"""Get the values of the Variable for a given Period."""
|
|
123
|
+
|
|
124
|
+
def set_input(
|
|
125
|
+
self, period: Period, array: Array[T] | Sequence[U], /
|
|
126
|
+
) -> Array[T] | None:
|
|
127
|
+
"""Set values for a Variable for a given Period."""
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class Period(Protocol):
|
|
131
|
+
"""Interface representing a period of a simulation."""
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
class Population(Protocol[E]):
|
|
135
|
+
"""Interface representing a data vector of an Entity."""
|
|
136
|
+
|
|
137
|
+
count: int
|
|
138
|
+
entity: E
|
|
139
|
+
ids: Array[String]
|
|
140
|
+
|
|
141
|
+
def get_holder(self, variable_name: str, /) -> Holder[V]:
|
|
142
|
+
"""Get the holder of a Variable."""
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class SinglePopulation(Population[E], Protocol):
|
|
146
|
+
"""Interface representing a data vector of a SingleEntity."""
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class GroupPopulation(Population[E], Protocol):
|
|
150
|
+
"""Interface representing a data vector of a GroupEntity."""
|
|
151
|
+
|
|
152
|
+
members_entity_id: Array[String]
|
|
153
|
+
|
|
154
|
+
def nb_persons(self, role: Role[G] | None = ..., /) -> int:
|
|
155
|
+
"""Get the number of persons for a given Role."""
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class Role(Protocol[G]):
|
|
159
|
+
"""Interface representing a role of the group entities of a simulation."""
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class TaxBenefitSystem(Protocol):
|
|
163
|
+
"""Interface representing a tax-benefit system."""
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
@abstractmethod
|
|
167
|
+
def person_entity(self) -> SingleEntity:
|
|
168
|
+
"""Get the person entity of the tax-benefit system."""
|
|
169
|
+
|
|
170
|
+
@person_entity.setter
|
|
171
|
+
@abstractmethod
|
|
172
|
+
def person_entity(self, person_entity: SingleEntity) -> None:
|
|
173
|
+
"""Set the person entity of the tax-benefit system."""
|
|
174
|
+
|
|
175
|
+
@property
|
|
176
|
+
@abstractmethod
|
|
177
|
+
def variables(self) -> dict[str, V]:
|
|
178
|
+
"""Get the variables of the tax-benefit system."""
|
|
179
|
+
|
|
180
|
+
def entities_by_singular(self) -> dict[str, E]:
|
|
181
|
+
"""Get the singular form of the entities' keys."""
|
|
182
|
+
|
|
183
|
+
def entities_plural(self) -> Iterable[str]:
|
|
184
|
+
"""Get the plural form of the entities' keys."""
|
|
185
|
+
|
|
186
|
+
def get_variable(
|
|
187
|
+
self, variable_name: str, check_existence: bool = ..., /
|
|
188
|
+
) -> V | None:
|
|
189
|
+
"""Get a variable."""
|
|
190
|
+
|
|
191
|
+
def instantiate_entities(
|
|
192
|
+
self,
|
|
193
|
+
) -> dict[str, Population[E]]:
|
|
194
|
+
"""Instantiate the populations of each Entity."""
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
class Variable(Protocol[T]):
|
|
198
|
+
"""Interface representing a variable of a tax-benefit system."""
|
|
199
|
+
|
|
200
|
+
end: str
|
|
201
|
+
|
|
202
|
+
def default_array(self, array_size: int, /) -> Array[T]:
|
|
203
|
+
"""Fill an array with the default value of the Variable."""
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Transitional imports to ensure non-breaking changes.
|
|
2
|
+
# Could be deprecated in the next major release.
|
|
3
|
+
#
|
|
4
|
+
# How imports are being used today:
|
|
5
|
+
#
|
|
6
|
+
# >>> from openfisca_core.module import symbol
|
|
7
|
+
#
|
|
8
|
+
# The previous example provokes cyclic dependency problems
|
|
9
|
+
# that prevent us from modularizing the different components
|
|
10
|
+
# of the library so to make them easier to test and to maintain.
|
|
11
|
+
#
|
|
12
|
+
# How could them be used after the next major release:
|
|
13
|
+
#
|
|
14
|
+
# >>> from openfisca_core import module
|
|
15
|
+
# >>> module.symbol()
|
|
16
|
+
#
|
|
17
|
+
# And for classes:
|
|
18
|
+
#
|
|
19
|
+
# >>> from openfisca_core.module import Symbol
|
|
20
|
+
# >>> Symbol()
|
|
21
|
+
#
|
|
22
|
+
# See: https://www.python.org/dev/peps/pep-0008/#imports
|
|
23
|
+
|
|
24
|
+
from openfisca_core.errors import VariableNameConflict, VariableNotFound # noqa: F401
|
|
25
|
+
|
|
26
|
+
from .tax_benefit_system import TaxBenefitSystem # noqa: F401
|