Example #1
0
def test_dsct():
    population = create_empty_population_dataframe(2001, 2061)
    cohorts = Cohorts(data = population, columns = ['pop']) 
    cohorts.gen_dsct(0.05)
    test_value = cohorts.get_value((0,0,2060), 'dsct')
#    print test_value
    assert test_value <= 1
Example #2
0
def test_empty_frame_generation():

    year_start = 2001
    year_end = 2061
    population_dataframe = create_empty_population_dataframe(year_start, year_end)
    test_value = population_dataframe.get_value((0,0,2043), "pop")
    assert test_value == 1
Example #3
0
def test_fill_cohort():   
    population = create_empty_population_dataframe(2001, 2061)
    profiles = create_constant_profiles_dataframe(population, tax = -1, subsidies = 0.5)
    cohorts_test = DataCohorts(data = population, columns = ['pop'])
    cohorts_test.fill(profiles, year = None)
    test_value = cohorts_test.get_value((0,0,2060), 'tax')
    assert test_value == -1
Example #4
0
def test_dsct():
    population = create_empty_population_dataframe(2001, 2061)
    cohorts = Cohorts(data=population, columns=["pop"])
    cohorts.gen_dsct(0.05)
    test_value = cohorts.get_value((0, 0, 2060), "dsct")
    #    print test_value
    assert test_value <= 1
Example #5
0
def test_empty_frame_generation():

    year_start = 2001
    year_end = 2061
    population_dataframe = create_empty_population_dataframe(year_start, year_end)
    test_value = population_dataframe.get_value((0, 0, 2043), "pop")
    assert test_value == 1
Example #6
0
def test_column_combination():
    year_start = 2001
    pop_dataframe = create_empty_population_dataframe(year_start, 2061)
#     print pop_dataframe
    profiles_dataframe = create_constant_profiles_dataframe(pop_dataframe, tax=-1.0, sub=0.5)
#     print profiles_dataframe
    profiles_dataframe['net'] = profiles_dataframe.sum(axis=1) 
#     print profiles_dataframe['net']
    test_value = profiles_dataframe.get_value((0,0,2001), 'net')
#     print test_value
    assert test_value == -0.5
Example #7
0
def test_column_combination():
    year_start = 2001
    pop_dataframe = create_empty_population_dataframe(year_start, 2061)
    #     print pop_dataframe
    profiles_dataframe = create_constant_profiles_dataframe(pop_dataframe, tax=-1.0, sub=0.5)
    #     print profiles_dataframe
    profiles_dataframe["net"] = profiles_dataframe.sum(axis=1)
    #     print profiles_dataframe['net']
    test_value = profiles_dataframe.get_value((0, 0, 2001), "net")
    #     print test_value
    assert test_value == -0.5
Example #8
0
def test_compute_net_transfers():
    population = create_empty_population_dataframe(2001, 2061)
    profiles = create_constant_profiles_dataframe(population, tax = 1, subsidies = 0.5)
    tax = ['tax']
    subsidy = ['subsidies']
    cohorts_test = DataCohorts(data = population, columns = ['pop'])
    cohorts_test.fill(profiles, year = None)
    cohorts_test.compute_net_transfers(taxes_list = tax, payments_list = subsidy)
    test_value = cohorts_test.get_value((0,0,2060), 'net_transfers')
    assert test_value == 0.5
    
    pass
Example #9
0
def test_population_projection():
    # Create cohorts
    start_data = 2001
    end_data = 2061
    population = create_empty_population_dataframe(start_data, end_data)
    cohorts = DataCohorts(data=population, columns=['pop'])

    # Complete population projection
    year_length = 100
    end_project = start_data + year_length
    method = 'exp_growth'
    growth_rate = n = 0.05
    cohorts.population_project(year_length, method=method, growth_rate=n)

    year_control = 2082
    control_value = (1 + n)**(year_control - end_data - 1)
    test_value = cohorts.get_value((0, 0, 2081), "pop")
    assert test_value == control_value
Example #10
0
def test_population_projection():
    # Create cohorts
    start_data = 2001
    end_data = 2061
    population = create_empty_population_dataframe(start_data, end_data)
    cohorts = DataCohorts(data = population, columns = ['pop'])

    # Complete population projection
    year_length = 100
    end_project = start_data + year_length
    method = 'exp_growth'   
    growth_rate = n = 0.05
    cohorts.population_project(year_length, method = method, growth_rate = n)
    
    year_control = 2082
    control_value = (1+n)**(year_control - end_data - 1)
    test_value = cohorts.get_value((0,0,2081), "pop")
    assert test_value == control_value
Example #11
0
def test_tax_projection():

    population = create_empty_population_dataframe(2001, 2061)
    profile = create_constant_profiles_dataframe(population, tax=-1, sub=0.5)
    g = 0.05
    r = 0
    cohort = DataCohorts(population)
    year_length = 200
    method = 'stable'
    cohort.population_project(year_length, method=method)
    cohort._fill(profile)
    typ = None
    cohort.proj_tax(g, r, typ, method='per_capita')
    #    print cohort
    test_value = cohort.get_value((0, 1, 2002), 'tax')
    test_value2 = cohort.get_value((0, 1, 2002), 'sub')
    #    print test_value, test_value2
    # TODO: I don't understand the following <- Just wanted to check if the for loop works by changing the value of typ in the test
    assert test_value2 > 0.5 and test_value < -1
Example #12
0
def test_tax_projection():

    population = create_empty_population_dataframe(2001, 2061)
    profile = create_constant_profiles_dataframe(population, tax = -1, sub=0.5) 
    g = 0.05
    r = 0
    cohort = DataCohorts(population)
    year_length = 200
    method = 'stable'   
    cohort.population_project(year_length, method = method)
    cohort.fill(profile)
    typ = None
    cohort.proj_tax(g, r, typ,  method = 'per_capita')
#    print cohort
    test_value = cohort.get_value((0,1,2002), 'tax')
    test_value2 = cohort.get_value((0,1,2002), 'sub')
#    print test_value, test_value2
    # TODO: I don't understand the following <- Just wanted to check if the for loop works by changing the value of typ in the test
    assert test_value2 > 0.5 and test_value < -1