Skip to content

Commit 4bc3669

Browse files
authored
Merge pull request #2639 from PolicyEngine/PavelMakarchuk/issue2637
Embed OBBBA Household Explorer
2 parents 299ea2e + 46df88d commit 4bc3669

4 files changed

Lines changed: 85 additions & 29 deletions

File tree

src/PolicyEngine.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import DeveloperHome from "./pages/DeveloperHome";
5050
import CTCComparison from "./applets/CTCComparison";
5151
import CTCCalculator from "./applets/CTCCalculator";
5252
import GiveCalc from "./applets/GiveCalc";
53+
import OBBBAHouseholdExplorer from "./applets/OBBBAHouseholdExplorer";
5354
import { wrappedResponseJson } from "./data/wrappedJson";
5455
import US2024ElectionCalculator from "./applets/US2024ElectionCalculator";
5556
import SALTernative from "./applets/SALTernative";
@@ -401,6 +402,10 @@ export default function PolicyEngine() {
401402
element={<CTCCalculator />}
402403
/>
403404
<Route path="/us/givecalc" element={<GiveCalc />} />
405+
<Route
406+
path="/us/obbba-household-explorer"
407+
element={<OBBBAHouseholdExplorer />}
408+
/>
404409
<Route
405410
path="/us/2024-election-calculator"
406411
element={<US2024ElectionCalculator />}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import Header from "../layout/Header";
2+
import { Helmet } from "react-helmet";
3+
import style from "../style";
4+
import { useWindowHeight } from "../hooks/useWindow";
5+
6+
export default function OBBBAHouseholdExplorer() {
7+
const windowHeight = useWindowHeight();
8+
9+
return (
10+
<>
11+
<Helmet>
12+
<title>OBBBA Household Explorer | PolicyEngine</title>
13+
</Helmet>
14+
<Header />
15+
<div
16+
style={{
17+
display: "flex",
18+
justifyContent: "center",
19+
height: windowHeight - style.spacing.HEADER_HEIGHT,
20+
width: "100%",
21+
}}
22+
>
23+
<iframe
24+
src={
25+
process.env.REACT_APP_OBBBA_IFRAME_URL ||
26+
"https://obbba-household-explorer.streamlit.app?embedded=true"
27+
}
28+
title="OBBBA Household Explorer"
29+
height={`calc(100vh - ${style.spacing.HEADER_HEIGHT})`}
30+
width="100%"
31+
style={{ overflow: "hidden" }}
32+
/>
33+
</div>
34+
</>
35+
);
36+
}

src/posts/articles/farage-speech-may-2025.ipynb

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
" \"gov.hmrc.income_tax.rates.uk[1].threshold\": 50_000,\n",
110110
" \"gov.hmrc.income_tax.allowances.marriage_allowance.max\": 0.25,\n",
111111
" \"gov.dwp.universal_credit.elements.child.limit.child_count\": 90,\n",
112-
" }\n",
112+
" },\n",
113113
")"
114114
]
115115
},
@@ -163,7 +163,7 @@
163163
"fig = px.bar(\n",
164164
" y=result.decile.relative,\n",
165165
" text=[f\"{x:.1%}\" for x in result.decile.relative.values()],\n",
166-
" color_discrete_sequence=[BLUE]\n",
166+
" color_discrete_sequence=[BLUE],\n",
167167
").update_layout(\n",
168168
" title=\"Impact of Reform UK tax-benefit policies by income decile\",\n",
169169
" xaxis_title=\"Income decile\",\n",
@@ -172,8 +172,7 @@
172172
" yaxis_tickformat=\".0%\",\n",
173173
")\n",
174174
"\n",
175-
"print(format_fig(fig).update_layout(\n",
176-
").to_json())"
175+
"print(format_fig(fig).update_layout().to_json())"
177176
]
178177
},
179178
{
@@ -323,11 +322,14 @@
323322
" print(reform, policy_reform_names[i])\n",
324323
"\n",
325324
" for year in tqdm(range(2025, 2030)):\n",
326-
" debt_impact = sim.reform_simulation.calculate(\"gov_balance\", year).sum()/1e9 - sim.baseline_simulation.calculate(\"gov_balance\", year).sum()/1e9\n",
325+
" debt_impact = (\n",
326+
" sim.reform_simulation.calculate(\"gov_balance\", year).sum() / 1e9\n",
327+
" - sim.baseline_simulation.calculate(\"gov_balance\", year).sum()\n",
328+
" / 1e9\n",
329+
" )\n",
327330
" years.append(year)\n",
328331
" debt_impacts.append(debt_impact)\n",
329-
" policies.append(policy_reform_names[i])\n",
330-
"\n"
332+
" policies.append(policy_reform_names[i])"
331333
]
332334
},
333335
{
@@ -339,13 +341,17 @@
339341
"source": [
340342
"import pandas as pd\n",
341343
"\n",
342-
"df = pd.DataFrame({\n",
343-
" \"Year\": years,\n",
344-
" \"Debt impact (£ billions)\": debt_impacts,\n",
345-
" \"Policy\": policies,\n",
346-
"})\n",
344+
"df = pd.DataFrame(\n",
345+
" {\n",
346+
" \"Year\": years,\n",
347+
" \"Debt impact (£ billions)\": debt_impacts,\n",
348+
" \"Policy\": policies,\n",
349+
" }\n",
350+
")\n",
347351
"\n",
348-
"df = df.pivot(columns=\"Year\", index=\"Policy\", values=\"Debt impact (£ billions)\")\n",
352+
"df = df.pivot(\n",
353+
" columns=\"Year\", index=\"Policy\", values=\"Debt impact (£ billions)\"\n",
354+
")\n",
349355
"df = df.iloc[[2, 1, 3, 0]]"
350356
]
351357
},

