policyengine 3.1.11__tar.gz → 3.1.13__tar.gz
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.
- {policyengine-3.1.11 → policyengine-3.1.13}/CHANGELOG.md +14 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/PKG-INFO +1 -1
- {policyengine-3.1.11 → policyengine-3.1.13}/changelog.yaml +10 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/pyproject.toml +1 -1
- policyengine-3.1.13/src/policyengine/__pycache__/__init__.cpython-313.pyc +0 -0
- policyengine-3.1.13/src/policyengine/core/parameter.py +65 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/tax_benefit_model_version.py +25 -27
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/uk/datasets.py +4 -4
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/uk/model.py +4 -28
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/us/datasets.py +3 -3
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/us/model.py +3 -25
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine.egg-info/PKG-INFO +1 -1
- policyengine-3.1.11/src/policyengine/__pycache__/__init__.cpython-313.pyc +0 -0
- policyengine-3.1.11/src/policyengine/core/parameter.py +0 -21
- {policyengine-3.1.11 → policyengine-3.1.13}/.claude/policyengine-guide.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.claude/quick-reference.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/CONTRIBUTING.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/changelog_template.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/fetch_version.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/get-changelog-diff.sh +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/has-functional-changes.sh +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/is-version-number-acceptable.sh +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/publish-git-tag.sh +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/workflows/code_changes.yaml +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/workflows/docs.yml +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/workflows/pr_code_changes.yaml +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/workflows/pr_docs_changes.yaml +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.github/workflows/versioning.yaml +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/.gitignore +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/CLAUDE.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/LICENSE +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/Makefile +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/README.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/changelog_entry.yaml +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/docs/.gitignore +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/docs/core-concepts.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/docs/country-models-uk.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/docs/country-models-us.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/docs/dev.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/docs/index.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/docs/myst.yml +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/docs/visualisation.md +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/examples/employment_income_variation_uk.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/examples/employment_income_variation_us.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/examples/income_bands_uk.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/examples/income_distribution_us.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/examples/policy_change_uk.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/examples/speedtest_us_simulation.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/setup.cfg +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/__init__.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/__init__.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/cache.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/dataset.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/dataset_version.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/dynamic.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/output.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/parameter_value.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/policy.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/simulation.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/tax_benefit_model.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/variable.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/outputs/__init__.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/outputs/aggregate.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/outputs/change_aggregate.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/outputs/decile_impact.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/uk/__init__.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/uk/analysis.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/uk/outputs.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/uk.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/us/__init__.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/us/analysis.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/us/outputs.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/us.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/utils/__init__.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/utils/dates.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/utils/parametric_reforms.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/utils/plotting.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine.egg-info/SOURCES.txt +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine.egg-info/dependency_links.txt +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine.egg-info/requires.txt +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine.egg-info/top_level.txt +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/tests/test_aggregate.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/tests/test_cache.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/tests/test_change_aggregate.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/tests/test_entity_mapping.py +0 -0
- {policyengine-3.1.11 → policyengine-3.1.13}/uv.lock +0 -0
|
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.1.13] - 2025-12-10 19:29:28
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Naming improvements.
|
|
13
|
+
|
|
14
|
+
## [3.1.12] - 2025-12-10 14:43:52
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Bug where all datasets would be the last year.
|
|
19
|
+
|
|
8
20
|
## [3.1.11] - 2025-12-02 14:03:39
|
|
9
21
|
|
|
10
22
|
### Fixed
|
|
@@ -263,6 +275,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
263
275
|
|
|
264
276
|
|
|
265
277
|
|
|
278
|
+
[3.1.13]: https://github.com/PolicyEngine/policyengine.py/compare/3.1.12...3.1.13
|
|
279
|
+
[3.1.12]: https://github.com/PolicyEngine/policyengine.py/compare/3.1.11...3.1.12
|
|
266
280
|
[3.1.11]: https://github.com/PolicyEngine/policyengine.py/compare/3.1.10...3.1.11
|
|
267
281
|
[3.1.10]: https://github.com/PolicyEngine/policyengine.py/compare/3.1.9...3.1.10
|
|
268
282
|
[3.1.9]: https://github.com/PolicyEngine/policyengine.py/compare/3.1.8...3.1.9
|
|
@@ -215,3 +215,13 @@
|
|
|
215
215
|
fixed:
|
|
216
216
|
- Caching didn't save time!
|
|
217
217
|
date: 2025-12-02 14:03:39
|
|
218
|
+
- bump: patch
|
|
219
|
+
changes:
|
|
220
|
+
fixed:
|
|
221
|
+
- Bug where all datasets would be the last year.
|
|
222
|
+
date: 2025-12-10 14:43:52
|
|
223
|
+
- bump: patch
|
|
224
|
+
changes:
|
|
225
|
+
fixed:
|
|
226
|
+
- Naming improvements.
|
|
227
|
+
date: 2025-12-10 19:29:28
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING, Any
|
|
2
|
+
from uuid import uuid4
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel, Field, PrivateAttr
|
|
5
|
+
|
|
6
|
+
from .parameter_value import ParameterValue
|
|
7
|
+
from .tax_benefit_model_version import TaxBenefitModelVersion
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from .parameter_value import ParameterValue
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Parameter(BaseModel):
|
|
14
|
+
model_config = {"arbitrary_types_allowed": True}
|
|
15
|
+
|
|
16
|
+
id: str = Field(default_factory=lambda: str(uuid4()))
|
|
17
|
+
name: str
|
|
18
|
+
label: str | None = None
|
|
19
|
+
description: str | None = None
|
|
20
|
+
data_type: type | None = None
|
|
21
|
+
tax_benefit_model_version: TaxBenefitModelVersion
|
|
22
|
+
unit: str | None = None
|
|
23
|
+
|
|
24
|
+
# Lazy loading: store core param ref, build values on demand
|
|
25
|
+
_core_param: Any = PrivateAttr(default=None)
|
|
26
|
+
_parameter_values: list["ParameterValue"] | None = PrivateAttr(
|
|
27
|
+
default=None
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
def __init__(self, _core_param: Any = None, **data):
|
|
31
|
+
super().__init__(**data)
|
|
32
|
+
self._core_param = _core_param
|
|
33
|
+
self._parameter_values = None
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def parameter_values(self) -> list["ParameterValue"]:
|
|
37
|
+
"""Lazily build parameter values on first access."""
|
|
38
|
+
if self._parameter_values is None:
|
|
39
|
+
self._parameter_values = []
|
|
40
|
+
if self._core_param is not None:
|
|
41
|
+
from policyengine.utils import parse_safe_date
|
|
42
|
+
|
|
43
|
+
for i in range(len(self._core_param.values_list)):
|
|
44
|
+
param_at_instant = self._core_param.values_list[i]
|
|
45
|
+
if i + 1 < len(self._core_param.values_list):
|
|
46
|
+
next_instant = self._core_param.values_list[i + 1]
|
|
47
|
+
else:
|
|
48
|
+
next_instant = None
|
|
49
|
+
pv = ParameterValue(
|
|
50
|
+
parameter=self,
|
|
51
|
+
start_date=parse_safe_date(
|
|
52
|
+
param_at_instant.instant_str
|
|
53
|
+
),
|
|
54
|
+
end_date=parse_safe_date(next_instant.instant_str)
|
|
55
|
+
if next_instant
|
|
56
|
+
else None,
|
|
57
|
+
value=param_at_instant.value,
|
|
58
|
+
)
|
|
59
|
+
self._parameter_values.append(pv)
|
|
60
|
+
return self._parameter_values
|
|
61
|
+
|
|
62
|
+
@parameter_values.setter
|
|
63
|
+
def parameter_values(self, value: list["ParameterValue"]) -> None:
|
|
64
|
+
"""Allow direct setting of parameter values."""
|
|
65
|
+
self._parameter_values = value
|
{policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/core/tax_benefit_model_version.py
RENAMED
|
@@ -14,6 +14,8 @@ if TYPE_CHECKING:
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class TaxBenefitModelVersion(BaseModel):
|
|
17
|
+
model_config = {"arbitrary_types_allowed": True}
|
|
18
|
+
|
|
17
19
|
id: str = Field(default_factory=lambda: str(uuid4()))
|
|
18
20
|
model: TaxBenefitModel
|
|
19
21
|
version: str
|
|
@@ -24,6 +26,14 @@ class TaxBenefitModelVersion(BaseModel):
|
|
|
24
26
|
parameters: list["Parameter"] = Field(default_factory=list)
|
|
25
27
|
parameter_values: list["ParameterValue"] = Field(default_factory=list)
|
|
26
28
|
|
|
29
|
+
# Lookup dicts for O(1) access (excluded from serialization)
|
|
30
|
+
variables_by_name: dict[str, "Variable"] = Field(
|
|
31
|
+
default_factory=dict, exclude=True
|
|
32
|
+
)
|
|
33
|
+
parameters_by_name: dict[str, "Parameter"] = Field(
|
|
34
|
+
default_factory=dict, exclude=True
|
|
35
|
+
)
|
|
36
|
+
|
|
27
37
|
def run(self, simulation: "Simulation") -> "Simulation":
|
|
28
38
|
raise NotImplementedError(
|
|
29
39
|
"The TaxBenefitModel class must define a method to execute simulations."
|
|
@@ -39,40 +49,28 @@ class TaxBenefitModelVersion(BaseModel):
|
|
|
39
49
|
"The TaxBenefitModel class must define a method to load simulations."
|
|
40
50
|
)
|
|
41
51
|
|
|
42
|
-
def
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
name: The parameter name (e.g., "gov.hmrc.income_tax.allowances.personal_allowance.amount")
|
|
52
|
+
def add_parameter(self, param: "Parameter") -> None:
|
|
53
|
+
"""Add a parameter and index it for fast lookup."""
|
|
54
|
+
self.parameters.append(param)
|
|
55
|
+
self.parameters_by_name[param.name] = param
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
def add_variable(self, var: "Variable") -> None:
|
|
58
|
+
"""Add a variable and index it for fast lookup."""
|
|
59
|
+
self.variables.append(var)
|
|
60
|
+
self.variables_by_name[var.name] = var
|
|
50
61
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if param.name == name:
|
|
56
|
-
return param
|
|
62
|
+
def get_parameter(self, name: str) -> "Parameter":
|
|
63
|
+
"""Get a parameter by name (O(1) lookup)."""
|
|
64
|
+
if name in self.parameters_by_name:
|
|
65
|
+
return self.parameters_by_name[name]
|
|
57
66
|
raise ValueError(
|
|
58
67
|
f"Parameter '{name}' not found in {self.model.id} version {self.version}"
|
|
59
68
|
)
|
|
60
69
|
|
|
61
70
|
def get_variable(self, name: str) -> "Variable":
|
|
62
|
-
"""Get a variable by name.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
name: The variable name (e.g., "income_tax", "household_net_income")
|
|
66
|
-
|
|
67
|
-
Returns:
|
|
68
|
-
Variable: The matching variable
|
|
69
|
-
|
|
70
|
-
Raises:
|
|
71
|
-
ValueError: If variable not found
|
|
72
|
-
"""
|
|
73
|
-
for var in self.variables:
|
|
74
|
-
if var.name == name:
|
|
75
|
-
return var
|
|
71
|
+
"""Get a variable by name (O(1) lookup)."""
|
|
72
|
+
if name in self.variables_by_name:
|
|
73
|
+
return self.variables_by_name[name]
|
|
76
74
|
raise ValueError(
|
|
77
75
|
f"Variable '{name}' not found in {self.model.id} version {self.version}"
|
|
78
76
|
)
|
{policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/uk/datasets.py
RENAMED
|
@@ -161,10 +161,10 @@ def create_datasets(
|
|
|
161
161
|
|
|
162
162
|
uk_dataset = PolicyEngineUKDataset(
|
|
163
163
|
id=f"{Path(dataset).stem}_year_{year}",
|
|
164
|
-
name=f"{dataset}-year-{year}",
|
|
165
|
-
description=f"UK Dataset for year {year} based on {dataset}",
|
|
164
|
+
name=f"{Path(dataset).stem}-year-{year}",
|
|
165
|
+
description=f"UK Dataset for year {year} based on {Path(dataset).stem}",
|
|
166
166
|
filepath=f"{data_folder}/{Path(dataset).stem}_year_{year}.h5",
|
|
167
|
-
year=year,
|
|
167
|
+
year=int(year),
|
|
168
168
|
data=UKYearData(
|
|
169
169
|
person=MicroDataFrame(person_df, weights="person_weight"),
|
|
170
170
|
benunit=MicroDataFrame(
|
|
@@ -199,7 +199,7 @@ def load_datasets(
|
|
|
199
199
|
name=f"{dataset}-year-{year}",
|
|
200
200
|
description=f"UK Dataset for year {year} based on {dataset}",
|
|
201
201
|
filepath=filepath,
|
|
202
|
-
year=year,
|
|
202
|
+
year=int(year),
|
|
203
203
|
)
|
|
204
204
|
uk_dataset.load()
|
|
205
205
|
|
|
@@ -118,7 +118,6 @@ class PolicyEngineUKLatest(TaxBenefitModelVersion):
|
|
|
118
118
|
|
|
119
119
|
self.id = f"{self.model.id}@{self.version}"
|
|
120
120
|
|
|
121
|
-
self.variables = []
|
|
122
121
|
for var_obj in system.variables.values():
|
|
123
122
|
variable = Variable(
|
|
124
123
|
id=self.id + "-" + var_obj.name,
|
|
@@ -140,9 +139,8 @@ class PolicyEngineUKLatest(TaxBenefitModelVersion):
|
|
|
140
139
|
var_obj.possible_values._value2member_map_.values(),
|
|
141
140
|
)
|
|
142
141
|
)
|
|
143
|
-
self.
|
|
142
|
+
self.add_variable(variable)
|
|
144
143
|
|
|
145
|
-
self.parameters = []
|
|
146
144
|
from policyengine_core.parameters import Parameter as CoreParameter
|
|
147
145
|
|
|
148
146
|
for param_node in system.parameters.get_descendants():
|
|
@@ -153,33 +151,11 @@ class PolicyEngineUKLatest(TaxBenefitModelVersion):
|
|
|
153
151
|
label=param_node.metadata.get("label", param_node.name),
|
|
154
152
|
tax_benefit_model_version=self,
|
|
155
153
|
description=param_node.description,
|
|
156
|
-
data_type=type(
|
|
157
|
-
param_node(2025)
|
|
158
|
-
), # Example year to infer type
|
|
154
|
+
data_type=type(param_node(2025)),
|
|
159
155
|
unit=param_node.metadata.get("unit"),
|
|
156
|
+
_core_param=param_node, # Store for lazy value loading
|
|
160
157
|
)
|
|
161
|
-
self.
|
|
162
|
-
|
|
163
|
-
for i in range(len(param_node.values_list)):
|
|
164
|
-
param_at_instant = param_node.values_list[i]
|
|
165
|
-
if i + 1 < len(param_node.values_list):
|
|
166
|
-
next_instant = param_node.values_list[i + 1]
|
|
167
|
-
else:
|
|
168
|
-
next_instant = None
|
|
169
|
-
parameter_value = ParameterValue(
|
|
170
|
-
parameter=parameter,
|
|
171
|
-
start_date=parse_safe_date(
|
|
172
|
-
param_at_instant.instant_str
|
|
173
|
-
),
|
|
174
|
-
end_date=parse_safe_date(next_instant.instant_str)
|
|
175
|
-
if next_instant
|
|
176
|
-
else None,
|
|
177
|
-
value=param_at_instant.value,
|
|
178
|
-
)
|
|
179
|
-
self.parameter_values.append(parameter_value)
|
|
180
|
-
self.get_parameter(parameter.name).parameter_values.append(
|
|
181
|
-
parameter_value
|
|
182
|
-
)
|
|
158
|
+
self.add_parameter(parameter)
|
|
183
159
|
|
|
184
160
|
def run(self, simulation: "Simulation") -> "Simulation":
|
|
185
161
|
from policyengine_uk import Microsimulation
|
{policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/us/datasets.py
RENAMED
|
@@ -266,10 +266,10 @@ def create_datasets(
|
|
|
266
266
|
|
|
267
267
|
us_dataset = PolicyEngineUSDataset(
|
|
268
268
|
id=f"{Path(dataset).stem}_year_{year}",
|
|
269
|
-
name=f"{dataset}-year-{year}",
|
|
270
|
-
description=f"US Dataset for year {year} based on {dataset}",
|
|
269
|
+
name=f"{Path(dataset).stem}-year-{year}",
|
|
270
|
+
description=f"US Dataset for year {year} based on {Path(dataset).stem}",
|
|
271
271
|
filepath=f"{data_folder}/{Path(dataset).stem}_year_{year}.h5",
|
|
272
|
-
year=year,
|
|
272
|
+
year=int(year),
|
|
273
273
|
data=USYearData(
|
|
274
274
|
person=MicroDataFrame(person_df, weights="person_weight"),
|
|
275
275
|
household=MicroDataFrame(
|
|
@@ -111,7 +111,6 @@ class PolicyEngineUSLatest(TaxBenefitModelVersion):
|
|
|
111
111
|
|
|
112
112
|
self.id = f"{self.model.id}@{self.version}"
|
|
113
113
|
|
|
114
|
-
self.variables = []
|
|
115
114
|
for var_obj in system.variables.values():
|
|
116
115
|
variable = Variable(
|
|
117
116
|
id=self.id + "-" + var_obj.name,
|
|
@@ -133,9 +132,8 @@ class PolicyEngineUSLatest(TaxBenefitModelVersion):
|
|
|
133
132
|
var_obj.possible_values._value2member_map_.values(),
|
|
134
133
|
)
|
|
135
134
|
)
|
|
136
|
-
self.
|
|
135
|
+
self.add_variable(variable)
|
|
137
136
|
|
|
138
|
-
self.parameters = []
|
|
139
137
|
from policyengine_core.parameters import Parameter as CoreParameter
|
|
140
138
|
|
|
141
139
|
for param_node in system.parameters.get_descendants():
|
|
@@ -147,29 +145,9 @@ class PolicyEngineUSLatest(TaxBenefitModelVersion):
|
|
|
147
145
|
description=param_node.description,
|
|
148
146
|
data_type=type(param_node(2025)),
|
|
149
147
|
unit=param_node.metadata.get("unit"),
|
|
148
|
+
_core_param=param_node, # Store for lazy value loading
|
|
150
149
|
)
|
|
151
|
-
self.
|
|
152
|
-
|
|
153
|
-
for i in range(len(param_node.values_list)):
|
|
154
|
-
param_at_instant = param_node.values_list[i]
|
|
155
|
-
if i + 1 < len(param_node.values_list):
|
|
156
|
-
next_instant = param_node.values_list[i + 1]
|
|
157
|
-
else:
|
|
158
|
-
next_instant = None
|
|
159
|
-
parameter_value = ParameterValue(
|
|
160
|
-
parameter=parameter,
|
|
161
|
-
start_date=parse_safe_date(
|
|
162
|
-
param_at_instant.instant_str
|
|
163
|
-
),
|
|
164
|
-
end_date=parse_safe_date(next_instant.instant_str)
|
|
165
|
-
if next_instant
|
|
166
|
-
else None,
|
|
167
|
-
value=param_at_instant.value,
|
|
168
|
-
)
|
|
169
|
-
self.parameter_values.append(parameter_value)
|
|
170
|
-
self.get_parameter(parameter.name).parameter_values.append(
|
|
171
|
-
parameter_value
|
|
172
|
-
)
|
|
150
|
+
self.add_parameter(parameter)
|
|
173
151
|
|
|
174
152
|
def run(self, simulation: "Simulation") -> "Simulation":
|
|
175
153
|
from policyengine_us import Microsimulation
|
|
Binary file
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
from typing import TYPE_CHECKING
|
|
2
|
-
from uuid import uuid4
|
|
3
|
-
|
|
4
|
-
from pydantic import BaseModel, Field
|
|
5
|
-
|
|
6
|
-
from .parameter_value import ParameterValue
|
|
7
|
-
from .tax_benefit_model_version import TaxBenefitModelVersion
|
|
8
|
-
|
|
9
|
-
if TYPE_CHECKING:
|
|
10
|
-
from .parameter_value import ParameterValue
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class Parameter(BaseModel):
|
|
14
|
-
id: str = Field(default_factory=lambda: str(uuid4()))
|
|
15
|
-
name: str
|
|
16
|
-
label: str | None = None
|
|
17
|
-
description: str | None = None
|
|
18
|
-
data_type: type | None = None
|
|
19
|
-
tax_benefit_model_version: TaxBenefitModelVersion
|
|
20
|
-
unit: str | None = None
|
|
21
|
-
parameter_values: list["ParameterValue"] = Field(default_factory=list)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/uk/__init__.py
RENAMED
|
File without changes
|
{policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/uk/analysis.py
RENAMED
|
File without changes
|
{policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/uk/outputs.py
RENAMED
|
File without changes
|
|
File without changes
|
{policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/us/__init__.py
RENAMED
|
File without changes
|
{policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/us/analysis.py
RENAMED
|
File without changes
|
{policyengine-3.1.11 → policyengine-3.1.13}/src/policyengine/tax_benefit_models/us/outputs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|