From 2a4170359f09b1932c3e3c93b9517e4cb72a96e0 Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Fri, 10 May 2024 05:15:18 -0600 Subject: [PATCH] Updated test_microsim.py --- .../tests/microsimulation/test_microsim.py | 37 +++++++++++++++---- .../income/subtractions/mn_subtractions.py | 1 - setup.py | 3 +- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/fiscalsim_us/tests/microsimulation/test_microsim.py b/fiscalsim_us/tests/microsimulation/test_microsim.py index 3ce5c857a..3f581df69 100644 --- a/fiscalsim_us/tests/microsimulation/test_microsim.py +++ b/fiscalsim_us/tests/microsimulation/test_microsim.py @@ -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) diff --git a/fiscalsim_us/variables/gov/states/mn/tax/income/subtractions/mn_subtractions.py b/fiscalsim_us/variables/gov/states/mn/tax/income/subtractions/mn_subtractions.py index 30329b69e..e3ec4b323 100644 --- a/fiscalsim_us/variables/gov/states/mn/tax/income/subtractions/mn_subtractions.py +++ b/fiscalsim_us/variables/gov/states/mn/tax/income/subtractions/mn_subtractions.py @@ -5,7 +5,6 @@ class mn_subtractions(Variable): """ Line 7 of form M1 (2023) """ - value_type = float entity = TaxUnit label = "Minnesota subtractions from federal AGI" diff --git a/setup.py b/setup.py index 40495dc8a..6cec2edba 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,8 @@ "click==8.1.3", "h5py", "microdf_python", - "numpy>=1.24, <1.25", + "numpy>=1.24", + "scipy==1.10.1", "pandas", "pathlib", "policyengine-core>=2.8,<2.9",