policyengine 3.1.4__tar.gz → 3.1.6__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.
Files changed (88) hide show
  1. {policyengine-3.1.4 → policyengine-3.1.6}/CHANGELOG.md +14 -0
  2. {policyengine-3.1.4 → policyengine-3.1.6}/PKG-INFO +1 -1
  3. {policyengine-3.1.4 → policyengine-3.1.6}/changelog.yaml +10 -0
  4. {policyengine-3.1.4 → policyengine-3.1.6}/pyproject.toml +1 -1
  5. policyengine-3.1.6/src/policyengine/__pycache__/__init__.cpython-313.pyc +0 -0
  6. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/dataset.py +21 -5
  7. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/parameter.py +2 -0
  8. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/uk/model.py +3 -0
  9. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/us/model.py +3 -0
  10. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine.egg-info/PKG-INFO +1 -1
  11. policyengine-3.1.4/src/policyengine/__pycache__/__init__.cpython-313.pyc +0 -0
  12. {policyengine-3.1.4 → policyengine-3.1.6}/.claude/policyengine-guide.md +0 -0
  13. {policyengine-3.1.4 → policyengine-3.1.6}/.claude/quick-reference.md +0 -0
  14. {policyengine-3.1.4 → policyengine-3.1.6}/.github/CONTRIBUTING.md +0 -0
  15. {policyengine-3.1.4 → policyengine-3.1.6}/.github/changelog_template.md +0 -0
  16. {policyengine-3.1.4 → policyengine-3.1.6}/.github/fetch_version.py +0 -0
  17. {policyengine-3.1.4 → policyengine-3.1.6}/.github/get-changelog-diff.sh +0 -0
  18. {policyengine-3.1.4 → policyengine-3.1.6}/.github/has-functional-changes.sh +0 -0
  19. {policyengine-3.1.4 → policyengine-3.1.6}/.github/is-version-number-acceptable.sh +0 -0
  20. {policyengine-3.1.4 → policyengine-3.1.6}/.github/publish-git-tag.sh +0 -0
  21. {policyengine-3.1.4 → policyengine-3.1.6}/.github/workflows/code_changes.yaml +0 -0
  22. {policyengine-3.1.4 → policyengine-3.1.6}/.github/workflows/docs.yml +0 -0
  23. {policyengine-3.1.4 → policyengine-3.1.6}/.github/workflows/pr_code_changes.yaml +0 -0
  24. {policyengine-3.1.4 → policyengine-3.1.6}/.github/workflows/pr_docs_changes.yaml +0 -0
  25. {policyengine-3.1.4 → policyengine-3.1.6}/.github/workflows/versioning.yaml +0 -0
  26. {policyengine-3.1.4 → policyengine-3.1.6}/.gitignore +0 -0
  27. {policyengine-3.1.4 → policyengine-3.1.6}/CLAUDE.md +0 -0
  28. {policyengine-3.1.4 → policyengine-3.1.6}/LICENSE +0 -0
  29. {policyengine-3.1.4 → policyengine-3.1.6}/Makefile +0 -0
  30. {policyengine-3.1.4 → policyengine-3.1.6}/README.md +0 -0
  31. {policyengine-3.1.4 → policyengine-3.1.6}/changelog_entry.yaml +0 -0
  32. {policyengine-3.1.4 → policyengine-3.1.6}/docs/.gitignore +0 -0
  33. {policyengine-3.1.4 → policyengine-3.1.6}/docs/core-concepts.md +0 -0
  34. {policyengine-3.1.4 → policyengine-3.1.6}/docs/country-models-uk.md +0 -0
  35. {policyengine-3.1.4 → policyengine-3.1.6}/docs/country-models-us.md +0 -0
  36. {policyengine-3.1.4 → policyengine-3.1.6}/docs/dev.md +0 -0
  37. {policyengine-3.1.4 → policyengine-3.1.6}/docs/index.md +0 -0
  38. {policyengine-3.1.4 → policyengine-3.1.6}/docs/myst.yml +0 -0
  39. {policyengine-3.1.4 → policyengine-3.1.6}/docs/visualisation.md +0 -0
  40. {policyengine-3.1.4 → policyengine-3.1.6}/examples/employment_income_variation_uk.py +0 -0
  41. {policyengine-3.1.4 → policyengine-3.1.6}/examples/employment_income_variation_us.py +0 -0
  42. {policyengine-3.1.4 → policyengine-3.1.6}/examples/income_bands_uk.py +0 -0
  43. {policyengine-3.1.4 → policyengine-3.1.6}/examples/income_distribution_us.py +0 -0
  44. {policyengine-3.1.4 → policyengine-3.1.6}/examples/policy_change_uk.py +0 -0
  45. {policyengine-3.1.4 → policyengine-3.1.6}/examples/speedtest_us_simulation.py +0 -0
  46. {policyengine-3.1.4 → policyengine-3.1.6}/setup.cfg +0 -0
  47. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/__init__.py +0 -0
  48. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/__init__.py +0 -0
  49. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/dataset_version.py +0 -0
  50. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/dynamic.py +0 -0
  51. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/output.py +0 -0
  52. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/parameter_value.py +0 -0
  53. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/policy.py +0 -0
  54. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/simulation.py +0 -0
  55. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/tax_benefit_model.py +0 -0
  56. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/tax_benefit_model_version.py +0 -0
  57. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/core/variable.py +0 -0
  58. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/outputs/__init__.py +0 -0
  59. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/outputs/aggregate.py +0 -0
  60. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/outputs/change_aggregate.py +0 -0
  61. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/outputs/decile_impact.py +0 -0
  62. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/uk/__init__.py +0 -0
  63. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/uk/analysis.py +0 -0
  64. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/uk/datasets.py +0 -0
  65. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/uk/outputs.py +0 -0
  66. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/uk.py +0 -0
  67. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/us/__init__.py +0 -0
  68. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/us/analysis.py +0 -0
  69. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/us/datasets.py +0 -0
  70. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/us/outputs.py +0 -0
  71. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/tax_benefit_models/us.py +0 -0
  72. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/utils/__init__.py +0 -0
  73. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/utils/dates.py +0 -0
  74. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/utils/parametric_reforms.py +0 -0
  75. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine/utils/plotting.py +0 -0
  76. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine.egg-info/SOURCES.txt +0 -0
  77. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine.egg-info/dependency_links.txt +0 -0
  78. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine.egg-info/requires.txt +0 -0
  79. {policyengine-3.1.4 → policyengine-3.1.6}/src/policyengine.egg-info/top_level.txt +0 -0
  80. {policyengine-3.1.4 → policyengine-3.1.6}/tests/test_aggregate.py +0 -0
  81. {policyengine-3.1.4 → policyengine-3.1.6}/tests/test_change_aggregate.py +0 -0
  82. {policyengine-3.1.4 → policyengine-3.1.6}/tests/test_entity_mapping.py +0 -0
  83. {policyengine-3.1.4 → policyengine-3.1.6}/tests/test_get_parameter_variable.py +0 -0
  84. {policyengine-3.1.4 → policyengine-3.1.6}/tests/test_uk_dataset.py +0 -0
  85. {policyengine-3.1.4 → policyengine-3.1.6}/tests/test_us_datasets.py +0 -0
  86. {policyengine-3.1.4 → policyengine-3.1.6}/tests/test_us_entity_mapping.py +0 -0
  87. {policyengine-3.1.4 → policyengine-3.1.6}/tests/test_us_simulation.py +0 -0
  88. {policyengine-3.1.4 → policyengine-3.1.6}/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.6] - 2025-11-24 16:23:57
