def test_txfunc_est(): ''' Test txfunc.txfunc_est() function. The test is that given inputs from previous run, the outputs are unchanged. ''' input_tuple = utils.safe_read_pickle( os.path.join(CUR_PATH, 'test_io_data', 'txfunc_est_inputs.pkl')) (df, s, t, rate_type, output_dir, graph) = input_tuple # Put old df variables into new df var names df.rename(columns={ 'MTR labor income': 'mtr_labinc', 'MTR capital income': 'mtr_capinc', 'Total labor income': 'total_labinc', 'Total capital income': 'total_capinc', 'ETR': 'etr', 'expanded_income': 'market_income', 'Weights': 'weight' }, inplace=True) tax_func_type = 'DEP' numparams = 12 test_tuple = txfunc.txfunc_est(df, s, t, rate_type, tax_func_type, numparams, output_dir, graph) expected_tuple = ((np.array([ 6.37000261e-22, 2.73401629e-03, 1.54672458e-08, 1.43446236e-02, 2.32797367e-01, -3.69059719e-02, 1.00000000e-04, -1.01967001e-01, 3.96030053e-02, 1.02987671e-01, -1.30433574e-01, 1.00000000e+00 ]), 19527.16203007729, 3798)) for i, v in enumerate(expected_tuple): assert (np.allclose(test_tuple[i], v))
def test_txfunc_est(): # Test txfunc.txfunc_est() function. The test is that given # inputs from previous run, the outputs are unchanged. input_tuple = utils.safe_read_pickle( os.path.join(CUR_PATH, 'test_io_data/txfunc_est_inputs.pkl')) (df, s, t, rate_type, output_dir, graph) = input_tuple tax_func_type = 'DEP' numparams = 12 test_tuple = txfunc.txfunc_est(df, s, t, rate_type, tax_func_type, numparams, output_dir, graph) expected_tuple = utils.safe_read_pickle( os.path.join(CUR_PATH, 'test_io_data/txfunc_est_outputs.pkl')) for i, v in enumerate(expected_tuple): assert (np.allclose(test_tuple[i], v))
def test_txfunc_est(): # Test txfunc.txfunc_est() function. The test is that given # inputs from previous run, the outputs are unchanged. input_tuple = utils.safe_read_pickle( os.path.join(CUR_PATH, 'test_io_data/txfunc_est_inputs.pkl')) (df, s, t, rate_type, output_dir, graph) = input_tuple tax_func_type = 'DEP' numparams = 12 test_tuple = txfunc.txfunc_est(df, s, t, rate_type, tax_func_type, numparams, output_dir, graph) expected_tuple = utils.safe_read_pickle( os.path.join(CUR_PATH, 'test_io_data/txfunc_est_outputs.pkl')) for i, v in enumerate(expected_tuple): assert(np.allclose(test_tuple[i], v))