当前位置: 首页>>代码示例>>Python>>正文


Python Calculator.distribution_tables方法代码示例

本文整理汇总了Python中taxcalc.Calculator.distribution_tables方法的典型用法代码示例。如果您正苦于以下问题:Python Calculator.distribution_tables方法的具体用法?Python Calculator.distribution_tables怎么用?Python Calculator.distribution_tables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在taxcalc.Calculator的用法示例。


在下文中一共展示了Calculator.distribution_tables方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_distribution_tables

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import distribution_tables [as 别名]
def test_distribution_tables(cps_subsample):
    """
    Test distribution_tables method.
    """
    pol = Policy()
    recs = Records.cps_constructor(data=cps_subsample)
    calc1 = Calculator(policy=pol, records=recs)
    assert calc1.current_year == 2014
    calc1.calc_all()
    dt1, dt2 = calc1.distribution_tables(None, 'weighted_deciles')
    assert isinstance(dt1, pd.DataFrame)
    assert dt2 is None
    dt1, dt2 = calc1.distribution_tables(calc1, 'weighted_deciles')
    assert isinstance(dt1, pd.DataFrame)
    assert isinstance(dt2, pd.DataFrame)
    reform = {2014: {'_UBI_u18': [1000],
                     '_UBI_1820': [1000],
                     '_UBI_21': [1000]}}
    pol.implement_reform(reform)
    assert not pol.parameter_errors
    calc2 = Calculator(policy=pol, records=recs)
    calc2.calc_all()
    dt1, dt2 = calc1.distribution_tables(calc2, 'weighted_deciles')
    assert isinstance(dt1, pd.DataFrame)
    assert isinstance(dt2, pd.DataFrame)
开发者ID:codykallen,项目名称:Tax-Calculator,代码行数:27,代码来源:test_calculator.py

示例2: test_dec_graph_plots

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import distribution_tables [as 别名]
def test_dec_graph_plots(cps_subsample):
    pol = Policy()
    rec = Records.cps_constructor(data=cps_subsample)
    calc1 = Calculator(policy=pol, records=rec)
    year = 2020
    calc1.advance_to_year(year)
    reform = {
        'SS_Earnings_c': {year: 9e99},  # OASDI FICA tax on all earnings
        'FICA_ss_trt': {year: 0.107484}  # lower rate to keep revenue unchanged
    }
    pol.implement_reform(reform)
    calc2 = Calculator(policy=pol, records=rec)
    calc2.advance_to_year(year)
    assert calc1.current_year == calc2.current_year
    calc1.calc_all()
    calc2.calc_all()
    fig = calc1.decile_graph(calc2)
    assert fig
    dt1, dt2 = calc1.distribution_tables(calc2, 'weighted_deciles')
    dta = dec_graph_data(dt1, dt2, year,
                         include_zero_incomes=True,
                         include_negative_incomes=False)
    assert isinstance(dta, dict)
    dta = dec_graph_data(dt1, dt2, year,
                         include_zero_incomes=False,
                         include_negative_incomes=True)
    assert isinstance(dta, dict)
    dta = dec_graph_data(dt1, dt2, year,
                         include_zero_incomes=False,
                         include_negative_incomes=False)
    assert isinstance(dta, dict)
开发者ID:andersonfrailey,项目名称:Tax-Calculator,代码行数:33,代码来源:test_utils.py

示例3: test_dist_table_sum_row

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import distribution_tables [as 别名]
def test_dist_table_sum_row(cps_subsample):
    rec = Records.cps_constructor(data=cps_subsample)
    calc = Calculator(policy=Policy(), records=rec)
    calc.calc_all()
    # create three distribution tables and compare the ALL row contents
    tb1, _ = calc.distribution_tables(None, 'standard_income_bins')
    tb2, _ = calc.distribution_tables(None, 'soi_agi_bins')
    tb3, _ = calc.distribution_tables(None, 'weighted_deciles')
    tb4, _ = calc.distribution_tables(None, 'weighted_deciles',
                                      pop_quantiles=True)
    assert np.allclose(tb1.loc['ALL'], tb2.loc['ALL'])
    assert np.allclose(tb1.loc['ALL'], tb3.loc['ALL'])
    # make sure population count is larger than filing-unit count
    assert tb4.at['ALL', 'count'] > tb1.at['ALL', 'count']
    # make sure population table has same ALL row values as filing-unit table
    for col in ['count', 'count_StandardDed', 'count_ItemDed', 'count_AMT']:
        tb4.at['ALL', col] = tb1.at['ALL', col]
    assert np.allclose(tb1.loc['ALL'], tb4.loc['ALL'])
    # make sure population table has same ALL tax liabilities as diagnostic tbl
    dgt = calc.diagnostic_table(1)
    assert np.allclose([tb4.at['ALL', 'iitax'],
                        tb4.at['ALL', 'payrolltax']],
                       [dgt.at['Ind Income Tax ($b)', calc.current_year],
                        dgt.at['Payroll Taxes ($b)', calc.current_year]])
开发者ID:open-source-economics,项目名称:Tax-Calculator,代码行数:26,代码来源:test_utils.py

示例4: test_create_tables

# 需要导入模块: from taxcalc import Calculator [as 别名]
# 或者: from taxcalc.Calculator import distribution_tables [as 别名]

#.........这里部分代码省略.........
    if not np.allclose(diff[tabcol].values, expected,
                       atol=0.1, rtol=0.0):
        test_failure = True
        print('diff xdec', tabcol)
        for val in diff[tabcol].values:
            print('{:.1f},'.format(val))

    tabcol = 'pc_aftertaxinc'
    expected = [np.nan,
                np.nan,
                -0.3,
                -1.0,
                -0.7,
                -0.5,
                -0.7,
                -0.7,
                -0.7,
                -0.7,
                -0.7,
                -0.3,
                -0.6,
                -0.6,
                -0.3,
                -0.1]
    if not np.allclose(diff[tabcol].values, expected,
                       atol=0.1, rtol=0.0, equal_nan=True):
        test_failure = True
        print('diff xdec', tabcol)
        for val in diff[tabcol].values:
            print('{:.1f},'.format(val))

    # test creating various distribution tables

    dist, _ = calc2.distribution_tables(None, 'weighted_deciles')
    assert isinstance(dist, pd.DataFrame)
    tabcol = 'iitax'
    expected = [0.0,
                0.0,
                -1.8,
                2.0,
                5.0,
                6.7,
                18.0,
                26.1,
                35.2,
                82.7,
                148.8,
                734.1,
                1056.9,
                152.4,
                234.7,
                347.1]
    if not np.allclose(dist[tabcol].values, expected,
                       atol=0.1, rtol=0.0):
        test_failure = True
        print('dist xdec', tabcol)
        for val in dist[tabcol].values:
            print('{:.1f},'.format(val))

    tabcol = 'count_ItemDed'
    expected = [0.0,
                0.0,
                0.4,
                1.5,
                2.5,
                2.6,
开发者ID:open-source-economics,项目名称:Tax-Calculator,代码行数:70,代码来源:test_utils.py


注:本文中的taxcalc.Calculator.distribution_tables方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。