Skip to content

Commit

Permalink
Make elderly_dependent plural; add Calculator.n65()
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Jul 18, 2018
1 parent af957d6 commit 8c15c6b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion puf_fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
DROP_VARS = set(['filer'])
else:
DROP_VARS = set(['filer', 's006', 'cmbtp',
'nu05', 'nu13', 'elderly_dependent',
'nu05', 'nu13', 'elderly_dependents',
'e09700', 'e09800', 'e09900', 'e11200'])

# specify set of variables whose values are not to be randomized
Expand Down
10 changes: 10 additions & 0 deletions taxcalc/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ def array(self, variable_name, variable_value=None):
setattr(self.__records, variable_name, variable_value)
return None

def n65(self):
"""
Return numpy ndarray containing the number of
individuals age 65+ in each filing unit.
"""
vdf = self.dataframe(['age_head', 'age_spouse', 'elderly_dependents'])
return ((vdf.age_head >= 65).astype(int) +
(vdf.age_spouse >= 65).astype(int) +
vdf.elderly_dependents)

def incarray(self, variable_name, variable_add):
"""
Add variable_add to named variable in embedded Records object.
Expand Down
6 changes: 3 additions & 3 deletions taxcalc/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def EI_PayrollTax(SS_Earnings_c, e00200, e00200p, e00200s,


@iterate_jit(nopython=True)
def DependentCare(nu13, elderly_dependent, earned,
def DependentCare(nu13, elderly_dependents, earned,
MARS, ALD_Dependents_thd, ALD_Dependents_hc,
ALD_Dependents_Child_c, ALD_Dependents_Elder_c,
care_deduction):
Expand All @@ -151,7 +151,7 @@ def DependentCare(nu13, elderly_dependent, earned,
Parameters
----------
nu13: Number of dependents under 13 years old
elderly_dependent: 1 if unit has an elderly dependent; 0 otherwise
elderly_dependents: number of elderly dependents
earned: Form 2441 earned income amount
MARS: Marital Status
ALD_Dependents_thd: Maximum income to qualify for deduction
Expand All @@ -167,7 +167,7 @@ def DependentCare(nu13, elderly_dependent, earned,
if earned <= ALD_Dependents_thd[MARS - 1]:
care_deduction = (((1. - ALD_Dependents_hc) * nu13 *
ALD_Dependents_Child_c) +
((1. - ALD_Dependents_hc) * elderly_dependent *
((1. - ALD_Dependents_hc) * elderly_dependents *
ALD_Dependents_Elder_c))
else:
care_deduction = 0.
Expand Down
4 changes: 2 additions & 2 deletions taxcalc/records_variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@
"form": {"2013-2016": "8863 Part I line 10 and 8863 Part III line 31"},
"availability": "taxdata_puf"
},
"elderly_dependent": {
"elderly_dependents": {
"type": "int",
"desc": "1 if filing unit has a dependent age 65+; otherwise 0",
"desc": "number of dependents age 65+ in filing unit excluding taxpayer and spouse",
"form": {"2013-2016": "imputed from CPS data; not used in tax law"},
"availability": "taxdata_puf, taxdata_cps"
},
Expand Down
6 changes: 6 additions & 0 deletions taxcalc/tests/test_calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,3 +973,9 @@ def test_privacy_of_embedded_objects(cps_subsample):
cyr = calc.__consumption.current_year
with pytest.raises(AttributeError):
cyr = calc.__behavior.current_year


def test_n65(cps_subsample):
recs = Records.cps_constructor(data=cps_subsample, no_benefits=True)
calc = Calculator(policy=Policy(), records=recs)
assert calc.n65().sum() > 1500

0 comments on commit 8c15c6b

Please sign in to comment.