policyengine 3.0.0__py3-none-any.whl → 3.1.1__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.
- policyengine/__pycache__/__init__.cpython-313.pyc +0 -0
- policyengine/core/__init__.py +22 -0
- policyengine/core/dataset.py +260 -0
- policyengine/core/dataset_version.py +16 -0
- policyengine/core/dynamic.py +43 -0
- policyengine/core/output.py +26 -0
- policyengine/{models → core}/parameter.py +4 -2
- policyengine/{models → core}/parameter_value.py +1 -1
- policyengine/core/policy.py +43 -0
- policyengine/{models → core}/simulation.py +10 -14
- policyengine/core/tax_benefit_model.py +11 -0
- policyengine/core/tax_benefit_model_version.py +34 -0
- policyengine/core/variable.py +15 -0
- policyengine/outputs/__init__.py +21 -0
- policyengine/outputs/aggregate.py +124 -0
- policyengine/outputs/change_aggregate.py +184 -0
- policyengine/outputs/decile_impact.py +140 -0
- policyengine/tax_benefit_models/uk/__init__.py +26 -0
- policyengine/tax_benefit_models/uk/analysis.py +97 -0
- policyengine/tax_benefit_models/uk/datasets.py +176 -0
- policyengine/tax_benefit_models/uk/model.py +268 -0
- policyengine/tax_benefit_models/uk/outputs.py +108 -0
- policyengine/tax_benefit_models/uk.py +33 -0
- policyengine/tax_benefit_models/us/__init__.py +36 -0
- policyengine/tax_benefit_models/us/analysis.py +99 -0
- policyengine/tax_benefit_models/us/datasets.py +307 -0
- policyengine/tax_benefit_models/us/model.py +447 -0
- policyengine/tax_benefit_models/us/outputs.py +108 -0
- policyengine/tax_benefit_models/us.py +32 -0
- policyengine/utils/__init__.py +3 -0
- policyengine/utils/dates.py +40 -0
- policyengine/utils/parametric_reforms.py +39 -0
- policyengine/utils/plotting.py +179 -0
- {policyengine-3.0.0.dist-info → policyengine-3.1.1.dist-info}/METADATA +185 -20
- policyengine-3.1.1.dist-info/RECORD +39 -0
- policyengine/database/__init__.py +0 -56
- policyengine/database/aggregate.py +0 -33
- policyengine/database/baseline_parameter_value_table.py +0 -66
- policyengine/database/baseline_variable_table.py +0 -40
- policyengine/database/database.py +0 -251
- policyengine/database/dataset_table.py +0 -41
- policyengine/database/dynamic_table.py +0 -34
- policyengine/database/link.py +0 -82
- policyengine/database/model_table.py +0 -27
- policyengine/database/model_version_table.py +0 -28
- policyengine/database/parameter_table.py +0 -31
- policyengine/database/parameter_value_table.py +0 -62
- policyengine/database/policy_table.py +0 -34
- policyengine/database/report_element_table.py +0 -48
- policyengine/database/report_table.py +0 -24
- policyengine/database/simulation_table.py +0 -50
- policyengine/database/user_table.py +0 -28
- policyengine/database/versioned_dataset_table.py +0 -28
- policyengine/models/__init__.py +0 -30
- policyengine/models/aggregate.py +0 -92
- policyengine/models/baseline_parameter_value.py +0 -14
- policyengine/models/baseline_variable.py +0 -12
- policyengine/models/dataset.py +0 -18
- policyengine/models/dynamic.py +0 -15
- policyengine/models/model.py +0 -124
- policyengine/models/model_version.py +0 -14
- policyengine/models/policy.py +0 -17
- policyengine/models/policyengine_uk.py +0 -114
- policyengine/models/policyengine_us.py +0 -115
- policyengine/models/report.py +0 -10
- policyengine/models/report_element.py +0 -36
- policyengine/models/user.py +0 -14
- policyengine/models/versioned_dataset.py +0 -12
- policyengine/utils/charts.py +0 -286
- policyengine/utils/compress.py +0 -20
- policyengine/utils/datasets.py +0 -71
- policyengine-3.0.0.dist-info/RECORD +0 -47
- policyengine-3.0.0.dist-info/entry_points.txt +0 -2
- {policyengine-3.0.0.dist-info → policyengine-3.1.1.dist-info}/WHEEL +0 -0
- {policyengine-3.0.0.dist-info → policyengine-3.1.1.dist-info}/licenses/LICENSE +0 -0
- {policyengine-3.0.0.dist-info → policyengine-3.1.1.dist-info}/top_level.txt +0 -0
policyengine/models/report.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import uuid
|
|
2
|
-
from datetime import datetime
|
|
3
|
-
from typing import Literal
|
|
4
|
-
|
|
5
|
-
from pydantic import BaseModel, Field
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class ReportElement(BaseModel):
|
|
9
|
-
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
10
|
-
label: str
|
|
11
|
-
type: Literal["chart", "markdown"]
|
|
12
|
-
|
|
13
|
-
# Data source
|
|
14
|
-
data_table: Literal["aggregates"] | None = None # Which table to pull from
|
|
15
|
-
|
|
16
|
-
# Chart configuration
|
|
17
|
-
chart_type: (
|
|
18
|
-
Literal["bar", "line", "scatter", "area", "pie", "histogram"] | None
|
|
19
|
-
) = None
|
|
20
|
-
x_axis_variable: str | None = None # Column name from the table
|
|
21
|
-
y_axis_variable: str | None = None # Column name from the table
|
|
22
|
-
group_by: str | None = None # Column to group/split series by
|
|
23
|
-
color_by: str | None = None # Column for color mapping
|
|
24
|
-
size_by: str | None = None # Column for size mapping (bubble charts)
|
|
25
|
-
|
|
26
|
-
# Markdown specific
|
|
27
|
-
markdown_content: str | None = None
|
|
28
|
-
|
|
29
|
-
# Metadata
|
|
30
|
-
report_id: str | None = None
|
|
31
|
-
user_id: str | None = None
|
|
32
|
-
position: int | None = None
|
|
33
|
-
visible: bool | None = True
|
|
34
|
-
custom_config: dict | None = None # Additional chart-specific config
|
|
35
|
-
created_at: datetime | None = None
|
|
36
|
-
updated_at: datetime | None = None
|
policyengine/models/user.py
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import uuid
|
|
2
|
-
from datetime import datetime
|
|
3
|
-
|
|
4
|
-
from pydantic import BaseModel, Field
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class User(BaseModel):
|
|
8
|
-
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
9
|
-
username: str
|
|
10
|
-
first_name: str | None = None
|
|
11
|
-
last_name: str | None = None
|
|
12
|
-
email: str | None = None
|
|
13
|
-
created_at: datetime | None = None
|
|
14
|
-
updated_at: datetime | None = None
|
policyengine/utils/charts.py
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
"""Chart formatting utilities for PolicyEngine."""
|
|
2
|
-
|
|
3
|
-
import plotly.graph_objects as go
|
|
4
|
-
from IPython.display import HTML
|
|
5
|
-
|
|
6
|
-
COLOUR_SCHEMES = {
|
|
7
|
-
"teal": {
|
|
8
|
-
"primary": "#319795",
|
|
9
|
-
"secondary": "#38B2AC",
|
|
10
|
-
"tertiary": "#4FD1C5",
|
|
11
|
-
"light": "#81E6D9",
|
|
12
|
-
"lighter": "#B2F5EA",
|
|
13
|
-
"lightest": "#E6FFFA",
|
|
14
|
-
"dark": "#2C7A7B",
|
|
15
|
-
"darker": "#285E61",
|
|
16
|
-
"darkest": "#234E52",
|
|
17
|
-
},
|
|
18
|
-
"blue": {
|
|
19
|
-
"primary": "#0EA5E9",
|
|
20
|
-
"secondary": "#0284C7",
|
|
21
|
-
"tertiary": "#38BDF8",
|
|
22
|
-
"light": "#7DD3FC",
|
|
23
|
-
"lighter": "#BAE6FD",
|
|
24
|
-
"lightest": "#E0F2FE",
|
|
25
|
-
"dark": "#026AA2",
|
|
26
|
-
"darker": "#075985",
|
|
27
|
-
"darkest": "#0C4A6E",
|
|
28
|
-
},
|
|
29
|
-
"gray": {
|
|
30
|
-
"primary": "#6B7280",
|
|
31
|
-
"secondary": "#9CA3AF",
|
|
32
|
-
"tertiary": "#D1D5DB",
|
|
33
|
-
"light": "#E2E8F0",
|
|
34
|
-
"lighter": "#F2F4F7",
|
|
35
|
-
"lightest": "#F9FAFB",
|
|
36
|
-
"dark": "#4B5563",
|
|
37
|
-
"darker": "#344054",
|
|
38
|
-
"darkest": "#101828",
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
DEFAULT_COLOURS = [
|
|
43
|
-
COLOUR_SCHEMES["teal"]["primary"],
|
|
44
|
-
COLOUR_SCHEMES["blue"]["primary"],
|
|
45
|
-
COLOUR_SCHEMES["teal"]["secondary"],
|
|
46
|
-
COLOUR_SCHEMES["blue"]["secondary"],
|
|
47
|
-
COLOUR_SCHEMES["teal"]["tertiary"],
|
|
48
|
-
COLOUR_SCHEMES["blue"]["tertiary"],
|
|
49
|
-
COLOUR_SCHEMES["gray"]["dark"],
|
|
50
|
-
COLOUR_SCHEMES["teal"]["dark"],
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def add_fonts() -> HTML:
|
|
55
|
-
"""Return HTML to add Google Fonts for Roboto and Roboto Mono."""
|
|
56
|
-
return HTML("""
|
|
57
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
58
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
59
|
-
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Roboto+Mono:wght@400;500&display=swap" rel="stylesheet">
|
|
60
|
-
""")
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def format_figure(
|
|
64
|
-
fig: go.Figure,
|
|
65
|
-
title: str | None = None,
|
|
66
|
-
x_title: str | None = None,
|
|
67
|
-
y_title: str | None = None,
|
|
68
|
-
colour_scheme: str = "teal",
|
|
69
|
-
show_grid: bool = True,
|
|
70
|
-
show_legend: bool = True,
|
|
71
|
-
height: int | None = None,
|
|
72
|
-
width: int | None = None,
|
|
73
|
-
) -> go.Figure:
|
|
74
|
-
"""Apply consistent formatting to a Plotly figure.
|
|
75
|
-
|
|
76
|
-
Args:
|
|
77
|
-
fig: The Plotly figure to format
|
|
78
|
-
title: Optional title for the chart
|
|
79
|
-
x_title: Optional x-axis title
|
|
80
|
-
y_title: Optional y-axis title
|
|
81
|
-
colour_scheme: Colour scheme name (teal, blue, gray)
|
|
82
|
-
show_grid: Whether to show gridlines
|
|
83
|
-
show_legend: Whether to show the legend
|
|
84
|
-
height: Optional figure height in pixels
|
|
85
|
-
width: Optional figure width in pixels
|
|
86
|
-
|
|
87
|
-
Returns:
|
|
88
|
-
The formatted figure
|
|
89
|
-
"""
|
|
90
|
-
|
|
91
|
-
colours = COLOUR_SCHEMES.get(colour_scheme, COLOUR_SCHEMES["teal"])
|
|
92
|
-
|
|
93
|
-
# Update traces with colour scheme
|
|
94
|
-
for i, trace in enumerate(fig.data):
|
|
95
|
-
if hasattr(trace, "marker"):
|
|
96
|
-
trace.marker.color = DEFAULT_COLOURS[i % len(DEFAULT_COLOURS)]
|
|
97
|
-
if hasattr(trace, "line"):
|
|
98
|
-
trace.line.color = DEFAULT_COLOURS[i % len(DEFAULT_COLOURS)]
|
|
99
|
-
trace.line.width = 2
|
|
100
|
-
|
|
101
|
-
# Base layout settings
|
|
102
|
-
layout_updates = {
|
|
103
|
-
"font": {
|
|
104
|
-
"family": "Roboto, sans-serif",
|
|
105
|
-
"size": 14,
|
|
106
|
-
"color": COLOUR_SCHEMES["gray"]["darkest"],
|
|
107
|
-
},
|
|
108
|
-
"plot_bgcolor": "white",
|
|
109
|
-
"paper_bgcolor": "white",
|
|
110
|
-
"showlegend": show_legend,
|
|
111
|
-
"hovermode": "x unified",
|
|
112
|
-
"hoverlabel": {
|
|
113
|
-
"bgcolor": "white",
|
|
114
|
-
"font": {"family": "Roboto Mono, monospace", "size": 12},
|
|
115
|
-
"bordercolor": colours["light"],
|
|
116
|
-
},
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
# Add title if provided
|
|
120
|
-
if title:
|
|
121
|
-
layout_updates["title"] = {
|
|
122
|
-
"text": title,
|
|
123
|
-
"font": {
|
|
124
|
-
"family": "Roboto, sans-serif",
|
|
125
|
-
"size": 20,
|
|
126
|
-
"color": COLOUR_SCHEMES["gray"]["darkest"],
|
|
127
|
-
"weight": 500,
|
|
128
|
-
},
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
# Configure axes
|
|
132
|
-
axis_config = {
|
|
133
|
-
"showgrid": show_grid,
|
|
134
|
-
"gridcolor": COLOUR_SCHEMES["gray"]["light"],
|
|
135
|
-
"gridwidth": 1,
|
|
136
|
-
"zeroline": True,
|
|
137
|
-
"zerolinecolor": COLOUR_SCHEMES["gray"]["lighter"],
|
|
138
|
-
"zerolinewidth": 1,
|
|
139
|
-
"tickfont": {
|
|
140
|
-
"family": "Roboto Mono, monospace",
|
|
141
|
-
"size": 11,
|
|
142
|
-
"color": COLOUR_SCHEMES["gray"]["primary"],
|
|
143
|
-
},
|
|
144
|
-
"titlefont": {
|
|
145
|
-
"family": "Roboto, sans-serif",
|
|
146
|
-
"size": 14,
|
|
147
|
-
"color": COLOUR_SCHEMES["gray"]["dark"],
|
|
148
|
-
},
|
|
149
|
-
"linecolor": COLOUR_SCHEMES["gray"]["light"],
|
|
150
|
-
"linewidth": 1,
|
|
151
|
-
"showline": True,
|
|
152
|
-
"mirror": False,
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
layout_updates["xaxis"] = axis_config.copy()
|
|
156
|
-
layout_updates["yaxis"] = axis_config.copy()
|
|
157
|
-
|
|
158
|
-
if x_title:
|
|
159
|
-
layout_updates["xaxis"]["title"] = x_title
|
|
160
|
-
if y_title:
|
|
161
|
-
layout_updates["yaxis"]["title"] = y_title
|
|
162
|
-
|
|
163
|
-
layout_updates["showlegend"] = len(fig.data) > 1 and show_legend
|
|
164
|
-
|
|
165
|
-
# Set dimensions if provided
|
|
166
|
-
if height:
|
|
167
|
-
layout_updates["height"] = height
|
|
168
|
-
if width:
|
|
169
|
-
layout_updates["width"] = width
|
|
170
|
-
|
|
171
|
-
fig.update_layout(**layout_updates)
|
|
172
|
-
|
|
173
|
-
fig.update_xaxes(title_font_color=COLOUR_SCHEMES["gray"]["primary"])
|
|
174
|
-
fig.update_yaxes(title_font_color=COLOUR_SCHEMES["gray"]["primary"])
|
|
175
|
-
|
|
176
|
-
# Add text annotations to bars in bar charts
|
|
177
|
-
if any(isinstance(trace, go.Bar) for trace in fig.data):
|
|
178
|
-
for trace in fig.data:
|
|
179
|
-
if isinstance(trace, go.Bar):
|
|
180
|
-
trace.texttemplate = "%{y:,.0f}"
|
|
181
|
-
trace.textposition = "outside"
|
|
182
|
-
trace.textfont = {
|
|
183
|
-
"family": "Roboto Mono, monospace",
|
|
184
|
-
"size": 11,
|
|
185
|
-
"color": COLOUR_SCHEMES["gray"]["primary"],
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return fig
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
def create_bar_chart(
|
|
192
|
-
data: dict[str, list],
|
|
193
|
-
x: str,
|
|
194
|
-
y: str,
|
|
195
|
-
title: str | None = None,
|
|
196
|
-
colour_scheme: str = "teal",
|
|
197
|
-
**kwargs,
|
|
198
|
-
) -> go.Figure:
|
|
199
|
-
"""Create a formatted bar chart.
|
|
200
|
-
|
|
201
|
-
Args:
|
|
202
|
-
data: Dictionary with data for the chart
|
|
203
|
-
x: Column name for x-axis
|
|
204
|
-
y: Column name for y-axis
|
|
205
|
-
title: Optional chart title
|
|
206
|
-
colour_scheme: Colour scheme to use
|
|
207
|
-
**kwargs: Additional arguments for format_figure
|
|
208
|
-
|
|
209
|
-
Returns:
|
|
210
|
-
Formatted bar chart figure
|
|
211
|
-
"""
|
|
212
|
-
fig = go.Figure(
|
|
213
|
-
data=[
|
|
214
|
-
go.Bar(
|
|
215
|
-
x=data[x],
|
|
216
|
-
y=data[y],
|
|
217
|
-
marker_color=COLOUR_SCHEMES[colour_scheme]["primary"],
|
|
218
|
-
marker_line_color=COLOUR_SCHEMES[colour_scheme]["dark"],
|
|
219
|
-
marker_line_width=1,
|
|
220
|
-
hovertemplate=f"{x}: "
|
|
221
|
-
+ "%{x}<br>"
|
|
222
|
-
+ f"{y}: "
|
|
223
|
-
+ "%{y:,.0f}<extra></extra>",
|
|
224
|
-
)
|
|
225
|
-
]
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
return format_figure(
|
|
229
|
-
fig,
|
|
230
|
-
title=title,
|
|
231
|
-
x_title=x,
|
|
232
|
-
y_title=y,
|
|
233
|
-
colour_scheme=colour_scheme,
|
|
234
|
-
**kwargs,
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
def create_line_chart(
|
|
239
|
-
data: dict[str, list],
|
|
240
|
-
x: str,
|
|
241
|
-
y: str | list[str],
|
|
242
|
-
title: str | None = None,
|
|
243
|
-
colour_scheme: str = "teal",
|
|
244
|
-
**kwargs,
|
|
245
|
-
) -> go.Figure:
|
|
246
|
-
"""Create a formatted line chart.
|
|
247
|
-
|
|
248
|
-
Args:
|
|
249
|
-
data: Dictionary with data for the chart
|
|
250
|
-
x: Column name for x-axis
|
|
251
|
-
y: Column name(s) for y-axis (can be a list for multiple lines)
|
|
252
|
-
title: Optional chart title
|
|
253
|
-
colour_scheme: Colour scheme to use
|
|
254
|
-
**kwargs: Additional arguments for format_figure
|
|
255
|
-
|
|
256
|
-
Returns:
|
|
257
|
-
Formatted line chart figure
|
|
258
|
-
"""
|
|
259
|
-
traces = []
|
|
260
|
-
y_columns = y if isinstance(y, list) else [y]
|
|
261
|
-
|
|
262
|
-
for i, y_col in enumerate(y_columns):
|
|
263
|
-
traces.append(
|
|
264
|
-
go.Scatter(
|
|
265
|
-
x=data[x],
|
|
266
|
-
y=data[y_col],
|
|
267
|
-
mode="lines+markers",
|
|
268
|
-
name=y_col,
|
|
269
|
-
line=dict(
|
|
270
|
-
color=DEFAULT_COLOURS[i % len(DEFAULT_COLOURS)], width=2
|
|
271
|
-
),
|
|
272
|
-
marker=dict(size=6),
|
|
273
|
-
hovertemplate=f"{y_col}: " + "%{y:,.0f}<extra></extra>",
|
|
274
|
-
)
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
fig = go.Figure(data=traces)
|
|
278
|
-
|
|
279
|
-
return format_figure(
|
|
280
|
-
fig,
|
|
281
|
-
title=title,
|
|
282
|
-
x_title=x,
|
|
283
|
-
y_title=y_columns[0] if len(y_columns) == 1 else None,
|
|
284
|
-
colour_scheme=colour_scheme,
|
|
285
|
-
**kwargs,
|
|
286
|
-
)
|
policyengine/utils/compress.py
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import pickle
|
|
2
|
-
from typing import Any
|
|
3
|
-
|
|
4
|
-
import blosc
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def compress_data(data: Any) -> bytes:
|
|
8
|
-
"""Compress data using blosc after pickling."""
|
|
9
|
-
pickled_data = pickle.dumps(data)
|
|
10
|
-
compressed_data = blosc.compress(
|
|
11
|
-
pickled_data, typesize=8, cname="zstd", clevel=9, shuffle=blosc.SHUFFLE
|
|
12
|
-
)
|
|
13
|
-
return compressed_data
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def decompress_data(compressed_data: bytes) -> Any:
|
|
17
|
-
"""Decompress data using blosc and then unpickle."""
|
|
18
|
-
decompressed_data = blosc.decompress(compressed_data)
|
|
19
|
-
data = pickle.loads(decompressed_data)
|
|
20
|
-
return data
|
policyengine/utils/datasets.py
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import pandas as pd
|
|
2
|
-
|
|
3
|
-
from policyengine.models import Dataset
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def create_uk_dataset(
|
|
7
|
-
dataset: str = "enhanced_frs_2023_24.h5",
|
|
8
|
-
year: int = 2029,
|
|
9
|
-
):
|
|
10
|
-
from policyengine_uk import Microsimulation
|
|
11
|
-
|
|
12
|
-
from policyengine.models.policyengine_uk import policyengine_uk_model
|
|
13
|
-
|
|
14
|
-
sim = Microsimulation(
|
|
15
|
-
dataset="hf://policyengine/policyengine-uk-data/" + dataset
|
|
16
|
-
)
|
|
17
|
-
sim.default_calculation_period = year
|
|
18
|
-
|
|
19
|
-
tables = {
|
|
20
|
-
"person": pd.DataFrame(sim.dataset[year].person),
|
|
21
|
-
"benunit": pd.DataFrame(sim.dataset[year].benunit),
|
|
22
|
-
"household": pd.DataFrame(sim.dataset[year].household),
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return Dataset(
|
|
26
|
-
id="uk",
|
|
27
|
-
name="UK",
|
|
28
|
-
description="A representative dataset for the UK, based on the Family Resources Survey.",
|
|
29
|
-
year=year,
|
|
30
|
-
model=policyengine_uk_model,
|
|
31
|
-
data=tables,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def create_us_dataset(
|
|
36
|
-
dataset: str = "enhanced_cps_2024.h5",
|
|
37
|
-
year: int = 2024,
|
|
38
|
-
):
|
|
39
|
-
from policyengine_us import Microsimulation
|
|
40
|
-
|
|
41
|
-
from policyengine.models.policyengine_us import policyengine_us_model
|
|
42
|
-
|
|
43
|
-
sim = Microsimulation(
|
|
44
|
-
dataset="hf://policyengine/policyengine-us-data/" + dataset
|
|
45
|
-
)
|
|
46
|
-
sim.default_calculation_period = year
|
|
47
|
-
|
|
48
|
-
known_variables = sim.input_variables
|
|
49
|
-
|
|
50
|
-
tables = {
|
|
51
|
-
"person": pd.DataFrame(),
|
|
52
|
-
"marital_unit": pd.DataFrame(),
|
|
53
|
-
"tax_unit": pd.DataFrame(),
|
|
54
|
-
"spm_unit": pd.DataFrame(),
|
|
55
|
-
"family": pd.DataFrame(),
|
|
56
|
-
"household": pd.DataFrame(),
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
for variable in known_variables:
|
|
60
|
-
entity = sim.tax_benefit_system.variables[variable].entity.key
|
|
61
|
-
if variable in sim.tax_benefit_system.variables:
|
|
62
|
-
tables[entity][variable] = sim.calculate(variable)
|
|
63
|
-
|
|
64
|
-
return Dataset(
|
|
65
|
-
id="us",
|
|
66
|
-
name="US",
|
|
67
|
-
description="A representative dataset for the US, based on the Current Population Survey.",
|
|
68
|
-
year=year,
|
|
69
|
-
model=policyengine_us_model,
|
|
70
|
-
data=tables,
|
|
71
|
-
)
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
policyengine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
policyengine/__pycache__/__init__.cpython-313.pyc,sha256=clYnHZ_Xv6c59J6BFYQDwmN-_Lo22ATcTO_WNkrUwoY,175
|
|
3
|
-
policyengine/database/__init__.py,sha256=-Xl7G0dfYoAVZwPyhpUsEd8XNAzIbbUIv8wM7h5Mpmo,1641
|
|
4
|
-
policyengine/database/aggregate.py,sha256=4r3C8avxhCb8NJBHViA2kgWL82cqR55voJIqJNh4SbI,911
|
|
5
|
-
policyengine/database/baseline_parameter_value_table.py,sha256=9R3W5ZMhNkgDfUPpkBFE587KBGu3gDFfdr16k-6dDZA,2107
|
|
6
|
-
policyengine/database/baseline_variable_table.py,sha256=AdpKhkrC1lhakT1bu5JYtwvMm6aUS2EP33cX3LvsPhk,1385
|
|
7
|
-
policyengine/database/database.py,sha256=EIeyubFp-pY-bG1IRz9LxlpiUARrN9Hw4fNHk1-Az7w,9168
|
|
8
|
-
policyengine/database/dataset_table.py,sha256=L1I6HUHfc8JHLhY-Ew4OrLkWs2kQwJFlwGqstfzK4pE,1297
|
|
9
|
-
policyengine/database/dynamic_table.py,sha256=6RH8mP1NnFJzs1wB5qYbRQDsk6ZoMKh8pzgaxUnpZ1k,1045
|
|
10
|
-
policyengine/database/link.py,sha256=RuxH9fLNreHns3k3SLIGhnZXMXzz7x2Y0yWPN0Qo0Sg,2941
|
|
11
|
-
policyengine/database/model_table.py,sha256=YRV7DNxXAJ4go1i1hcEV8TE1I8-WRwcpS5-hokn-uhE,742
|
|
12
|
-
policyengine/database/model_version_table.py,sha256=yf2WtCA7kWCd0yOs_ZNXjivPJvUG3QtLf_9CCaLu85U,811
|
|
13
|
-
policyengine/database/parameter_table.py,sha256=Ch-pMOPTcUpKyhd9eIWVEr2pLJxMTP9mcvCe8cPaAP8,980
|
|
14
|
-
policyengine/database/parameter_value_table.py,sha256=Qg3edb44qTNw9iJjg9gXXAPPWQDE3ER5GUtkAI-dwvg,1891
|
|
15
|
-
policyengine/database/policy_table.py,sha256=G-RdGh3zWGIVqGYfnQHXNL0ICxYIe21ITY_EhWKIzYU,1040
|
|
16
|
-
policyengine/database/report_element_table.py,sha256=Cdo-056O9yZJhHfXUu59Z0K5KZqAbEMKvygEDRIkpg0,1516
|
|
17
|
-
policyengine/database/report_table.py,sha256=KqMTkYs_hNyb3FZsIjHDu6rX742qNZi33qZOBGhDaf8,536
|
|
18
|
-
policyengine/database/simulation_table.py,sha256=d8F9Tp8EGv6Mb6sba4UomrCaVilRRs_bl7pl808Gn4k,1697
|
|
19
|
-
policyengine/database/user_table.py,sha256=y2kRjLr4t04mnyI3EEHVsuinYWUZsOdY8vECSUCUDaI,745
|
|
20
|
-
policyengine/database/versioned_dataset_table.py,sha256=WUU7Ed651JLkv3GJmEInbFJChIEaaRIdddKzYFgcRu8,770
|
|
21
|
-
policyengine/models/__init__.py,sha256=ue_8jZnnZZwrEet5kxX3MFIJXyb2qhYQ6pDUJlNonfM,1199
|
|
22
|
-
policyengine/models/aggregate.py,sha256=0RgvJl9UFKNha8t_FuJR34L2Du6VY-Wm0cwCRyIns4E,3135
|
|
23
|
-
policyengine/models/baseline_parameter_value.py,sha256=np7ysyuccqv6oR1PM0cJkozx1cTyw25m6gm3tz9_dfQ,355
|
|
24
|
-
policyengine/models/baseline_variable.py,sha256=hFMTmJngSwm0b3ZC941JWdLZjQpZnuHx79jgFVxYuJg,267
|
|
25
|
-
policyengine/models/dataset.py,sha256=VMPabDHPTm1XlEUKZn8IaK6iMOee_arcfXOm2bXFx_Y,466
|
|
26
|
-
policyengine/models/dynamic.py,sha256=PZvJqXPG-Zpk2LS2TRiZuR0o_mZwm9cz81mbrC7U1P0,475
|
|
27
|
-
policyengine/models/model.py,sha256=puNMRHnPR2GriwU1yqQn2UuASJsOI5YmM8xRYdxVuPc,4554
|
|
28
|
-
policyengine/models/model_version.py,sha256=j9wUCuGSvae2cVkkozUMzKMoqdWIqpSvij4J6NlgObo,341
|
|
29
|
-
policyengine/models/parameter.py,sha256=eOpHXi2aXh8Eqpt0WWmFvWvI5HCEa4PrTcn-W03vpK0,276
|
|
30
|
-
policyengine/models/parameter_value.py,sha256=oFxMwUpb8zU0U4V6HtI7XUXfxbdG1FPDIzaeNpCxjg0,363
|
|
31
|
-
policyengine/models/policy.py,sha256=FjpBR1Dr_9S_3kpQb8Q6qKdcrfRheh1F2h3wLBKgw5g,530
|
|
32
|
-
policyengine/models/policyengine_uk.py,sha256=aKbr-TSXL0GSrpFAZs9r7JAFrpKlgZruSh_C0VybR5M,4028
|
|
33
|
-
policyengine/models/policyengine_us.py,sha256=wOjtdSmEZ4CKSkfFz4N81QOHd9r2_IGDHrjVbheV-vY,3761
|
|
34
|
-
policyengine/models/report.py,sha256=g1iykmUMcgeuX1IECb9kU1GETbxtAg3KRSodM4t2Zco,225
|
|
35
|
-
policyengine/models/report_element.py,sha256=rbGxh4FR25frTMOijbYsPW_wljQQp5opfJYv14hnh4U,1193
|
|
36
|
-
policyengine/models/simulation.py,sha256=sZIZtojah9cPkLSEBclJFZFh-_ICIgeYM-WA3sQ7UtA,903
|
|
37
|
-
policyengine/models/user.py,sha256=oKkYLBt7GiTaA5Nh_O6CyYoC-E9sS3ACzCOGMJF3xnk,361
|
|
38
|
-
policyengine/models/versioned_dataset.py,sha256=TYBYEKghMNQWvrn7SdsW2rl47ZZoleoWHP2gTxGqpNE,249
|
|
39
|
-
policyengine/utils/charts.py,sha256=8wfJmHBbVhpx80sTUpMsigdKFoQuEjQhiUkz_6jDBwo,8201
|
|
40
|
-
policyengine/utils/compress.py,sha256=6J2LE8EedPQsK4TnhoPRFe4kO8AmRIs04fdsllsszzk,561
|
|
41
|
-
policyengine/utils/datasets.py,sha256=EXyJ-4pfkd70fSVaQH2eHa3BQYIC1o3gCQzlcXdz_d8,1977
|
|
42
|
-
policyengine-3.0.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
43
|
-
policyengine-3.0.0.dist-info/METADATA,sha256=viH80P24ygDMLfWIMiMDjdg_jmBPxME9wycA23qNxdw,41860
|
|
44
|
-
policyengine-3.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
45
|
-
policyengine-3.0.0.dist-info/entry_points.txt,sha256=pg1qc3ESZ9CE7kHUQpJtLDLJeWvvdNERRF5W7zrMmgM,67
|
|
46
|
-
policyengine-3.0.0.dist-info/top_level.txt,sha256=_23UPobfkneHQkpJ0e0OmDJfhCUfoXj_F2sTckCGOH4,13
|
|
47
|
-
policyengine-3.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|