def test_compare_sheets_to_IPP():  # WIP. for now it only generates the first two sheets, to be compared to Agrégats IPP
    df = get_tidy_data(2012)
    variables_CN1 = generate_CN1_variables(2012)
    variables_CN2 = generate_CN2_variables(2012)
    values_CN1_2012, formulas_CN1 = get_or_construct_data(df, variables_CN1, range(1949, 2013))
    values_CN2_2012, formulas_CN2 = get_or_construct_data(df, variables_CN2, range(1949, 2013))
    return values_CN1_2012, values_CN2_2012
Example #2
0
def test_compare_sheets_to_IPP(
):  # WIP. for now it only generates the first two sheets, to be compared to Agrégats IPP
    df = get_tidy_data(2012)
    variables_CN1 = generate_CN1_variables(2012)
    variables_CN2 = generate_CN2_variables(2012)
    values_CN1_2012, formulas_CN1 = get_or_construct_data(
        df, variables_CN1, range(1949, 2013))
    values_CN2_2012, formulas_CN2 = get_or_construct_data(
        df, variables_CN2, range(1949, 2013))
    return values_CN1_2012, values_CN2_2012
Example #3
0
def test_get_or_construct_data_CN1():  # copied on the one in cn_test
    df = get_comptes_nationaux_data(2013)
    values_CN1_target = read_CN1(2013)
    variables_CN1 = generate_CN1_variables(2013)
    values_CN1, formulas_CN1 = get_or_construct_data(df, variables_CN1,
                                                     range(1949, 2014))
    assert_frame_equal(values_CN1, values_CN1_target)
def test_CN1(year):
    df = get_tidy_data(year)
    values_CN1_target = read_CN1(year)
    variables_CN1 = generate_CN1_variables(year)
    values_CN1, formulas_CN1 = get_or_construct_data(df, variables_CN1, range(1949, year + 1))

    assert_frame_equal(values_CN1, values_CN1_target)
def test_profits_societes():
    df = get_tidy_data(2013)
    values_profits_societes_target = read_profits_societes()
    dict_profits_societes = create_dict_profits()
    values_profits_societes = get_or_construct_data(df, dict_profits_societes)[0]

    assert_frame_equal(values_profits_societes, values_profits_societes_target)
def create_and_save_CN1(year):  # NB : should no longer be executed - already saved
    file_path = (os.path.join(tests_data, 'values_CN1_{}.h5'.format(year)))
    assert not os.path.exists(file_path), 'CN1 sheet with {} data already generated and saved'.format(year)
    df = get_tidy_data(year)
    variables_CN1 = generate_CN1_variables(year)
    values_CN1, formulas_CN1 = get_or_construct_data(df, variables_CN1, range(1949, year + 1))
    values_CN1.to_hdf(file_path, 'CN1')
Example #7
0
def test_CN1(year):
    df = get_tidy_data(year)
    values_CN1_target = read_CN1(year)
    variables_CN1 = generate_CN1_variables(year)
    values_CN1, formulas_CN1 = get_or_construct_data(df, variables_CN1,
                                                     range(1949, year + 1))

    assert_frame_equal(values_CN1, values_CN1_target)
Example #8
0
def test_profits_societes():
    df = get_tidy_data(2013)
    values_profits_societes_target = read_profits_societes()
    dict_profits_societes = create_dict_profits()
    values_profits_societes = get_or_construct_data(df,
                                                    dict_profits_societes)[0]

    assert_frame_equal(values_profits_societes, values_profits_societes_target)
def test_get_or_construct_data_profits():  # copied on the one in cn_test
    df = get_comptes_nationaux_data(2013)

    values_profits_societes_target = read_profits_societes()
    dict_profits = create_dict_profits()
    values_profits_societes = get_or_construct_data(df, dict_profits)[0]

    assert_frame_equal(values_profits_societes, values_profits_societes_target)
def test_get_or_construct_data_CN1():  # copied on the one in cn_test
    df = get_comptes_nationaux_data(2013)
    values_CN1_target = read_CN1(2013)
    variables_CN1 = generate_CN1_variables(2013)
    values_CN1, formulas_CN1 = get_or_construct_data(df, variables_CN1, range(1949, 2014))
    print values_CN1.columns
    print values_CN1_target.columns
    assert_frame_equal(values_CN1, values_CN1_target)
Example #11
0
def create_and_save_CN1(
        year):  # NB : should no longer be executed - already saved
    file_path = (os.path.join(tests_data, 'values_CN1_{}.h5'.format(year)))
    assert not os.path.exists(
        file_path
    ), 'CN1 sheet with {} data already generated and saved'.format(year)
    df = get_tidy_data(year)
    variables_CN1 = generate_CN1_variables(year)
    values_CN1, formulas_CN1 = get_or_construct_data(df, variables_CN1,
                                                     range(1949, year + 1))
    values_CN1.to_hdf(file_path, 'CN1')
