def test_calc_r(p, expected_dict): ''' Test of the calculation of the discount rate function ''' f_dict = { 'c': { 'mix': p.f_c, 'd': 1.0, 'e': 0.0 }, 'pt': { 'mix': p.f_pt, 'd': 1.0, 'e': 0.0 } } int_haircut_dict = { 'c': p.interest_deduct_haircut_c, 'pt': p.interest_deduct_haircut_pt } E_dict = {'c': p.E_c, 'pt': 0.07} print('E dict = ', E_dict) ace_dict = {'c': p.ace_c, 'pt': p.ace_pt} test_dict = {} for t in p.entity_list: test_dict[t] = {} for f in p.financing_list: test_dict[t][f] = pf.calc_r(p.u[t], p.nominal_interest_rate, p.inflation_rate, p.ace_int_rate, f_dict[t][f], int_haircut_dict[t], E_dict[t], ace_dict[t]) for k, v in test_dict.items(): for k2, v2 in v.items(): assert (np.allclose(v2, expected_dict[k][k2]))
def test_calc_r(p, expected_dict): ''' Test of the calculation of the discount rate function ''' f_dict = { 'c': { 'mix': p.f_c, 'd': 1.0, 'e': 0.0 }, 'pt': { 'mix': p.f_pt, 'd': 1.0, 'e': 0.0 } } int_haircut_dict = { 'c': p.interest_deduct_haircut_c, 'pt': p.interest_deduct_haircut_pt } E_dict = {'c': p.E_c, 'pt': 0.07} print('E dict = ', E_dict) ace_dict = {'c': p.ace_c, 'pt': p.ace_pt} test_dict = pf.calc_r(p, f_dict, int_haircut_dict, E_dict, ace_dict) for k, v in test_dict.items(): for k2, v2 in v.items(): assert (np.allclose(v2, expected_dict[k][k2]))
def compute_default_params(self): ''' Does cheap calculations to return parameter values ''' self.financing_list = ['mix', 'd', 'e'] self.entity_list = ['c', 'nc'] # If new_view, then don't assume don't pay out any dividends # This becuase under new view, equity investments are financed # with retained earnings if self.new_view: self.m = 1 # Get after-tax return to savers self.s, E_nc = pf.calc_s(self) # Set rate of 1st layer of taxation on investment income self.u = {'c': self.CIT_rate} if not self.PT_entity_tax_ind.all(): self.u['nc'] = self.tau_nc else: self.u['nc'] = self.PT_entity_tax_rate E_dict = {'c': self.E_c, 'nc': E_nc} # Allowance for Corporate Equity ace_dict = {'c': self.ace_c, 'nc': self.ace_nc} # Limitation on interest deduction int_haircut_dict = {'c': self.interest_deduct_haircut_corp, 'nc': self.interest_deduct_haircut_PT} # Debt financing ratios f_dict = {'c': {'mix': self.f_c, 'd': 1.0, 'e': 0.0}, 'nc': {'mix': self.f_nc, 'd': 1.0, 'e': 0.0}} # Compute firm discount factors self.r = pf.calc_r(self, f_dict, int_haircut_dict, E_dict, ace_dict) # Compute firm after-tax rates of return r_prime = pf.calc_r_prime(self, f_dict, E_dict) # if no entity level taxes on pass-throughs, ensure mettr and metr # on non-corp entities the same if not self.PT_entity_tax_ind: for f in self.financing_list: r_prime['nc'][f] = self.s['nc'][f] + self.inflation_rate # if entity level tax, assume distribute earnings at same rate corps # distribute dividends and these are taxed at dividends tax rate # (which seems likely). Also implicitly assumed that if entity # level tax, then only additional taxes on pass-through income are # capital gains and dividend taxes else: # keep debt and equity financing ratio the same even though now # entity level tax that might now favor debt self.s['nc']['mix'] = (self.f_nc * self.s['nc']['d'] + (1 - self.f_nc) * self.s['c']['e']) self.r_prime = r_prime # Map string tax methods into multiple of declining balance self.tax_methods = {'DB 200%': 2.0, 'DB 150%': 1.5, 'SL': 1.0, 'Economic': 1.0, 'Expensing': 1.0} # Create dictionaries with depreciation system and rate of bonus # depreciation by asset class class_list = [3, 5, 7, 10, 15, 20, 25, 27.5, 39] class_list_str = [ (str(i) if i != 27.5 else '27_5') for i in class_list ] self.bonus_deprec = {} for cl in class_list_str: self.bonus_deprec[cl] = getattr( self, 'BonusDeprec_{}yr'.format(cl)) # to handle land and inventories # this is fixed later, but should work on this self.bonus_deprec['100'] = 0.0