Exemplo n.º 1
0
def test_multi_year_reform():
    """
    Test multi-year reform involving 1D and 2D parameters.
    """
    # specify dimensions of policy Policy object
    syr = 2013
    nyrs = Policy.DEFAULT_NUM_YEARS
    pol = Policy(start_year=syr)
    iratelist = pol.inflation_rates()
    ifactor = {}
    for i in range(0, nyrs):
        ifactor[syr + i] = 1.0 + iratelist[i]
    wratelist = pol.wage_growth_rates()
    wfactor = {}
    for i in range(0, nyrs):
        wfactor[syr + i] = 1.0 + wratelist[i]
    # confirm that parameters have current-law values
    assert_allclose(getattr(pol, '_EITC_c'),
                    Policy._expand_array(np.array(
                        [[487, 3250, 5372, 6044], [496, 3305, 5460, 6143],
                         [503, 3359, 5548, 6242], [506, 3373, 5572, 6269],
                         [510, 3400, 5616, 6318]],
                        dtype=np.float64),
                                         False,
                                         inflate=True,
                                         inflation_rates=iratelist,
                                         num_years=nyrs),
                    atol=0.01,
                    rtol=0.0)
    assert_allclose(getattr(pol, '_STD_Dep'),
                    Policy._expand_array(np.array(
                        [1000, 1000, 1050, 1050, 1050], dtype=np.float64),
                                         False,
                                         inflate=True,
                                         inflation_rates=iratelist,
                                         num_years=nyrs),
                    atol=0.01,
                    rtol=0.0)
    assert_allclose(getattr(pol, '_CTC_c'),
                    Policy._expand_array(np.array([1000] * 5 + [1400] * 4 +
                                                  [1500] * 3 + [1600] + [1000],
                                                  dtype=np.float64),
                                         False,
                                         inflate=False,
                                         inflation_rates=iratelist,
                                         num_years=nyrs),
                    atol=0.01,
                    rtol=0.0)
    # this parameter uses a different indexing rate
    assert_allclose(getattr(pol, '_SS_Earnings_c'),
                    Policy._expand_array(np.array(
                        [113700, 117000, 118500, 118500, 127200],
                        dtype=np.float64),
                                         False,
                                         inflate=True,
                                         inflation_rates=wratelist,
                                         num_years=nyrs),
                    atol=0.01,
                    rtol=0.0)
    # specify multi-year reform using a dictionary of year_provisions dicts
    reform = {
        2015: {
            '_CTC_c': [2000]
        },
        2016: {
            '_EITC_c': [[900, 5000, 8000, 9000]],
            '_II_em': [7000],
            '_SS_Earnings_c': [300000]
        },
        2017: {
            '_SS_Earnings_c': [500000],
            '_SS_Earnings_c_cpi': False
        },
        2019: {
            '_EITC_c': [[1200, 7000, 10000, 12000]],
            '_II_em': [9000],
            '_SS_Earnings_c': [700000],
            '_SS_Earnings_c_cpi': True
        }
    }
    # implement multi-year reform
    pol.implement_reform(reform)
    assert pol.current_year == syr
    # move policy Policy object forward in time so current_year is syr+2
    #   Note: this would be typical usage because the first budget year
    #         is greater than Policy start_year.
    pol.set_year(pol.start_year + 2)
    assert pol.current_year == syr + 2
    # confirm that actual parameters have expected post-reform values
    check_eitc_c(pol, reform, ifactor)
    check_ii_em(pol, reform, ifactor)
    check_ss_earnings_c(pol, reform, wfactor)
    check_ctc_c(pol, reform)
