Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename spm_unit_net_income to spm_resources #3722

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9619d41
Rename `spm_unit_net_income` to `spm_resources`
SirMalamute Jan 29, 2024
6f909b4
Merge branch 'master' of https://github.com/PolicyEngine/policyengine…
SirMalamute Feb 11, 2024
b762a52
Merge branch 'master' of https://github.com/PolicyEngine/policyengine…
SirMalamute Feb 12, 2024
d76a524
added 2 tests, causes issues with labor_supply_response.py
SirMalamute Feb 12, 2024
57bfd9c
added deep_spm_poverty test
SirMalamute Feb 19, 2024
0c367cc
incomplete test
SirMalamute Feb 19, 2024
1f4b406
Merge branch 'master' of https://github.com/PolicyEngine/policyengine…
SirMalamute Feb 19, 2024
2202cc9
fixed issues
SirMalamute Feb 19, 2024
b3fe97d
Update policyengine_us/variables/household/income/spm_unit/spm_unit_o…
SirMalamute Mar 18, 2024
ad9a1ed
Update policyengine_us/variables/household/income/spm_unit/spm_unit_i…
SirMalamute Mar 18, 2024
f66757e
Rename `spm_unit_net_income` to `spm_resources`
SirMalamute Mar 18, 2024
894f523
Update policyengine_us/variables/household/income/spm_unit/deep_pover…
SirMalamute Mar 21, 2024
7880670
Update policyengine_us/variables/household/income/spm_unit/poverty_ga…
SirMalamute Mar 21, 2024
b495c31
Update policyengine_us/variables/household/income/spm_unit/spm_unit_i…
SirMalamute Mar 21, 2024
a692218
Merge branch 'master' of https://github.com/PolicyEngine/policyengine…
SirMalamute Mar 21, 2024
cca478e
adjusted return function
SirMalamute Mar 21, 2024
ad982b0
Merge branch 'SirMalamute/issue3707' of https://github.com/SirMalamut…
SirMalamute Mar 21, 2024
d0f28cd
Merge branch 'master' of https://github.com/PolicyEngine/policyengine…
SirMalamute Mar 28, 2024
9f377ce
Rename `spm_unit_net_income` to `spm_resources`
SirMalamute Apr 1, 2024
9206370
Merge branch 'master' of https://github.com/PolicyEngine/policyengine…
SirMalamute Apr 1, 2024
ed8094c
Update policyengine_us/variables/household/income/spm_unit/spm_unit_o…
SirMalamute Apr 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- bump: minor
changes:
added:
- Code coverage for SPM Unit.
- Renamed spm_unit_net_income to spm_resources
6 changes: 3 additions & 3 deletions docs/gov/irs/credits/cdcc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -162613,7 +162613,7 @@
"\n",
"class ignore_reported(Reform):\n",
" def apply(self):\n",
" self.neutralize_variable(\"spm_unit_net_income_reported\")\n",
" self.neutralize_variable(\"spm_resources_reported\")\n",
"\n",
"\n",
"class neutralize_cdcc(Reform):\n",
Expand All @@ -162625,8 +162625,8 @@
"sim_no_cdcc = Microsimulation((ignore_reported, neutralize_cdcc), year=2020)\n",
"\n",
"(\n",
" sim.calc(\"spm_unit_net_income\", period=2022).sum()\n",
" - sim_no_cdcc.calc(\"spm_unit_net_income\", period=2022).sum()\n",
" sim.calc(\"spm_resources\", period=2022).sum()\n",
" - sim_no_cdcc.calc(\"spm_resources\", period=2022).sum()\n",
") / 1e6"
]
}
Expand Down
8 changes: 4 additions & 4 deletions docs/gov/irs/credits/clean-vehicle.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85340,7 +85340,7 @@
" return pd.DataFrame(\n",
" dict(\n",
" employment_income=sim.calc(\"employment_income\")[0],\n",
" spm_unit_net_income=sim.calc(\"spm_unit_net_income\")[0],\n",
" spm_resources=sim.calc(\"spm_resources\")[0],\n",
" credit=sim.calc(\"new_clean_vehicle_credit\")[0],\n",
" adults=adults,\n",
" children=children,\n",
Expand All @@ -85362,7 +85362,7 @@
"wide = df.pivot(\n",
" index=[\"employment_income\", \"adults\", \"children\"],\n",
" columns=\"purchased_qualifying_new_clean_vehicle\",\n",
" values=\"spm_unit_net_income\",\n",
" values=\"spm_resources\",\n",
").reset_index()\n",
"wide[\"benefit\"] = wide[True] - wide[False]\n",
"\n",
Expand Down Expand Up @@ -170708,7 +170708,7 @@
" return pd.DataFrame(\n",
" dict(\n",
" employment_income=sim.calc(\"employment_income\")[0],\n",
" spm_unit_net_income=sim.calc(\"spm_unit_net_income\")[0],\n",
" spm_resources=sim.calc(\"spm_resources\")[0],\n",
" credit=sim.calc(\"used_clean_vehicle_credit\")[0],\n",
" adults=adults,\n",
" children=children,\n",
Expand All @@ -170734,7 +170734,7 @@
"wide = df.pivot(\n",
" index=[\"employment_income\", \"adults\", \"children\"],\n",
" columns=\"purchased_qualifying_used_clean_vehicle\",\n",
" values=\"spm_unit_net_income\",\n",
" values=\"spm_resources\",\n",
").reset_index()\n",
"\n",
"wide[\"benefit\"] = wide[True] - wide[False]\n",
Expand Down
18 changes: 9 additions & 9 deletions docs/gov/states/de/tax-benefit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25334,14 +25334,14 @@
" sim.add_household(name=\"household\", members=members, state_code=\"DE\")\n",
" sim.vary(\"employment_income\", max=100_000, step=100)\n",
" employment_income = sim.calc(\"employment_income\")[0]\n",
" spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n",
" spm_resources = sim.calc(\"spm_resources\")[0].round()\n",
" mtr = 1 - sim.deriv(\n",
" \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n",
" \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n",
" )\n",
" return pd.DataFrame(\n",
" dict(\n",
" employment_income=employment_income,\n",
" spm_unit_net_income=spm_unit_net_income,\n",
" spm_resources=spm_resources,\n",
" mtr=mtr,\n",
" adults=adults,\n",
" children=str(children),\n",
Expand All @@ -25359,7 +25359,7 @@
"\n",
"LABELS = dict(\n",
" employment_income=\"Employment income\",\n",
" spm_unit_net_income=\"Net income\",\n",
" spm_resources=\"Net income\",\n",
" mtr=\"Marginal tax rate\",\n",
" adults=\"Adults\",\n",
" children=\"Children\",\n",
Expand All @@ -25370,7 +25370,7 @@
"fig = px.line(\n",
" df,\n",
" \"employment_income\",\n",
" \"spm_unit_net_income\",\n",
" \"spm_resources\",\n",
" color=\"children\",\n",
" animation_frame=\"adults\",\n",
" labels=LABELS,\n",
Expand Down Expand Up @@ -53643,22 +53643,22 @@
"\n",
"sim.vary(\"employment_income\", max=100_000, step=100)\n",
"employment_income = sim.calc(\"employment_income\")[0]\n",
"spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n",
"spm_resources = sim.calc(\"spm_resources\")[0].round()\n",
"mtr = 1 - sim.deriv(\n",
" \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n",
" \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n",
")\n",
"df = pd.DataFrame(\n",
" dict(\n",
" employment_income=employment_income,\n",
" spm_unit_net_income=spm_unit_net_income,\n",
" spm_resources=spm_resources,\n",
" mtr=mtr,\n",
" )\n",
")\n",
"\n",
"fig = px.line(\n",
" df,\n",
" \"employment_income\",\n",
" \"spm_unit_net_income\",\n",
" \"spm_resources\",\n",
" labels=LABELS,\n",
" title=\"Net income for a single person aged 65 in Delaware\",\n",
")\n",
Expand Down
18 changes: 9 additions & 9 deletions docs/gov/states/ma/tax-benefit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25349,14 +25349,14 @@
" sim.add_household(name=\"household\", members=members, state_code=\"MA\")\n",
" sim.vary(\"employment_income\", max=100_000, step=100)\n",
" employment_income = sim.calc(\"employment_income\")[0]\n",
" spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n",
" spm_resources = sim.calc(\"spm_resources\")[0].round()\n",
" mtr = 1 - sim.deriv(\n",
" \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n",
" \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n",
" )\n",
" return pd.DataFrame(\n",
" dict(\n",
" employment_income=employment_income,\n",
" spm_unit_net_income=spm_unit_net_income,\n",
" spm_resources=spm_resources,\n",
" mtr=mtr,\n",
" adults=adults,\n",
" children=str(children),\n",
Expand All @@ -25374,7 +25374,7 @@
"\n",
"LABELS = dict(\n",
" employment_income=\"Employment income\",\n",
" spm_unit_net_income=\"Net income\",\n",
" spm_resources=\"Net income\",\n",
" mtr=\"Marginal tax rate\",\n",
" adults=\"Adults\",\n",
" children=\"Children\",\n",
Expand All @@ -25385,7 +25385,7 @@
"fig = px.line(\n",
" df,\n",
" \"employment_income\",\n",
" \"spm_unit_net_income\",\n",
" \"spm_resources\",\n",
" color=\"children\",\n",
" animation_frame=\"adults\",\n",
" labels=LABELS,\n",
Expand Down Expand Up @@ -53658,22 +53658,22 @@
"\n",
"sim.vary(\"employment_income\", max=100_000, step=100)\n",
"employment_income = sim.calc(\"employment_income\")[0]\n",
"spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n",
"spm_resources = sim.calc(\"spm_resources\")[0].round()\n",
"mtr = 1 - sim.deriv(\n",
" \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n",
" \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n",
")\n",
"df = pd.DataFrame(\n",
" dict(\n",
" employment_income=employment_income,\n",
" spm_unit_net_income=spm_unit_net_income,\n",
" spm_resources=spm_resources,\n",
" mtr=mtr,\n",
" )\n",
")\n",
"\n",
"fig = px.line(\n",
" df,\n",
" \"employment_income\",\n",
" \"spm_unit_net_income\",\n",
" \"spm_resources\",\n",
" labels=LABELS,\n",
" title=\"Net income for a single person aged 65 in Massachusetts\",\n",
")\n",
Expand Down
18 changes: 9 additions & 9 deletions docs/gov/states/mo/tax-benefit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25332,14 +25332,14 @@
" sim.add_household(name=\"household\", members=members, state_code=\"MO\")\n",
" sim.vary(\"employment_income\", max=100_000, step=100)\n",
" employment_income = sim.calc(\"employment_income\")[0]\n",
" spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n",
" spm_resources = sim.calc(\"spm_resources\")[0].round()\n",
" mtr = 1 - sim.deriv(\n",
" \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n",
" \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n",
" )\n",
" return pd.DataFrame(\n",
" dict(\n",
" employment_income=employment_income,\n",
" spm_unit_net_income=spm_unit_net_income,\n",
" spm_resources=spm_resources,\n",
" mtr=mtr,\n",
" adults=adults,\n",
" children=str(children),\n",
Expand All @@ -25357,7 +25357,7 @@
"\n",
"LABELS = dict(\n",
" employment_income=\"Employment income\",\n",
" spm_unit_net_income=\"Net income\",\n",
" spm_resources=\"Net income\",\n",
" mtr=\"Marginal tax rate\",\n",
" adults=\"Adults\",\n",
" children=\"Children\",\n",
Expand All @@ -25368,7 +25368,7 @@
"fig = px.line(\n",
" df,\n",
" \"employment_income\",\n",
" \"spm_unit_net_income\",\n",
" \"spm_resources\",\n",
" color=\"children\",\n",
" animation_frame=\"adults\",\n",
" labels=LABELS,\n",
Expand Down Expand Up @@ -53620,22 +53620,22 @@
"\n",
"sim.vary(\"employment_income\", max=100_000, step=100)\n",
"employment_income = sim.calc(\"employment_income\")[0]\n",
"spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n",
"spm_resources = sim.calc(\"spm_resources\")[0].round()\n",
"mtr = 1 - sim.deriv(\n",
" \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n",
" \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n",
")\n",
"df = pd.DataFrame(\n",
" dict(\n",
" employment_income=employment_income,\n",
" spm_unit_net_income=spm_unit_net_income,\n",
" spm_resources=spm_resources,\n",
" mtr=mtr,\n",
" )\n",
")\n",
"\n",
"fig = px.line(\n",
" df,\n",
" \"employment_income\",\n",
" \"spm_unit_net_income\",\n",
" \"spm_resources\",\n",
" labels=LABELS,\n",
" title=\"Net income for a single person aged 65 in Missouri\",\n",
")\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/gov/states/ny/cdcc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9962,7 +9962,7 @@
"\n",
" class ignore_reported(Reform):\n",
" def apply(self):\n",
" self.neutralize_variable(\"spm_unit_net_income_reported\")\n",
" self.neutralize_variable(\"spm_resources_reported\")\n",
"\n",
" class neutralize(Reform):\n",
" def apply(self):\n",
Expand All @@ -9974,10 +9974,10 @@
" )\n",
" program_value = sim.calc(variable, period=policy_year).sum()\n",
" baseline_net_income = sim.calc(\n",
" \"spm_unit_net_income\", period=policy_year\n",
" \"spm_resources\", period=policy_year\n",
" ).sum()\n",
" neutralized_net_income = sim_neutralized.calc(\n",
" \"spm_unit_net_income\", period=policy_year\n",
" \"spm_resources\", period=policy_year\n",
" ).sum()\n",
" budgetary_impact = neutralized_net_income - baseline_net_income\n",
" return round(program_value / 1e6), round(budgetary_impact / 1e6)\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/gov/states/ny/ctc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49446,7 +49446,7 @@
"\n",
" class ignore_reported(Reform):\n",
" def apply(self):\n",
" self.neutralize_variable(\"spm_unit_net_income_reported\")\n",
" self.neutralize_variable(\"spm_resources_reported\")\n",
"\n",
" class neutralize(Reform):\n",
" def apply(self):\n",
Expand All @@ -49458,10 +49458,10 @@
" )\n",
" program_value = sim.calc(variable, period=policy_year).sum()\n",
" baseline_net_income = sim.calc(\n",
" \"spm_unit_net_income\", period=policy_year\n",
" \"spm_resources\", period=policy_year\n",
" ).sum()\n",
" neutralized_net_income = sim_neutralized.calc(\n",
" \"spm_unit_net_income\", period=policy_year\n",
" \"spm_resources\", period=policy_year\n",
" ).sum()\n",
" budgetary_impact = neutralized_net_income - baseline_net_income\n",
" return round(program_value / 1e6), round(budgetary_impact / 1e6)\n",
Expand Down
10 changes: 5 additions & 5 deletions docs/gov/states/ny/eitc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31519,11 +31519,11 @@
"text": [
"/Users/maxghenis/opt/anaconda3/envs/py37/lib/python3.7/site-packages/policyengine_core/holders/holder.py:169: Warning:\n",
"\n",
"You cannot set a value for the variable spm_unit_net_income_reported, as it has been neutralized. The value you provided ([28327. 76811. 15350. ... 17282. 78821. 53152.]) will be ignored.\n",
"You cannot set a value for the variable spm_resources_reported, as it has been neutralized. The value you provided ([28327. 76811. 15350. ... 17282. 78821. 53152.]) will be ignored.\n",
"\n",
"/Users/maxghenis/opt/anaconda3/envs/py37/lib/python3.7/site-packages/policyengine_core/holders/holder.py:169: Warning:\n",
"\n",
"You cannot set a value for the variable spm_unit_net_income_reported, as it has been neutralized. The value you provided ([28327. 76811. 15350. ... 17282. 78821. 53152.]) will be ignored.\n",
"You cannot set a value for the variable spm_resources_reported, as it has been neutralized. The value you provided ([28327. 76811. 15350. ... 17282. 78821. 53152.]) will be ignored.\n",
"\n"
]
},
Expand Down Expand Up @@ -31559,7 +31559,7 @@
"\n",
" class ignore_reported(Reform):\n",
" def apply(self):\n",
" self.neutralize_variable(\"spm_unit_net_income_reported\")\n",
" self.neutralize_variable(\"spm_resources_reported\")\n",
"\n",
" class neutralize(Reform):\n",
" def apply(self):\n",
Expand All @@ -31571,10 +31571,10 @@
" )\n",
" program_value = sim.calc(variable, period=policy_year).sum()\n",
" baseline_net_income = sim.calc(\n",
" \"spm_unit_net_income\", period=policy_year\n",
" \"spm_resources\", period=policy_year\n",
" ).sum()\n",
" neutralized_net_income = sim_neutralized.calc(\n",
" \"spm_unit_net_income\", period=policy_year\n",
" \"spm_resources\", period=policy_year\n",
" ).sum()\n",
" budgetary_impact = neutralized_net_income - baseline_net_income\n",
" return round(program_value / 1e6), round(budgetary_impact / 1e6)\n",
Expand Down
10 changes: 5 additions & 5 deletions docs/gov/states/ny/tax-benefit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25466,14 +25466,14 @@
" sim.add_household(name=\"household\", members=members, state_code=\"NY\")\n",
" sim.vary(\"employment_income\", max=100_000, step=100)\n",
" employment_income = sim.calc(\"employment_income\")[0]\n",
" spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n",
" spm_resources = sim.calc(\"spm_resources\")[0].round()\n",
" mtr = 1 - sim.deriv(\n",
" \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n",
" \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n",
" )\n",
" return pd.DataFrame(\n",
" dict(\n",
" employment_income=employment_income,\n",
" spm_unit_net_income=spm_unit_net_income,\n",
" spm_resources=spm_resources,\n",
" mtr=mtr,\n",
" adults=adults,\n",
" children=str(children),\n",
Expand All @@ -25491,7 +25491,7 @@
"\n",
"LABELS = dict(\n",
" employment_income=\"Employment income\",\n",
" spm_unit_net_income=\"Net income\",\n",
" spm_resources=\"Net income\",\n",
" mtr=\"Marginal tax rate\",\n",
" adults=\"Adults\",\n",
" children=\"Children\",\n",
Expand All @@ -25502,7 +25502,7 @@
"fig = px.line(\n",
" df,\n",
" \"employment_income\",\n",
" \"spm_unit_net_income\",\n",
" \"spm_resources\",\n",
" color=\"children\",\n",
" animation_frame=\"adults\",\n",
" labels=LABELS,\n",
Expand Down
2 changes: 1 addition & 1 deletion policyengine_us/data/datasets/acs/acs.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def add_person_variables(acs: h5py.File, person: DataFrame) -> None:


def add_spm_variables(acs: h5py.File, spm_unit: DataFrame) -> None:
acs["spm_unit_net_income_reported"] = spm_unit.SPM_RESOURCES
acs["spm_resources_reported"] = spm_unit.SPM_RESOURCES
acs["spm_unit_spm_threshold"] = spm_unit.SPM_POVTHRESHOLD


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
taxable_interest_income: 100_000
state_fips: 48 # TX
output:
spm_unit_net_income: 151_539.00
spm_resources: 151_539.00
household_net_income: 151_539.00

- name: household_net_income test TX-netinc-alt
Expand All @@ -19,7 +19,7 @@
taxable_interest_income: 100_000
state_fips: 48 # TX
output:
spm_unit_net_income: 152_670.00
spm_resources: 152_670.00
household_net_income: 152_670.00

- name: cliff_gap test TX-cliff_gap
Expand Down
Loading
Loading