From 0810d9bf2bef21c80daec5df5094b13b95394e80 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 25 Nov 2024 08:20:54 +0000 Subject: [PATCH 1/6] Fix bug in simulation.py --- policyengine/simulation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/policyengine/simulation.py b/policyengine/simulation.py index 0832b90..cddbb74 100644 --- a/policyengine/simulation.py +++ b/policyengine/simulation.py @@ -76,6 +76,9 @@ def calculate(self, output: str): node = self.outputs + for child_key in output.split("/")[:-1]: + node = node[child_key] + parent = node child_key = output.split("/")[-1] node = parent[child_key] From 7d256beb0ab66c4a066d24dc30145e5a80e807b5 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 25 Nov 2024 08:21:00 +0000 Subject: [PATCH 2/6] Format --- .github/workflows/push.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 45f696c..a110b40 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -21,8 +21,6 @@ jobs: pip install furo pip install sphinx-argparse - - - name: Generate documentation run: make documentation From 1207fdaadeaf315596af5c53878a3e4e766397e8 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 25 Nov 2024 08:32:49 +0000 Subject: [PATCH 3/6] Add some impacts from the API --- .../macro/comparison/revenue_impact.py | 8 +++-- .../outputs/macro/single/gov/balance.py | 20 +++++++++++ .../outputs/macro/single/gov/programs.py | 35 +++++++++++++++++++ .../single/household/demographic_values.py | 15 ++++++++ .../outputs/macro/single/tax_revenue.py | 2 -- 5 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 policyengine/outputs/macro/single/gov/balance.py create mode 100644 policyengine/outputs/macro/single/gov/programs.py create mode 100644 policyengine/outputs/macro/single/household/demographic_values.py delete mode 100644 policyengine/outputs/macro/single/tax_revenue.py diff --git a/policyengine/outputs/macro/comparison/revenue_impact.py b/policyengine/outputs/macro/comparison/revenue_impact.py index e7276ca..08ab0b9 100644 --- a/policyengine/outputs/macro/comparison/revenue_impact.py +++ b/policyengine/outputs/macro/comparison/revenue_impact.py @@ -10,6 +10,10 @@ def revenue_impact(simulation: Simulation): Returns: float: The revenue impact of the simulation. """ - tax_revenue_baseline = simulation.calculate("macro/baseline/tax_revenue") - tax_revenue_reform = simulation.calculate("macro/reform/tax_revenue") + tax_revenue_baseline = simulation.calculate( + "macro/baseline/gov/balance/total_tax_revenue" + ) + tax_revenue_reform = simulation.calculate( + "macro/reform/gov/balance/total_tax_revenue" + ) return tax_revenue_reform - tax_revenue_baseline diff --git a/policyengine/outputs/macro/single/gov/balance.py b/policyengine/outputs/macro/single/gov/balance.py new file mode 100644 index 0000000..ceb66b6 --- /dev/null +++ b/policyengine/outputs/macro/single/gov/balance.py @@ -0,0 +1,20 @@ +from policyengine import Simulation + + +def balance(simulation: Simulation) -> dict: + sim = simulation.baseline + if simulation.country == "uk": + total_tax = sim.calculate("gov_tax").sum() + total_spending = sim.calculate("gov_spending").sum() + total_state_tax = 0 + elif simulation.country == "us": + total_tax = sim.calculate("household_tax").sum() + total_spending = sim.calculate("household_benefits").sum() + total_state_tax = simulation.calculate( + "household_state_income_tax" + ).sum() + return { + "total_tax_revenue": total_tax, + "total_gov_spending": total_spending, + "total_state_tax": total_state_tax, + } diff --git a/policyengine/outputs/macro/single/gov/programs.py b/policyengine/outputs/macro/single/gov/programs.py new file mode 100644 index 0000000..c261440 --- /dev/null +++ b/policyengine/outputs/macro/single/gov/programs.py @@ -0,0 +1,35 @@ +from policyengine import Simulation +from dataclasses import dataclass + + +@dataclass +class UKProgram: + name: str + is_positive: bool + + +class UKPrograms: + PROGRAMS = [ + UKProgram("income_tax", True), + UKProgram("national_insurance", True), + UKProgram("vat", True), + UKProgram("council_tax", True), + UKProgram("fuel_duty", True), + UKProgram("tax_credits", False), + UKProgram("universal_credit", False), + UKProgram("child_benefit", False), + UKProgram("state_pension", False), + UKProgram("pension_credit", False), + UKProgram("ni_employer", True), + ] + + +def programs(simulation: Simulation) -> dict: + if simulation.country == "uk": + return { + program.name: simulation.baseline.calculate( + program.name, map_to="household" + ).sum() + * (1 if program.is_positive else -1) + for program in UKPrograms.PROGRAMS + } diff --git a/policyengine/outputs/macro/single/household/demographic_values.py b/policyengine/outputs/macro/single/household/demographic_values.py new file mode 100644 index 0000000..e0ea72d --- /dev/null +++ b/policyengine/outputs/macro/single/household/demographic_values.py @@ -0,0 +1,15 @@ +from policyengine import Simulation + + +def demographic_values(simulation: Simulation) -> dict: + sim = simulation.baseline + household_count_people = ( + sim.calculate("household_count_people").astype(int).tolist() + ) + person_weight = sim.calculate("person_weight").astype(float).tolist() + household_weight = sim.calculate("household_weight").astype(float).tolist() + return { + "household_count_people": household_count_people, + "person_weight": person_weight, + "household_weight": household_weight, + } diff --git a/policyengine/outputs/macro/single/tax_revenue.py b/policyengine/outputs/macro/single/tax_revenue.py deleted file mode 100644 index 3a2f70d..0000000 --- a/policyengine/outputs/macro/single/tax_revenue.py +++ /dev/null @@ -1,2 +0,0 @@ -def tax_revenue(simulation): - return simulation.baseline.calculate("gov_tax").sum() / 1e9 From 46f67b60f166647a284d29f06b8429384c89f517 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 25 Nov 2024 08:47:26 +0000 Subject: [PATCH 4/6] Fix bugs --- api_docs.ipynb | 60 +++++++++++++++++++ .../macro/comparison/revenue_impact.py | 8 +-- policyengine/simulation.py | 3 + test.ipynb | 40 ++++--------- 4 files changed, 80 insertions(+), 31 deletions(-) create mode 100644 api_docs.ipynb diff --git a/api_docs.ipynb b/api_docs.ipynb new file mode 100644 index 0000000..790de15 --- /dev/null +++ b/api_docs.ipynb @@ -0,0 +1,60 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from policyengine import Simulation" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "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\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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 +} diff --git a/policyengine/outputs/macro/comparison/revenue_impact.py b/policyengine/outputs/macro/comparison/revenue_impact.py index 08ab0b9..4403c3a 100644 --- a/policyengine/outputs/macro/comparison/revenue_impact.py +++ b/policyengine/outputs/macro/comparison/revenue_impact.py @@ -11,9 +11,9 @@ def revenue_impact(simulation: Simulation): float: The revenue impact of the simulation. """ tax_revenue_baseline = simulation.calculate( - "macro/baseline/gov/balance/total_tax_revenue" - ) + "macro/baseline/gov/balance" + )["total_tax_revenue"] tax_revenue_reform = simulation.calculate( - "macro/reform/gov/balance/total_tax_revenue" - ) + "macro/reform/gov/balance" + )["total_tax_revenue"] return tax_revenue_reform - tax_revenue_baseline diff --git a/policyengine/simulation.py b/policyengine/simulation.py index cddbb74..18a34a9 100644 --- a/policyengine/simulation.py +++ b/policyengine/simulation.py @@ -73,6 +73,9 @@ def calculate(self, output: str): """ if output.endswith("/"): output = output[:-1] + + if output == "": + output = list(self.outputs.keys())[0] node = self.outputs diff --git a/test.ipynb b/test.ipynb index 798dba0..b82cee8 100644 --- a/test.ipynb +++ b/test.ipynb @@ -17,10 +17,7 @@ "source": [ "sim = Simulation(\n", " country=\"uk\",\n", - " scope=\"household\",\n", - " data={\n", - " \"employment_income\": 30_000\n", - " },\n", + " scope=\"macro\",\n", " time_period=2025,\n", " reform={\n", " \"gov.hmrc.income_tax.allowances.personal_allowance.amount\": {\n", @@ -32,36 +29,25 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "Calculating net_income_change...\n", - "Calculating net_income...\n", - "Stored result in household/baseline/net_income\n", - "Calculating net_income...\n", - "Stored result in household/reform/net_income\n", - "Stored result in household/comparison/net_income_change\n" + "ename": "KeyError", + "evalue": "'comparison'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/var/folders/r_/j9kk4vmd3tj29ljn52_76m4h0000gn/T/ipykernel_62469/2089930413.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcalculate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"macro\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/policyengine/policyengine.py/policyengine/simulation.py\u001b[0m in \u001b[0;36mcalculate\u001b[0;34m(self, output)\u001b[0m\n\u001b[1;32m 89\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 90\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mchild_key\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mnode\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkeys\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 91\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcalculate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0moutput\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"/\"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mchild_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 92\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 93\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mnode\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/policyengine/policyengine.py/policyengine/simulation.py\u001b[0m in \u001b[0;36mcalculate\u001b[0;34m(self, output)\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[0mparent\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnode\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[0mchild_key\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0moutput\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msplit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"/\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 81\u001b[0;31m \u001b[0mnode\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparent\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mchild_key\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 82\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[0;31m# Check if any descendants are None\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 'comparison'" ] - }, - { - "data": { - "text/plain": [ - "{'comparison': {'net_income_change': -2514.0},\n", - " 'baseline': {'net_income': 28298.0},\n", - " 'reform': {'net_income': 25784.0}}" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ - "sim.calculate(\"household\")" + "sim.calculate(\"macro\")" ] } ], From 43f2b65d00d0ae3133d1f0c9faeecf22f1c25f40 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 25 Nov 2024 09:43:33 +0000 Subject: [PATCH 5/6] Add schema --- api_docs.ipynb | 60 -------- docs/_toc.yml | 5 +- docs/schema.ipynb | 140 ++++++++++++++++++ .../macro/comparison/revenue_impact.py | 5 +- test.ipynb | 75 ---------- 5 files changed, 148 insertions(+), 137 deletions(-) delete mode 100644 api_docs.ipynb create mode 100644 docs/schema.ipynb delete mode 100644 test.ipynb diff --git a/api_docs.ipynb b/api_docs.ipynb deleted file mode 100644 index 790de15..0000000 --- a/api_docs.ipynb +++ /dev/null @@ -1,60 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from policyengine import Simulation" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "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\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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 -} diff --git a/docs/_toc.yml b/docs/_toc.yml index b2699f2..51cd2ae 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -3,4 +3,7 @@ root: index parts: - caption: Maintenance chapters: - - file: maintaining \ No newline at end of file + - file: maintaining + - caption: Schema + chapters: + - file: schema \ No newline at end of file diff --git a/docs/schema.ipynb b/docs/schema.ipynb new file mode 100644 index 0000000..89ed21b --- /dev/null +++ b/docs/schema.ipynb @@ -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: \n", + " total_state_tax: \n", + " total_tax_revenue: \n", + " programs:\n", + " child_benefit: \n", + " council_tax: \n", + " fuel_duty: \n", + " income_tax: \n", + " national_insurance: \n", + " ni_employer: \n", + " pension_credit: \n", + " state_pension: \n", + " tax_credits: \n", + " universal_credit: \n", + " vat: \n", + " household:\n", + " demographic_values:\n", + " household_count_people: \n", + " household_weight: \n", + " person_weight: \n", + " comparison:\n", + " revenue_impact:\n", + " tax_revenues: \n", + " reform:\n", + " gov:\n", + " balance:\n", + " total_gov_spending: \n", + " total_state_tax: \n", + " total_tax_revenue: \n", + " programs:\n", + " child_benefit: \n", + " council_tax: \n", + " fuel_duty: \n", + " income_tax: \n", + " national_insurance: \n", + " ni_employer: \n", + " pension_credit: \n", + " state_pension: \n", + " tax_credits: \n", + " universal_credit: \n", + " vat: \n", + " household:\n", + " demographic_values:\n", + " household_count_people: \n", + " household_weight: \n", + " person_weight: \n", + "\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "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 +} diff --git a/policyengine/outputs/macro/comparison/revenue_impact.py b/policyengine/outputs/macro/comparison/revenue_impact.py index 4403c3a..9cce7be 100644 --- a/policyengine/outputs/macro/comparison/revenue_impact.py +++ b/policyengine/outputs/macro/comparison/revenue_impact.py @@ -16,4 +16,7 @@ def revenue_impact(simulation: Simulation): tax_revenue_reform = simulation.calculate( "macro/reform/gov/balance" )["total_tax_revenue"] - return tax_revenue_reform - tax_revenue_baseline + tax_revenue_impact = tax_revenue_reform - tax_revenue_baseline + return { + "tax_revenues": tax_revenue_impact, + } diff --git a/test.ipynb b/test.ipynb deleted file mode 100644 index b82cee8..0000000 --- a/test.ipynb +++ /dev/null @@ -1,75 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from policyengine import Simulation" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "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", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "ename": "KeyError", - "evalue": "'comparison'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/var/folders/r_/j9kk4vmd3tj29ljn52_76m4h0000gn/T/ipykernel_62469/2089930413.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcalculate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"macro\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/policyengine/policyengine.py/policyengine/simulation.py\u001b[0m in \u001b[0;36mcalculate\u001b[0;34m(self, output)\u001b[0m\n\u001b[1;32m 89\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 90\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mchild_key\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mnode\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkeys\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 91\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcalculate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0moutput\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"/\"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mchild_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 92\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 93\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mnode\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/policyengine/policyengine.py/policyengine/simulation.py\u001b[0m in \u001b[0;36mcalculate\u001b[0;34m(self, output)\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[0mparent\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnode\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[0mchild_key\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0moutput\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msplit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"/\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 81\u001b[0;31m \u001b[0mnode\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparent\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mchild_key\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 82\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[0;31m# Check if any descendants are None\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mKeyError\u001b[0m: 'comparison'" - ] - } - ], - "source": [ - "sim.calculate(\"macro\")" - ] - } - ], - "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 -} From 3cafefd5590f8a3425001948d5e54954db6d18cf Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Mon, 25 Nov 2024 09:47:48 +0000 Subject: [PATCH 6/6] Fix test --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 51f8769..78833a5 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -21,7 +21,7 @@ jobs: pip install furo - name: Generate documentation - run: make docs + run: make documentation - name: Check documentation build run: |