Skip to content

Commit

Permalink
Merge pull request #267 from jdebacker/fix_microdata
Browse files Browse the repository at this point in the history
Remove passing growth assumptions to taxcalc
  • Loading branch information
jdebacker authored Mar 10, 2017
2 parents 99f548e + c11380c commit d4a69c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 47 deletions.
39 changes: 1 addition & 38 deletions Python/ogusa/get_micro_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,6 @@
import numba
import pickle

def only_growth_assumptions(user_mods, start_year):
"""
Extract any reform parameters that are pertinent to growth
assumptions
"""
growth_dd = taxcalc.growth.Growth.default_data(start_year=start_year)
ga = {}
for year, reforms in user_mods.items():
overlap = set(growth_dd.keys()) & set(reforms.keys())
if overlap:
ga[year] = {param:reforms[param] for param in overlap}
return ga


def only_reform_mods(user_mods, start_year):
"""
Extract parameters that are just for policy reforms
"""
pol_refs = {}
beh_dd = Behavior.default_data(start_year=start_year)
growth_dd = taxcalc.growth.Growth.default_data(start_year=start_year)
policy_dd = taxcalc.policy.Policy.default_data(start_year=start_year)
for year, reforms in user_mods.items():
all_cpis = {p for p in reforms.keys() if p.endswith("_cpi") and
p[:-4] in policy_dd.keys()}
pols = set(reforms.keys()) - set(beh_dd.keys()) - set(growth_dd.keys())
pols &= set(policy_dd.keys())
pols ^= all_cpis
if pols:
pol_refs[year] = {param:reforms[param] for param in pols}
return pol_refs

def get_calculator(baseline, calculator_start_year, reform=None, data=None, weights=None, records_start_year=None):
'''
Expand Down Expand Up @@ -89,18 +58,12 @@ def get_calculator(baseline, calculator_start_year, reform=None, data=None, weig
#Should not be a reform if baseline is True
assert not reform

growth_assumptions = only_growth_assumptions(reform, calculator_start_year)
reform_mods = only_reform_mods(reform, calculator_start_year)

if not baseline:
policy1.implement_reform(reform_mods)
policy1.implement_reform(reform)

# the default set up increments year to 2013
calc1 = Calculator(records=records1, policy=policy1)

if growth_assumptions:
calc1.growth.update_growth(growth_assumptions)

# this increment_year function extrapolates all PUF variables to the next year
# so this step takes the calculator to the start_year
for i in range(calculator_start_year-2013):
Expand Down
15 changes: 7 additions & 8 deletions Python/ogusa/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_compare_dict_diff_ndarrays_relative():
def test_get_micro_data_get_calculator():

reform = {
2016: {
2017: {
'_II_rt1': [.09],
'_II_rt2': [.135],
'_II_rt3': [.225],
Expand All @@ -187,24 +187,23 @@ def test_get_micro_data_get_calculator():
'_II_rt7': [0.3564],
}, }

calc = get_calculator(baseline=False, calculator_start_year=2016,
calc = get_calculator(baseline=False, calculator_start_year=2017,
reform=reform, data=TAXDATA,
weights=WEIGHTS, records_start_year=2009)
assert calc.current_year == 2016
assert calc.current_year == 2017

reform = {
2016: {
2017: {
'_II_rt1': [.09],
'_II_rt2': [.135],
'_II_rt3': [.225],
'_II_rt4': [.252],
'_II_rt5': [.297],
'_II_rt6': [.315],
'_II_rt7': [0.3564],
'_factor_adjustment': [0.1]
'_II_rt7': [0.3564]
}, }

calc2 = get_calculator(baseline=False, calculator_start_year=2016,
calc2 = get_calculator(baseline=False, calculator_start_year=2017,
reform=reform, data=TAXDATA,
weights=WEIGHTS, records_start_year=2009)
assert calc2.current_year == 2016
assert calc2.current_year == 2017
2 changes: 1 addition & 1 deletion Python/ogusa/tests/test_run_ogusa.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def run_micro_macro(reform, user_params, guid):
def test_run_micro_macro():

reform = {
2016: {
2017: {
'_II_rt1': [.09],
'_II_rt2': [.135],
'_II_rt3': [.225],
Expand Down

0 comments on commit d4a69c6

Please sign in to comment.