-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46f67b6
commit 43f2b65
Showing
5 changed files
with
148 additions
and
137 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Schema\n", | ||
"\n", | ||
"This page contains examples of the schema of the returned simulation outputs for given types of simulation. Each subsection specifies the country, scope and whether a reform has been passed. The schema is given in YAML format.\n", | ||
"\n", | ||
"## UK, macro, reform-comparison" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"tags": [ | ||
"hide-input" | ||
] | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"```yaml\n", | ||
"macro:\n", | ||
" baseline:\n", | ||
" gov:\n", | ||
" balance:\n", | ||
" total_gov_spending: <class 'numpy.float64'>\n", | ||
" total_state_tax: <class 'int'>\n", | ||
" total_tax_revenue: <class 'numpy.float64'>\n", | ||
" programs:\n", | ||
" child_benefit: <class 'numpy.float64'>\n", | ||
" council_tax: <class 'numpy.float64'>\n", | ||
" fuel_duty: <class 'numpy.float64'>\n", | ||
" income_tax: <class 'numpy.float64'>\n", | ||
" national_insurance: <class 'numpy.float64'>\n", | ||
" ni_employer: <class 'numpy.float64'>\n", | ||
" pension_credit: <class 'numpy.float64'>\n", | ||
" state_pension: <class 'numpy.float64'>\n", | ||
" tax_credits: <class 'numpy.float64'>\n", | ||
" universal_credit: <class 'numpy.float64'>\n", | ||
" vat: <class 'numpy.float64'>\n", | ||
" household:\n", | ||
" demographic_values:\n", | ||
" household_count_people: <class 'list'>\n", | ||
" household_weight: <class 'list'>\n", | ||
" person_weight: <class 'list'>\n", | ||
" comparison:\n", | ||
" revenue_impact:\n", | ||
" tax_revenues: <class 'numpy.float64'>\n", | ||
" reform:\n", | ||
" gov:\n", | ||
" balance:\n", | ||
" total_gov_spending: <class 'numpy.float64'>\n", | ||
" total_state_tax: <class 'int'>\n", | ||
" total_tax_revenue: <class 'numpy.float64'>\n", | ||
" programs:\n", | ||
" child_benefit: <class 'numpy.float64'>\n", | ||
" council_tax: <class 'numpy.float64'>\n", | ||
" fuel_duty: <class 'numpy.float64'>\n", | ||
" income_tax: <class 'numpy.float64'>\n", | ||
" national_insurance: <class 'numpy.float64'>\n", | ||
" ni_employer: <class 'numpy.float64'>\n", | ||
" pension_credit: <class 'numpy.float64'>\n", | ||
" state_pension: <class 'numpy.float64'>\n", | ||
" tax_credits: <class 'numpy.float64'>\n", | ||
" universal_credit: <class 'numpy.float64'>\n", | ||
" vat: <class 'numpy.float64'>\n", | ||
" household:\n", | ||
" demographic_values:\n", | ||
" household_count_people: <class 'list'>\n", | ||
" household_weight: <class 'list'>\n", | ||
" person_weight: <class 'list'>\n", | ||
"\n", | ||
"```" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from policyengine import Simulation\n", | ||
"from IPython.display import Markdown\n", | ||
"import yaml\n", | ||
"\n", | ||
"def replace_value_with_dtype(tree):\n", | ||
" for key in tree:\n", | ||
" if isinstance(tree[key], dict):\n", | ||
" replace_value_with_dtype(tree[key])\n", | ||
" else:\n", | ||
" tree[key] = str(type(tree[key]))\n", | ||
" return tree\n", | ||
"\n", | ||
"sim = Simulation(\n", | ||
" country=\"uk\",\n", | ||
" scope=\"macro\",\n", | ||
" time_period=2025,\n", | ||
" reform={\n", | ||
" \"gov.hmrc.income_tax.allowances.personal_allowance.amount\": {\n", | ||
" \"2025\": 0,\n", | ||
" }\n", | ||
" }\n", | ||
")\n", | ||
"sim.calculate(\"macro\")\n", | ||
"tree = replace_value_with_dtype(sim.outputs)\n", | ||
"\n", | ||
"Markdown('```yaml\\n' + yaml.dump(tree, indent=2) + '\\n```')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "base", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.14" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.