def run(): parm = Policy() assert parm.current_year == 2013 recs = Records(data=TAX_DTA, weights=WEIGHTS, start_year=2009) calc = Calculator(policy=parm, records=recs) assert calc.current_year == 2013 totaldf = calc.calc_all_test() totaldf = totaldf.T.groupby(level=0).first().T # drop duplicates exp_results_file = os.path.join(CUR_PATH, '../../exp_results.csv.gz') exp_results = pd.read_csv(exp_results_file, compression='gzip') exp_set = set(exp_results.columns) # fix-up to bad colname in exp_results cur_set = set(totaldf.columns) assert(exp_set == cur_set) for label in exp_results.columns: lhs = exp_results[label].values.reshape(len(exp_results)) rhs = totaldf[label].values.reshape(len(exp_results)) res = np.allclose(lhs, rhs, atol=1e-02) if not res: print('Problem found in: ', label)
def run(): """ Run each function defined in Calculator.calc_all_test method using 'puf.csv' input and writing ouput to a CSV file named 'results_puf.csv'. """ # create a Policy object containing current-law policy (clp) parameters clp = Policy() # create a Records object (puf) containing puf.csv input records tax_dta = pd.read_csv('puf.csv') blowup_factors = './taxcalc/StageIFactors.csv' weights = './taxcalc/WEIGHTS.csv' puf = Records(tax_dta, blowup_factors, weights) # create a Calculator object using clp policy and puf records calc = Calculator(policy=clp, records=puf) # save calculated test results in output dataframe (odf) odf = calc.calc_all_test() odf = odf.T.groupby(level=0).first().T # write test output to csv file named 'results_puf.csv' odf.to_csv('results_puf.csv', float_format='%1.3f', sep=',', header=True, index=False)