本文整理汇总了Python中taxcalc.Records.read_var_info方法的典型用法代码示例。如果您正苦于以下问题:Python Records.read_var_info方法的具体用法?Python Records.read_var_info怎么用?Python Records.read_var_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taxcalc.Records
的用法示例。
在下文中一共展示了Records.read_var_info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_calc_and_used_vars
# 需要导入模块: from taxcalc import Records [as 别名]
# 或者: from taxcalc.Records import read_var_info [as 别名]
def test_calc_and_used_vars(tests_path):
"""
Runs two kinds of tests on variables used in the calcfunctions.py file:
(1) Checks that each var in Records.CALCULATED_VARS is actually calculated
If test (1) fails, a variable in Records.CALCULATED_VARS was not
calculated in any function in the calcfunctions.py file. With the
exception of a few variables listed in this test, all
Records.CALCULATED_VARS must be calculated in the calcfunctions.py file.
(2) Check that each variable that is calculated in a function and
returned by that function is an argument of that function.
"""
# pylint: disable=too-many-locals
funcpath = os.path.join(tests_path, '..', 'calcfunctions.py')
gfd = GetFuncDefs()
fnames, fargs, cvars, rvars = gfd.visit(ast.parse(open(funcpath).read()))
# Test (1):
# .. create set of vars that are actually calculated in calcfunctions.py
all_cvars = set()
for fname in fnames:
if fname == 'BenefitSurtax':
continue # because BenefitSurtax is not really a function
all_cvars.update(set(cvars[fname]))
# .. add to all_cvars set variables calculated in Records class
all_cvars.update(set(['num', 'sep', 'exact']))
# .. add to all_cvars set variables calculated elsewhere
all_cvars.update(set(['mtr_paytax', 'mtr_inctax']))
all_cvars.update(set(['benefit_cost_total', 'benefit_value_total']))
# .. check that each var in Records.CALCULATED_VARS is in the all_cvars set
Records.read_var_info()
found_error1 = False
if not Records.CALCULATED_VARS <= all_cvars:
msg1 = ('all Records.CALCULATED_VARS not calculated '
'in calcfunctions.py\n')
for var in Records.CALCULATED_VARS - all_cvars:
found_error1 = True
msg1 += 'VAR NOT CALCULATED: {}\n'.format(var)
# Test (2):
faux_functions = ['EITCamount', 'ComputeBenefit', 'BenefitPrograms',
'BenefitSurtax', 'BenefitLimitation']
found_error2 = False
msg2 = 'calculated & returned variables are not function arguments\n'
for fname in fnames:
if fname in faux_functions:
continue # because fname is not a genuine function
crvars_set = set(cvars[fname]) & set(rvars[fname])
if not crvars_set <= set(fargs[fname]):
found_error2 = True
for var in crvars_set - set(fargs[fname]):
msg2 += 'FUNCTION,VARIABLE: {} {}\n'.format(fname, var)
# Report errors for the two tests:
if found_error1 and found_error2:
raise ValueError('{}\n{}'.format(msg1, msg2))
if found_error1:
raise ValueError(msg1)
if found_error2:
raise ValueError(msg2)
示例2: test_validity_of_name_lists
# 需要导入模块: from taxcalc import Records [as 别名]
# 或者: from taxcalc.Records import read_var_info [as 别名]
def test_validity_of_name_lists():
assert len(DIST_TABLE_COLUMNS) == len(DIST_TABLE_LABELS)
Records.read_var_info()
assert set(DIST_VARIABLES).issubset(Records.CALCULATED_VARS | {'s006'})
extra_vars_set = set(['num_returns_StandardDed',
'num_returns_ItemDed',
'num_returns_AMT'])
assert (set(DIST_TABLE_COLUMNS) - set(DIST_VARIABLES)) == extra_vars_set
示例3: set
# 需要导入模块: from taxcalc import Records [as 别名]
# 或者: from taxcalc.Records import read_var_info [as 别名]
MAX_SIZE = 100000 # maximum size of sample to draw from puf.csv
DEBUG = False # True implies no variable randomization or record sampling
TRACE = False # True implies tracing output written to stdout
# specify set of variables not included in xYY.csv file
if DEBUG:
DROP_VARS = set(['filer'])
else:
DROP_VARS = set(['filer', 's006', 'cmbtp',
'nu05', 'nu13', 'elderly_dependents',
'e09700', 'e09800', 'e09900', 'e11200'])
# specify set of variables whose values are not to be randomized
Records.read_var_info()
if DEBUG:
SKIP_VARS = Records.USABLE_READ_VARS
else:
SKIP_VARS = set(['RECID', 'MARS', 'DSI', 'MIDR', 'FLPDYR',
'age_head', 'age_spouse',
'nu18', 'n1820', 'n21',
'XTOT', 'EIC', 'n24', 'f2441',
'f6251'])
ANNUAL_DRIFT = 0.03
NORM_STD_DEV = 0.25
def randomize_data(xdf, taxyear, rnseed):
"""