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


Python Policy.convert_reform_dictionary方法代码示例

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


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

示例1: check_complete_reform_dict

# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import convert_reform_dictionary [as 别名]
def check_complete_reform_dict(reform_name, complete_reform_dict):
    """
    Check specified complete_reform_dict for reform with specified
    reform_name for valid year values and for valid number of replications.
    Raise error if there are any illegal values; otherwise
    return without doing anything or returning anything.
    """
    replications = complete_reform_dict['replications']
    start_year = complete_reform_dict['start_year']
    refspec = complete_reform_dict['specification']
    refdict = Policy.convert_reform_dictionary(refspec)
    if replications < 1 or replications > 1000:
        msg = 'reform {} has replications {} outside [1,1000] range'
        raise ValueError(msg.format(reform_name, replications))
    if start_year < MIN_START_YEAR or start_year > MAX_START_YEAR:
        msg = 'reform {} has start year {} outside [{},{}] range'
        raise ValueError(msg.format(reform_name, start_year,
                                    MIN_START_YEAR, MAX_START_YEAR))
    first_year = min(refdict)
    if first_year < start_year:
        msg = 'reform {} has first reform year {} before start year {}'
        raise ValueError(msg.format(reform_name, first_year, start_year))
    last_year = max(refdict)
    max_year = start_year + NUMBER_OF_YEARS
    if last_year > max_year:
        msg = 'reform {} has last reform year {} after last results year {}'
        raise ValueError(msg.format(reform_name, last_year, max_year))
    return
开发者ID:AHYANBusinessSolution,项目名称:Tax-Calculator,代码行数:30,代码来源:reforms.py

示例2: main

# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import convert_reform_dictionary [as 别名]
def main(reforms_json_filename, tracing):
    """
    Highest-level logic of reforms.py script.
    """
    # pylint: disable=too-many-locals

    # read specified reforms file and convert to a dictionary of reforms
    reforms_dict = read_reforms_json_file(reforms_json_filename)

    # check validity of each reform
    for ref in sorted(reforms_dict, key=int):
        check_complete_reform_dict(ref, reforms_dict[ref])

    # compute taxcalc results for current-law policy
    (itax_taxcalc_clp, ptax_taxcalc_clp) = taxcalc_clp_results()

    # check that selenium package and chromedriver program are available
    check_selenium_and_chromedriver()

    # process each reform in reforms_dict
    for ref in sorted(reforms_dict, key=int):
        syr = reforms_dict[ref]['start_year']
        refspec = reforms_dict[ref]['specification']
        refdict = Policy.convert_reform_dictionary(refspec)
        (itax_taxcalc,
         ptax_taxcalc) = taxcalc_results(syr, refdict,
                                         itax_taxcalc_clp,
                                         ptax_taxcalc_clp)
        for repl in range(reforms_dict[ref]['replications']):
            ref_repl = '{}-{:03d}'.format(ref, repl)
            if tracing:
                sys.stderr.write('==> {}\n'.format(ref_repl))
                sys.stderr.flush()
            (itax_taxbrain,
             ptax_taxbrain,
             taxbrain_output_url) = taxbrain_results(ref_repl, syr, refspec)
            if len(taxbrain_output_url) == 0:
                if tracing:
                    sys.stderr.write('    no TaxBrain output\n')
                    sys.stderr.flush()
                continue  # to top of replication loop
            else:
                if tracing:
                    sys.stderr.write('    got TaxBrain output\n')
                    sys.stderr.flush()
            check_for_differences(ref_repl, 'ITAX', taxbrain_output_url,
                                  itax_taxbrain, itax_taxcalc)
            check_for_differences(ref_repl, 'PTAX', taxbrain_output_url,
                                  ptax_taxbrain, ptax_taxcalc)

    # return no-error exit code
    return 0
开发者ID:salimfurth,项目名称:Tax-Calculator,代码行数:54,代码来源:reforms.py

示例3: main

# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import convert_reform_dictionary [as 别名]
def main(reforms_json_filename):
    """
    Highest-level logic of reforms.py script.
    """
    # read specified reforms file and convert to a dictionary of reforms
    reforms_dict = read_reforms_json_file(reforms_json_filename)

    # check validity of each reform
    for ref in sorted(reforms_dict):
        check_complete_reform_dict(ref, reforms_dict[ref])

    # compute taxcalc results for current-law policy
    (itax_taxcalc_clp, fica_taxcalc_clp) = taxcalc_clp_results()

    # check that selenium package and chromedriver program are available
    check_selenium_and_chromedriver()

    # process each reform in reforms_dict
    for ref in sorted(reforms_dict):
        syr = reforms_dict[ref]['start_year']
        refspec = reforms_dict[ref]['specification']
        refdict = Policy.convert_reform_dictionary(refspec)
        (itax_taxcalc,
         fica_taxcalc) = taxcalc_results(syr, refdict,
                                         itax_taxcalc_clp,
                                         fica_taxcalc_clp)
        for repl in range(reforms_dict[ref]['replications']):
            ref_repl = '{}-{:03d}'.format(ref, repl)
            (itax_taxbrain,
             fica_taxbrain,
             taxbrain_output_url) = taxbrain_results(ref_repl, syr, refspec)
            if len(taxbrain_output_url) == 0:  # no TaxBrain output
                continue  # to top of replication loop
            check_for_differences(ref_repl, 'ITAX', taxbrain_output_url,
                                  itax_taxbrain, itax_taxcalc)
            check_for_differences(ref_repl, 'FICA', taxbrain_output_url,
                                  fica_taxbrain, fica_taxcalc)

    # return no-error exit code
    return 0
开发者ID:AHYANBusinessSolution,项目名称:Tax-Calculator,代码行数:42,代码来源:reforms.py

示例4: test_convert_reform_dictionary

# 需要导入模块: from taxcalc import Policy [as 别名]
# 或者: from taxcalc.Policy import convert_reform_dictionary [as 别名]
def test_convert_reform_dictionary():
    with pytest.raises(ValueError):
        rdict = Policy.convert_reform_dictionary({2013: {'2013': [40000]}})
    with pytest.raises(ValueError):
        rdict = Policy.convert_reform_dictionary({'_II_em': {2013: [40000]}})
开发者ID:akshaya-trivedi,项目名称:Tax-Calculator,代码行数:7,代码来源:test_policy.py


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