9
+
10
+ ### Fixed
11
+
12
+ - Parameter values now accessible from models.
13
+
14
+ ## [3.1.5] - 2025-11-21 12:59:36
15
+
16
+ ### Fixed
17
+
18
+ - Minor fixes
19
+
8
20
  ## [3.1.4] - 2025-11-20 14:06:49
9
21
 
10
22
  ### Fixed
@@ -221,6 +233,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
221
233
 
222
234
 
223
235
 
236
+ [3.1.6]: https://github.com/PolicyEngine/policyengine.py/compare/3.1.5...3.1.6
237
+ [3.1.5]: https://github.com/PolicyEngine/policyengine.py/compare/3.1.4...3.1.5
224
238
  [3.1.4]: https://github.com/PolicyEngine/policyengine.py/compare/3.1.3...3.1.4
225
239
  [3.1.3]: https://github.com/PolicyEngine/policyengine.py/compare/3.1.2...3.1.3
226
240
  [3.1.2]: https://github.com/PolicyEngine/policyengine.py/compare/3.1.1...3.1.2
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: policyengine
3
- Version: 3.1.4
3
+ Version: 3.1.6
4
4
  Summary: A package to conduct policy analysis using PolicyEngine tax-benefit models.
5
5
  Author-email: PolicyEngine <hello@policyengine.org>
6
6
  License: GNU AFFERO GENERAL PUBLIC LICENSE
@@ -180,3 +180,13 @@
180
180
  fixed:
181
181
  - Minor fixes
182
182
  date: 2025-11-20 14:06:49
183
+ - bump: patch
184
+ changes:
185
+ fixed:
186
+ - Minor fixes
187
+ date: 2025-11-21 12:59:36
188
+ - bump: patch
189
+ changes:
190
+ fixed:
191
+ - Parameter values now accessible from models.
192
+ date: 2025-11-24 16:23:57
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "policyengine"
7
- version = "3.1.4"
7
+ version = "3.1.6"
8
8
  description = "A package to conduct policy analysis using PolicyEngine tax-benefit models."
9
9
  readme = "README.md"
