示例#1
0
def test_parameters_get_default_start_year():
    paramdata = Policy.default_data(metadata=True, start_year=2015)
    # 1D data, has 2015 values
    meta_II_em = paramdata['_II_em']
    assert meta_II_em['start_year'] == 2015
    assert meta_II_em['row_label'] == ['2015', '2016']
    assert meta_II_em['value'] == [4000, 4050]
    # 2D data, has 2015 values
    meta_std_aged = paramdata['_STD_Aged']
    assert meta_std_aged['start_year'] == 2015
    assert meta_std_aged['row_label'] == ['2015', '2016']
    assert meta_std_aged['value'] == [[1550, 1250, 1250, 1550, 1550, 1250],
                                      [1550, 1250, 1250, 1550, 1550, 1250]]
    # 1D data, doesn't have 2015 values, is CPI inflated
    meta_amt_thd_marrieds = paramdata['_AMT_thd_MarriedS']
    assert meta_amt_thd_marrieds['start_year'] == 2015
    assert meta_amt_thd_marrieds['row_label'] == ['2015']
    # Take the 2014 parameter value and multiply by inflation for that year
    should_be = 41050 * (1.0 + Policy.default_inflation_rates()[2014])
    meta_amt_thd_marrieds['value'] == should_be
    # 1D data, doesn't have 2015 values, is not CPI inflated
    meta_kt_c_age = paramdata['_KT_c_Age']
    assert meta_kt_c_age['start_year'] == 2015
    assert meta_kt_c_age['row_label'] == ['2015']
    assert meta_kt_c_age['value'] == [24]
def test_parameters_get_default_start_year():
    paramdata = Policy.default_data(metadata=True, start_year=2015)
    # 1D data, has 2015 values
    meta_II_em = paramdata['_II_em']
    assert meta_II_em['start_year'] == 2015
    assert meta_II_em['row_label'] == ['2015', '2016']
    assert meta_II_em['value'] == [4000, 4050]
    # 2D data, has 2015 values
    meta_std_aged = paramdata['_STD_Aged']
    assert meta_std_aged['start_year'] == 2015
    assert meta_std_aged['row_label'] == ['2015', '2016']
    assert meta_std_aged['value'] == [[1550, 1250, 1250, 1550, 1550, 1250],
                                      [1550, 1250, 1250, 1550, 1550, 1250]]
    # 1D data, doesn't have 2015 values, is CPI inflated
    meta_amt_thd_marrieds = paramdata['_AMT_thd_MarriedS']
    assert meta_amt_thd_marrieds['start_year'] == 2015
    assert meta_amt_thd_marrieds['row_label'] == ['2015']
    # Take the 2014 parameter value and multiply by inflation for that year
    should_be = 41050 * (1.0 + Policy.default_inflation_rates()[2014])
    meta_amt_thd_marrieds['value'] == should_be
    # 1D data, doesn't have 2015 values, is not CPI inflated
    meta_kt_c_age = paramdata['_KT_c_Age']
    assert meta_kt_c_age['start_year'] == 2015
    assert meta_kt_c_age['row_label'] == ['2015']
    assert meta_kt_c_age['value'] == [24]
示例#3
0
def test_parameters_get_default_start_year():
    paramdata = Policy.default_data(metadata=True, start_year=2015)
    # 1D data, has 2015 values
    meta_II_em = paramdata['_II_em']
    assert meta_II_em['start_year'] == 2015
    assert meta_II_em['row_label'] == [str(cyr) for cyr in range(2015, 2027)]
    assert meta_II_em['value'] == [4000, 4050, 4050] + [0] * 8 + [4883]
    # 2D data, has 2015 values
    meta_std_aged = paramdata['_STD_Aged']
    assert meta_std_aged['start_year'] == 2015
    assert meta_std_aged['row_label'] == ['2015', '2016', '2017']
    assert meta_std_aged['value'] == [[1550, 1250, 1250, 1550, 1550],
                                      [1550, 1250, 1250, 1550, 1550],
                                      [1550, 1250, 1250, 1550, 1550]]
    # 1D data, doesn't have 2015 values, is not CPI inflated
    meta_kt_c_age = paramdata['_AMT_KT_c_Age']
    assert meta_kt_c_age['start_year'] == 2015
    assert meta_kt_c_age['row_label'] == ['2015']
    assert meta_kt_c_age['value'] == [24]
示例#4
0
def test_parameters_get_default_data():
    paramdata = Policy.default_data(metadata=True)
    # 1D data, has 2013+ values
    meta_II_em = paramdata['_II_em']
    assert meta_II_em['start_year'] == 2013
    assert meta_II_em['row_label'] == [str(cyr) for cyr in range(2013, 2027)]
    expval = [3900, 3950, 4000, 4050, 4050] + [0] * 8 + [4883]
    assert meta_II_em['value'] == expval
    # 2D data, has 2013+ values
    meta_std_aged = paramdata['_STD_Aged']
    assert meta_std_aged['start_year'] == 2013
    explabels = ['2013', '2014', '2015', '2016', '2017']
    assert meta_std_aged['row_label'] == explabels
    assert meta_std_aged['value'] == [[1500, 1200, 1200, 1500, 1500],
                                      [1550, 1200, 1200, 1550, 1550],
                                      [1550, 1250, 1250, 1550, 1550],
                                      [1550, 1250, 1250, 1550, 1550],
                                      [1550, 1250, 1250, 1550, 1550]]
    # 1D data, has only 2013 values because is not CPI inflated
    meta_kt_c_age = paramdata['_AMT_KT_c_Age']
    assert meta_kt_c_age['start_year'] == 2013
    assert meta_kt_c_age['row_label'] == ['2013']
    assert meta_kt_c_age['value'] == [24]
示例#5
0
def test_parameters_get_default():
    paramdata = Policy.default_data()
    assert paramdata['_CDCC_ps'] == [15000]
def test_parameters_get_default():
    paramdata = Policy.default_data()
    assert paramdata['_CDCC_ps'] == [15000]
示例#7
0
def fixture_allparams():
    """
    Return metadata for current law parameters
    """
    return Policy.default_data(metadata=True)
示例#8
0
            '_ID_prt': [0.03],
            '_ID_crt': [0.8]
        }
    }
    return _reform_xx


@pytest.fixture(scope='module', name='sorted_param_names')
def fixture_sorted_param_names(allparams):
    """
    Fixture for storing a sorted parameter list
    """
    return sorted(list(allparams.keys()))


NPARAMS = len(Policy.default_data())
BATCHSIZE = 10
BATCHES = int(np.floor(NPARAMS / BATCHSIZE)) + 1


@pytest.fixture(scope='module',
                name='allparams_batch',
                params=[i for i in range(0, BATCHES)])
def fixture_allparams_batch(request, allparams, sorted_param_names):
    """
    Fixture for grouping Tax-Calculator parameters

    Experiments indicated that there is some overhead when you run
    `test_compatible_data` on each parameter individually. Suppose it takes X
    amount of time to set up the test data for `test_compatible_data` and Y
    amount of time to run `test_compatible_data` on each parameter wihtout