-
Notifications
You must be signed in to change notification settings - Fork 12
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
Showing
3 changed files
with
31 additions
and
10 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,13 +1,34 @@ | ||
def test_microsim_runs_cps(): | ||
import numpy as np | ||
from fiscalsim_us import Microsimulation | ||
import numpy as np | ||
from fiscalsim_us import Microsimulation | ||
from policyengine_core.reforms import Reform | ||
from policyengine_core.periods import instant | ||
|
||
""" | ||
In US nationwide simulations, use reported state income tax liabilities | ||
""" | ||
def use_reported_state_income_tax(parameters): | ||
parameters.simulation.reported_state_income_tax.update( | ||
start=instant("2024-01-01"), stop=instant("2100-12-31"), | ||
value=True) | ||
return parameters | ||
|
||
|
||
sim = Microsimulation() | ||
hnet = sim.calc("household_net_income") | ||
class baseline_reform(Reform): | ||
def apply(self): | ||
self.modify_parameters(use_reported_state_income_tax) | ||
|
||
|
||
def test_microsim_runs_cps(): | ||
sim = Microsimulation(reform=baseline_reform) | ||
hnet = sim.calc("household_net_income", period=2024, map_to="person") | ||
assert not hnet.isna().any(), "Some households have NaN net income." | ||
hidecile = sim.calc("household_income_decile") | ||
hidecile = sim.calc( | ||
"household_income_decile", period=2024, map_to="person" | ||
) | ||
assert np.all(hidecile >= 1) and np.all(hidecile <= 10) | ||
sidecile = sim.calc("spm_unit_income_decile") | ||
sidecile = sim.calc( | ||
"spm_unit_income_decile", period=2024, map_to="person" | ||
) | ||
assert np.all(sidecile >= 1) and np.all(sidecile <= 10) | ||
idecile = sim.calc("income_decile") | ||
idecile = sim.calc("income_decile", period=2024, map_to="person") | ||
assert np.all(idecile >= 1) and np.all(idecile <= 10) |
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