src/posts/articles/wfa-means-test.ipynb

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
" \"2027\": False,\n",
111111
" \"2028\": False,\n",
112112
" \"2029\": False,\n",
113-
" }\n",
113+
" },\n",
114114
"}\n",
115115
"\n",
116116
"NEW_MEANS_TESTED = {\n",
@@ -127,7 +127,7 @@
127127
" \"2027\": True,\n",
128128
" \"2028\": True,\n",
129129
" \"2029\": True,\n",
130-
" }\n",
130+
" },\n",
131131
"}\n",
132132
"\n",
133133
"sim = Simulation(\n",
@@ -182,21 +182,31 @@
182182
" \"age\": 70,\n",
183183
" }\n",
184184
" },\n",
185-
" \"axes\": [[{\n",
186-
" \"name\": \"private_pension_income\",\n",
187-
" \"min\": 0,\n",
188-
" \"max\": 100_000,\n",
189-
" \"count\": 101,\n",
190-
" }]]\n",
191-
" }\n",
185+
" \"axes\": [\n",
186+
" [\n",
187+
" {\n",
188+
" \"name\": \"private_pension_income\",\n",
189+
" \"min\": 0,\n",
190+
" \"max\": 100_000,\n",
191+
" \"count\": 101,\n",
192+
" }\n",
193+
" ]\n",
194+
" ],\n",
195+
" },\n",
192196
")\n",
193197
"\n",
194198
"import plotly.express as px\n",
195199
"\n",
196200
"df = pd.DataFrame()\n",
197-
"df[\"Reform\"] = household.reform_simulation.calculate(\"winter_fuel_allowance\", 2025)\n",
198-
"df[\"Baseline\"] = household.baseline_simulation.calculate(\"winter_fuel_allowance\", 2025)\n",
199-
"df[\"Income\"] = household.baseline_simulation.calculate(\"private_pension_income\", 2025)\n",
201+
"df[\"Reform\"] = household.reform_simulation.calculate(\n",
202+
" \"winter_fuel_allowance\", 2025\n",
203+
")\n",
204+
"df[\"Baseline\"] = household.baseline_simulation.calculate(\n",
205+
" \"winter_fuel_allowance\", 2025\n",
206+
")\n",
207+
"df[\"Income\"] = household.baseline_simulation.calculate(\n",
208+
" \"private_pension_income\", 2025\n",
209+
")\n",
200210
"\n",
201211
"from policyengine.utils.charts import *\n",
202212
"\n",
@@ -205,7 +215,7 @@
205215
" df,\n",
206216
" x=\"Income\",\n",
207217
" y=[\"Reform\", \"Baseline\"],\n",
208-
" color_discrete_sequence=[BLUE, GRAY]\n",
218+
" color_discrete_sequence=[BLUE, GRAY],\n",
209219
").update_layout(\n",
210220
" title=\"Winter Fuel Allowance by taxable income for a 70-year-old\",\n",
211221
" yaxis_title=\"Winter Fuel Allowance\",\n",
@@ -299,10 +309,10 @@
299309
}
300310
],
301311
"source": [
302-
"\n",
303312
"def add_thousands_separator(x):\n",
304313
" return \"{:,}\".format(x)\n",
305314
"\n",
315+
"\n",
306316
"def get_rate_table(absolute, bhc, i):\n",
307317
" years = []\n",
308318
" poverty_rates_autumn = []\n",
@@ -569,8 +579,7 @@
569579
" )\n",
570580
"\n",
571581
"\n",
572-
"get_inequality_table(\"Gini coefficient\", i=6)\n",
573-
"\n"
582+
"get_inequality_table(\"Gini coefficient\", i=6)"
574583
]
575584
},
576585
{

0 commit comments

Comments
 (0)