def test_present_value(): """ Testing all the methods to generate a present value of net transfers """ size_generation = 3 cohort = create_neutral_profiles_cohort(population=1) cohort2 = create_neutral_profiles_cohort(population=size_generation) res = cohort.aggregate_generation_present_value('tax') # defining a function which creates the theoretical result of the present value for the following test def control_value(x): control_value = (50 - abs(x - 50)) return control_value age = 0 while age <= 100: assert res.get_value((age, 1, 2002), 'tax') == control_value(age), res.get_value( (age, 1, 2060), 'tax') == control_value(age) age += 1 cohort3 = cohort2.per_capita_generation_present_value('tax') res_control = cohort2.aggregate_generation_present_value('tax', discount_rate=0) count = 0 while count <= 100: # print cohort3.get_value((count, 1, 2001), 'tax'), res_control.get_value((count, 0, 2001), 'tax') assert cohort3.get_value( (count, 1, 2001), 'tax') * size_generation == res_control.get_value((count, 0, 2001), 'tax') count += 1
def test_present_value(): """ Testing all the methods to generate a present value of net transfers """ size_generation = 3 cohort = create_neutral_profiles_cohort(population = 1) cohort2 = create_neutral_profiles_cohort(population = size_generation) res = cohort.aggregate_generation_present_value('tax') # defining a function which creates the theoretical result of the present value for the following test def control_value(x): control_value = (50 - abs(x-50)) return control_value age = 0 while age <= 100: assert res.get_value((age, 1, 2002), 'tax') == control_value(age), res.get_value((age, 1, 2060), 'tax') == control_value(age) age +=1 cohort3 = cohort2.per_capita_generation_present_value('tax') res_control = cohort2.aggregate_generation_present_value('tax', discount_rate=0) count = 0 while count <= 100: # print cohort3.get_value((count, 1, 2001), 'tax'), res_control.get_value((count, 0, 2001), 'tax') assert cohort3.get_value((count, 1, 2001), 'tax')*size_generation == res_control.get_value((count, 0, 2001), 'tax') count +=1
def test_compute_ipl(): size_generation = 3 cohort2 = create_neutral_profiles_cohort(population=size_generation) cohort3 = cohort2.aggregate_generation_present_value('tax') ipl = cohort3.compute_ipl(typ='tax', net_gov_wealth=10) assert ipl == 10.0
def test_compute_ipl(): size_generation = 3 cohort2 = create_neutral_profiles_cohort(population=size_generation) cohort3 = cohort2.aggregate_generation_present_value("tax") ipl = cohort3.compute_ipl(typ="tax", net_gov_wealth=10) assert ipl == 10.0
def test_compute_ipl(): size_generation = 3 cohort2 = create_neutral_profiles_cohort(population = size_generation) cohort3 = cohort2.aggregate_generation_present_value('tax') ipl = cohort3.compute_ipl(typ = 'tax', net_gov_wealth = 10) precision = cohort3.compute_ipl(typ = 'tax', net_gov_wealth = 10, precision=True) assert precision == size_generation/ipl assert ipl == -10.0
def test_compute_gen_imbalance(): size_generation = 1 cohort = create_neutral_profiles_cohort(population=size_generation) simulation = Simulation() simulation.discount_rate = 0 simulation.growth_rate = 0 simulation.cohorts = cohort simulation.create_present_values('tax') gen_imbalance = simulation.compute_gen_imbalance(typ='tax') # print gen_imbalance assert gen_imbalance == -5000.0 / (2 * 199.0)
def test_compute_gen_imbalance(): size_generation = 1 cohort = create_neutral_profiles_cohort(population = size_generation) simulation = Simulation() simulation.discount_rate = 0 simulation.growth_rate = 0 simulation.cohorts = cohort simulation.create_present_values('tax') gen_imbalance = simulation.compute_gen_imbalance(typ = 'tax') # print gen_imbalance assert gen_imbalance[0] == -5000.0/(2*199.0), gen_imbalance[1] == -5000.0/(2*199.0)
def test_compute_gen_imbalance(): size_generation = 1 cohort = create_neutral_profiles_cohort(population = size_generation) simulation = Simulation() simulation.discount_rate = 0 simulation.growth_rate = 0 simulation.cohorts = cohort simulation.create_present_values('tax') print simulation.aggregate_pv.tail(20).to_string() print simulation.cohorts.head(20).to_string() gen_imbalance = simulation.compute_gen_imbalance(typ = 'tax', to_return='difference') # print gen_imbalance, -5000.0/(2*199.0) assert gen_imbalance == -5000.0/(2*199.0)
def test_save_simulation(): size_generation = 1 cohort = create_neutral_profiles_cohort(population = size_generation) simulation = Simulation() simulation.country = 'france' simulation.discount_rate = 0 simulation.growth_rate = 0 simulation.cohorts = cohort simulation.create_present_values('tax') simulation.save_simulation(filename='test_save') store = HDFStore(os.path.join(SRC_PATH,'countries','france','sources', 'Output_folder','test_save.h5')) assert store['aggregate_pv'] is not None