10
10
  authors = [
@@ -1,5 +1,6 @@
1
1
  from uuid import uuid4
2
2
 
3
+ import numpy as np
3
4
  import pandas as pd
4
5
  from microdf import MicroDataFrame
5
6
  from pydantic import BaseModel, ConfigDict, Field
@@ -100,7 +101,7 @@ def map_to_entity(
100
101
  target_entity: str,
101
102
  person_entity: str = "person",
102
103
  columns: list[str] | None = None,
103
- values: list | None = None,
104
+ values: np.ndarray | None = None,
104
105
  how: str = "sum",
105
106
  ) -> MicroDataFrame:
106
107
  """Map data from source entity to target entity using join keys.
@@ -143,6 +144,9 @@ def map_to_entity(
143
144
  # Get source data (convert to plain DataFrame to avoid weighted operations during mapping)
144
145
  source_df = pd.DataFrame(entity_data[source_entity])
145
146
 
147
+ # Track if we should return a MicroSeries (values is a numpy array, not a list)
148
+ return_series = values is not None
149
+
146
150
  # Handle values parameter - create a temporary column with the provided values
147
151
  if values is not None:
148
152
  if len(values) != len(source_df):
@@ -166,7 +170,10 @@ def map_to_entity(
166
170
 
167
171
  # Same entity - return as is
168
172
  if source_entity == target_entity:
169
- return MicroDataFrame(source_df, weights=target_weight)
173
+ result = MicroDataFrame(source_df, weights=target_weight)
174
+ if return_series:
175
+ return result["__mapped_value"]
176
+ return result
170
177
 
171
178
  # Get target data and key
172
179
  target_df = entity_data[target_entity]
@@ -225,7 +232,10 @@ def map_to_entity(
225
232
  # Fill NaN with 0 for groups with no members in source entity
226
233
  result[agg_cols] = result[agg_cols].fillna(0)
227
234
 
228
- return MicroDataFrame(result, weights=target_weight)
235
+ result_df = MicroDataFrame(result, weights=target_weight)
236
+ if return_series:
237
+ return result_df["__mapped_value"]
238
+ return result_df
229
239
 
230
240
  # Group entity to person: expand group-level data to person level
231
241
  if source_entity != person_entity and target_entity == person_entity:
@@ -284,7 +294,10 @@ def map_to_entity(
284
294
  f"Unsupported aggregation method for group->person: {how}. Use 'project' or 'divide'."
285
295
  )
286
296
 
287
- return MicroDataFrame(result, weights=target_weight)
297
+ result_df = MicroDataFrame(result, weights=target_weight)
298
+ if return_series:
299
+ return result_df["__mapped_value"]
300
+ return result_df
288
301
 
289
302
  # Group to group: go through person table
290
303
  if source_entity != person_entity and target_entity != person_entity:
@@ -408,7 +421,10 @@ def map_to_entity(
408
421
  # Fill NaN with 0
409
422
  result[agg_cols] = result[agg_cols].fillna(0)
410
423
 
411
- return MicroDataFrame(result, weights=target_weight)
424
+ result_df = MicroDataFrame(result, weights=target_weight)
425
+ if return_series:
426
+ return result_df["__mapped_value"]
427
+ return result_df
412
428
 
413
429
  raise ValueError(
414
430
  f"Unsupported mapping from {source_entity} to {target_entity}"
@@ -2,6 +2,7 @@ from uuid import uuid4
2
2
 
3
3
  from pydantic import BaseModel, Field
4
4
 
5
+ from .parameter_value import ParameterValue
5
6
  from .tax_benefit_model_version import TaxBenefitModelVersion
6
7
 
7
8
 
@@ -13,3 +14,4 @@ class Parameter(BaseModel):
13
14
  data_type: type | None = None
14
15
  tax_benefit_model_version: TaxBenefitModelVersion
15
16
  unit: str | None = None
17
+ parameter_values: list["ParameterValue"] = Field(default_factory=list)
@@ -177,6 +177,9 @@ class PolicyEngineUKLatest(TaxBenefitModelVersion):
177
177
  value=param_at_instant.value,
178
178
  )
179
179
  self.parameter_values.append(parameter_value)
180
+ self.get_parameter(parameter.name).parameter_values.append(
181
+ parameter_value
182
+ )
180
183
 
181
184
  def run(self, simulation: "Simulation") -> "Simulation":
182
185
  from policyengine_uk import Microsimulation
@@ -167,6 +167,9 @@ class PolicyEngineUSLatest(TaxBenefitModelVersion):
167
167
  value=param_at_instant.value,
168
168
  )
169
169
  self.parameter_values.append(parameter_value)
170
+ self.get_parameter(parameter.name).parameter_values.append(
171
+ parameter_value
172
+ )
170
173
 
171
174
  def run(self, simulation: "Simulation") -> "Simulation":
172
175
  from policyengine_us import Microsimulation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: policyengine
3
- Version: 3.1.4
3
+ Version: 3.1.6
4
4
  Summary: A package to conduct policy analysis using PolicyEngine tax-benefit models.
5
5
  Author-email: PolicyEngine <hello@policyengine.org>
6
6
  License: GNU AFFERO GENERAL PUBLIC LICENSE
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