Example #12
0
def tests_get_or_construct_data():
    df = get_tidy_data(2013)

    double_dict = create_double_dict()
    dict_revenus_rdm = create_dict_revenus_rdm()
    dict_with_squares = create_dict_w_squares()
    dict_profits = create_dict_profits()
    dict_sal_cot_soc = create_dict_sal_cot_soc()
    mult_dict_with_formula = create_mult_dict_formula()

    values_double, formulas_double = get_or_construct_data(df, double_dict)
    values_double_w_formula, formulas_double_w_formula = get_or_construct_data(
        df, mult_dict_with_formula)
    values_complex, formulas_complex = get_or_construct_data(
        df, dict_with_squares)
    values_profits_societes, formulas_profits_societes = get_or_construct_data(
        df, dict_profits)
    values_revenus_reste_du_monde, formulas_revenus_reste_du_monde = get_or_construct_data(
        df, dict_revenus_rdm, range(1949, 2014))
    values_sal_cs, formulas_sal_cs = get_or_construct_data(df,
                                                           dict_sal_cot_soc,
                                                           years=range(
                                                               1949, 2014))

    return (values_double, values_double_w_formula, values_complex,
            values_profits_societes, values_revenus_reste_du_monde)
def tests_get_or_construct_data():
    df = get_tidy_data(2013)

    double_dict = create_double_dict()
    dict_revenus_rdm = create_dict_revenus_rdm()
    dict_with_squares = create_dict_w_squares()
    dict_profits = create_dict_profits()
    dict_sal_cot_soc = create_dict_sal_cot_soc()
    mult_dict_with_formula = create_mult_dict_formula()

    values_double, formulas_double = get_or_construct_data(df, double_dict)
    values_double_w_formula, formulas_double_w_formula = get_or_construct_data(df, mult_dict_with_formula)
    values_complex, formulas_complex = get_or_construct_data(df, dict_with_squares)
    values_profits_societes, formulas_profits_societes = get_or_construct_data(df, dict_profits)
    values_revenus_reste_du_monde, formulas_revenus_reste_du_monde = get_or_construct_data(
        df, dict_revenus_rdm, range(1949, 2014)
        )
    values_sal_cs, formulas_sal_cs = get_or_construct_data(df, dict_sal_cot_soc, years = range(1949, 2014))

    return (
        values_double, values_double_w_formula, values_complex, values_profits_societes, values_revenus_reste_du_monde
        )
# -*- coding: utf-8 -*-

import os
import pkg_resources

from ipp_macro_series_parser.config import Config
from ipp_macro_series_parser.comptes_nationaux.parser_main import get_comptes_nationaux_data
from ipp_macro_series_parser.data_extraction import get_or_construct_data
from ipp_macro_series_parser.comptes_nationaux.sheets_lists import variables_CN1, variables_CN2

parser = Config()
cn_directory = parser.get('data', 'cn_directory')
cn_hdf = parser.get('data', 'cn_hdf_directory')
cn_csv = parser.get('data', 'cn_csv_directory')
tests_directory = parser.get('data', 'tests_directory')

tests_data = os.path.join(
    pkg_resources.get_distribution('ipp-macro-series-parser').location,
    'ipp_macro_series_parser/tests/data')

df = get_comptes_nationaux_data(2013)

values_CN1, formulas_CN1 = get_or_construct_data(df, variables_CN1,
                                                 range(1949, 2014))
values_CN2, formulas_CN2 = get_or_construct_data(df, variables_CN2,
                                                 range(1949, 2014))
Example #15
0
def generate_CN6(year):
    df = get_tidy_data(year)
    variables_CN6 = generate_CN6_variables(year)
    values_CN6, formulas_CN6 = get_or_construct_data(df, variables_CN6,
                                                     range(1949, year + 1))
    return values_CN6, formulas_CN6
# -*- coding: utf-8 -*-


import os
import pandas
import pkg_resources
from ipp_macro_series_parser.config import Config

from ipp_macro_series_parser.comptes_nationaux.parser_main import get_comptes_nationaux_data
from ipp_macro_series_parser.data_extraction import (
    look_many, look_up, get_or_construct_value, get_or_construct_data)
from ipp_macro_series_parser.comptes_nationaux.sheets_lists import variables_CN1, variables_CN2

parser = Config(
    config_files_directory = os.path.join(pkg_resources.get_distribution('ipp-macro-series-parser').location)
    )
cn_directory = parser.get('data', 'cn_directory')
cn_hdf = parser.get('data', 'cn_hdf_directory')
cn_csv = parser.get('data', 'cn_csv_directory')
tests_directory = parser.get('data', 'tests_directory')

tests_data = os.path.join(
    pkg_resources.get_distribution('ipp-macro-series-parser').location,
    'ipp_macro_series_parser/tests/data')

df = get_comptes_nationaux_data(2013)

values_CN1, formulas_CN1 = get_or_construct_data(df, variables_CN1, range(1949, 2014))
values_CN2, formulas_CN2 = get_or_construct_data(df, variables_CN2, range(1949, 2014))
def generate_CN6(year):
    df = get_tidy_data(year)
    variables_CN6 = generate_CN6_variables(year)
    values_CN6, formulas_CN6 = get_or_construct_data(df, variables_CN6, range(1949, year + 1))
    return values_CN6, formulas_CN6