Exemplo n.º 2
0
def test_multi_year_reform():
    """
    Test multi-year reform involving 1D and 2D parameters.
    """
    # specify dimensions of policy Policy object
    syr = Policy.JSON_START_YEAR
    nyrs = Policy.DEFAULT_NUM_YEARS
    pol = Policy()
    iratelist = pol.inflation_rates()
    ifactor = {}
    for i in range(0, nyrs):
        ifactor[syr + i] = 1.0 + iratelist[i]
    wratelist = pol.wage_growth_rates()
    wfactor = {}
    for i in range(0, nyrs):
        wfactor[syr + i] = 1.0 + wratelist[i]
    # confirm that parameters have current-law values
    assert np.allclose(getattr(pol, '_EITC_c'),
                       Policy._expand_array(
                           np.array([[487, 3250, 5372, 6044],
                                     [496, 3305, 5460, 6143],
                                     [503, 3359, 5548, 6242],
                                     [506, 3373, 5572, 6269],
                                     [510, 3400, 5616, 6318],
                                     [519, 3461, 5716, 6431]],
                                    dtype=np.float64),
                           'real',
                           inflate=True,
                           inflation_rates=iratelist,
                           num_years=nyrs),
                       atol=0.01, rtol=0.0)
    assert np.allclose(getattr(pol, '_STD_Dep'),
                       Policy._expand_array(
                           np.array([1000, 1000, 1050, 1050, 1050, 1050],
                                    dtype=np.float64),
                           'real',
                           inflate=True,
                           inflation_rates=iratelist,
                           num_years=nyrs),
                       atol=0.01, rtol=0.0)
    assert np.allclose(getattr(pol, '_CTC_c'),
                       Policy._expand_array(
                           np.array([1000] * 5 + [2000] * 8 + [1000],
                                    dtype=np.float64),
                           'real',
                           inflate=False,
                           inflation_rates=iratelist,
                           num_years=nyrs),
                       atol=0.01, rtol=0.0)
    # this parameter uses a different indexing rate
    assert np.allclose(getattr(pol, '_SS_Earnings_c'),
                       Policy._expand_array(
                           np.array([113700, 117000, 118500, 118500, 127200,
                                     128400],
                                    dtype=np.float64),
                           'real',
                           inflate=True,
                           inflation_rates=wratelist,
                           num_years=nyrs),
                       atol=0.01, rtol=0.0)
    # specify multi-year reform using a param:year:value-fomatted dictionary
    reform = {
        'SS_Earnings_c': {2016: 300000,
                          2017: 500000,
                          2019: 700000},
        'SS_Earnings_c-indexed': {2017: False,
                                  2019: True},
        'CTC_c': {2015: 2000},
        'EITC_c': {2016: [900, 5000, 8000, 9000],
                   2019: [1200, 7000, 10000, 12000]},
        'II_em': {2016: 7000,
                  2019: 9000}
    }
    # implement multi-year reform
    pol.implement_reform(reform)
    assert pol.current_year == syr
    # move policy Policy object forward in time so current_year is syr+2
    #   Note: this would be typical usage because the first budget year
    #         is typically greater than Policy start_year.
    pol.set_year(pol.start_year + 2)
    assert pol.current_year == syr + 2
    # confirm that actual parameters have expected post-reform values
    check_eitc_c(pol, reform, ifactor)
    check_ii_em(pol, reform, ifactor)
    check_ss_earnings_c(pol, reform, wfactor)
    check_ctc_c(pol, reform)
def test_multi_year_reform():
    """
    Test multi-year reform involving 1D and 2D parameters.
    """
    # specify dimensions of policy Policy object
    syr = Policy.JSON_START_YEAR
    nyrs = Policy.DEFAULT_NUM_YEARS
    pol = Policy()
    iratelist = pol.inflation_rates()
    ifactor = {}
    for i in range(0, nyrs):
        ifactor[syr + i] = 1.0 + iratelist[i]
    wratelist = pol.wage_growth_rates()
    wfactor = {}
    for i in range(0, nyrs):
        wfactor[syr + i] = 1.0 + wratelist[i]
    # confirm that parameters have current-law values
    assert np.allclose(getattr(pol, '_EITC_c'),
                       Policy._expand_array(np.array(
                           [[487, 3250, 5372, 6044], [496, 3305, 5460, 6143],
                            [503, 3359, 5548, 6242], [506, 3373, 5572, 6269],
                            [510, 3400, 5616, 6318], [519, 3461, 5716, 6431],
                            [529, 3526, 5828, 6557]],
                           dtype=np.float64),
                                            'real',
                                            inflate=True,
                                            inflation_rates=iratelist,
                                            num_years=nyrs),
                       atol=0.01,
                       rtol=0.0)
    assert np.allclose(getattr(pol, '_STD_Dep'),
                       Policy._expand_array(np.array(
                           [1000, 1000, 1050, 1050, 1050, 1050, 1100],
                           dtype=np.float64),
                                            'real',
                                            inflate=True,
                                            inflation_rates=iratelist,
                                            num_years=nyrs),
                       atol=0.01,
                       rtol=0.0)
    assert np.allclose(getattr(pol, '_CTC_c'),
                       Policy._expand_array(np.array([1000] * 5 + [2000] * 8 +
                                                     [1000],
                                                     dtype=np.float64),
                                            'real',
                                            inflate=False,
                                            inflation_rates=iratelist,
                                            num_years=nyrs),
                       atol=0.01,
                       rtol=0.0)
    # this parameter uses a different indexing rate
    assert np.allclose(
        getattr(pol, '_SS_Earnings_c'),
        Policy._expand_array(np.array(
            [113700, 117000, 118500, 118500, 127200, 128400, 132900],
            dtype=np.float64),
                             'real',
                             inflate=True,
                             inflation_rates=wratelist,
                             num_years=nyrs),
        atol=0.01,
        rtol=0.0)
    # specify multi-year reform using a param:year:value-fomatted dictionary
    reform = {
        'SS_Earnings_c': {
            2016: 300000,
            2017: 500000,
            2019: 700000
        },
        'SS_Earnings_c-indexed': {
            2017: False,
            2019: True
        },
        'CTC_c': {
            2015: 2000
        },
        'EITC_c': {
            2016: [900, 5000, 8000, 9000],
            2019: [1200, 7000, 10000, 12000]
        },
        'II_em': {
            2016: 7000,
            2019: 9000
        }
    }
    # implement multi-year reform
    pol.implement_reform(reform)
    assert pol.current_year == syr
    # move policy Policy object forward in time so current_year is syr+2
    #   Note: this would be typical usage because the first budget year
    #         is typically greater than Policy start_year.
    pol.set_year(pol.start_year + 2)
    assert pol.current_year == syr + 2
    # confirm that actual parameters have expected post-reform values
    check_eitc_c(pol, reform, ifactor)
    check_ii_em(pol, reform, ifactor)
    check_ss_earnings_c(pol, reform, wfactor)
    check_ctc_c(pol, reform)