test_data = [(b1, p1, expected1), (b2, p2, expected2)] @pytest.mark.parametrize('b,p,expected', test_data, ids=['constant params', 'vary params']) def test_MTR_wealth(b, p, expected): # Test marginal tax rate on wealth tau_w_prime = tax.MTR_wealth(b, p.h_wealth[:p.T], p.m_wealth[:p.T], p.p_wealth[:p.T]) assert np.allclose(tau_w_prime, expected) p1 = Specifications() p1.S = 2 p1.J = 1 p1.e = np.array([0.5, 0.45]) p1.tax_func_type = 'DEP' etr_params1 = np.reshape(np.array([ [0.001, 0.002, 0.003, 0.0015, 0.8, -0.14, 0.8, -0.15, 0.15, 0.16, -0.15, 0.83], [0.001, 0.002, 0.003, 0.0015, 0.8, -0.14, 0.8, -0.15, 0.15, 0.16, -0.15, 0.83]]), (1, p1.S, 12)) p2 = Specifications() p2.S = 2 p2.J = 1 p2.e = np.array([0.5, 0.45]) p2.tax_func_type = 'GS' etr_params2 = np.reshape(np.array([ [0.396, 0.7, 0.9, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1.4248841, 0.806333875, 6.987729463]]))] @pytest.mark.parametrize('n,params,expected', test_data, ids=['1', '2', '3', '4', '5', '6', '7', '8']) def test_marg_ut_labor(n, params, expected): # Test marginal utility of labor calculation test_value = household.marg_ut_labor(n, params.chi_n, params) assert np.allclose(test_value, expected) p1 = Specifications() p1.zeta = np.array([[0.1, 0.3], [0.15, 0.4], [0.05, 0.0]]) p1.S = 3 p1.J = 2 p1.T = 3 p1.lambdas = np.array([0.6, 0.4]) p1.omega_SS = np.array([0.25, 0.25, 0.5]) p1.omega = np.tile(p1.omega_SS.reshape((1, p1.S)), (p1.T, 1)) BQ1 = 2.5 p1.use_zeta = True expected1 = np.array([[1.66666667, 7.5], [2.5, 10.0], [0.416666667, 0.0]]) p2 = Specifications() p2.zeta = np.array([[0.1, 0.3], [0.15, 0.4], [0.05, 0.0]]) p2.S = 3 p2.J = 2 p2.T = 3 p2.lambdas = np.array([0.6, 0.4]) p2.omega_SS = np.array([0.25, 0.25, 0.5])