Skip to content

Commit

Permalink
Make dropq test fail like in issue #1367
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Jun 3, 2017
1 parent 8cd518e commit 6610a62
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions taxcalc/tests/test_dropq.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,45 +215,49 @@ def test_dropq_diff_table(groupby, res_column, puf_1991_path):
@pytest.mark.requires_pufcsv
def test_with_pufcsv(puf_path):
# specify usermods dictionary in code
start_year = 2016
reform_year = start_year + 1
reforms = dict()
reforms['_II_rt3'] = [0.33]
reforms['_PT_rt3'] = [0.33]
reforms['_II_rt4'] = [0.33]
reforms['_PT_rt4'] = [0.33]
start_year = 2017
reform_year = start_year
analysis_year = 2026
year_n = analysis_year - start_year
reforms = {
'_FICA_ss_trt': [0.2]
}
# '_FICA_ss_trt': [0.22000] # no error
# '_FICA_ss_trt': [0.21000] # generates error
# '_FICA_ss_trt': [0.20000] # generates error
# '_FICA_ss_trt': [0.19999] # no error
# '_FICA_ss_trt': [0.19000] # no error

usermods = dict()
usermods['policy'] = {reform_year: reforms}
usermods['consumption'] = {}
usermods['behavior'] = {}
usermods['growdiff_baseline'] = {}
usermods['growdiff_response'] = {}
usermods['gdp_elasticity'] = {}
seed = random_seed(usermods)
assert seed == 3047708076
random_seed(usermods)
# create a Policy object (pol) containing reform policy parameters
pol = Policy()
pol.implement_reform(usermods['policy'])
# create a Records object (rec) containing all puf.csv input records
rec = Records(data=puf_path)
# create a Calculator object using clp policy and puf records
calc = Calculator(policy=pol, records=rec)
while calc.current_year < reform_year:
while calc.current_year < analysis_year:
calc.increment_year()
# create aggregate diagnostic table (adt) as a Pandas DataFrame object
years = reform_year - Policy.JSON_START_YEAR + 1
adt = multiyear_diagnostic_table(calc, years)
adt = multiyear_diagnostic_table(calc, 1)
taxes_fullsample = adt.loc["Combined Liability ($b)"]
assert taxes_fullsample is not None
fulls_reform_revenue = taxes_fullsample.loc[reform_year]
fulls_reform_revenue = taxes_fullsample.loc[analysis_year]
# create a Public Use File object
tax_data = pd.read_csv(puf_path)
# call run_nth_year_tax_calc_model function
restuple = run_nth_year_tax_calc_model(1, start_year,
restuple = run_nth_year_tax_calc_model(year_n, start_year,
tax_data, usermods,
return_json=True)
total = restuple[len(restuple) - 1] # the last of element of the tuple
dropq_reform_revenue = float(total['combined_tax_1'])
dropq_reform_revenue = float(total['combined_tax_9'])
dropq_reform_revenue *= 1e-9 # convert to billions of dollars
diff = abs(fulls_reform_revenue - dropq_reform_revenue)
# assert that dropq revenue is similar to the fullsample calculation
Expand Down

0 comments on commit 6610a62

Please sign in to comment.