Skip to content

Commit 06e08f5

Browse files
authored
Merge pull request #46 from martinholmer/taxcalc-1.0-changes
Make changes so code can work with Tax-Calculator 1.0+
2 parents d603bdd + 17204a1 commit 06e08f5

5 files changed

Lines changed: 12 additions & 16 deletions

File tree

behresp/behavior.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def response(calc_1, calc_2, behavior, dump=False):
6262
And neither calc_1 nor calc_2 are affected by this response function.
6363
6464
The behavior argument is a dictionary returned from the Tax-Calculator
65-
Calculator.read_json_assumptions method.
65+
Calculator.read_json_parameters method.
6666
6767
The optional dump argument controls the number of variables included
6868
in the two returned DataFrame objects. When dump=False (its default

behresp/tests/test_behavior.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_default_response_function(cps_subsample):
5555
df2s = calc2s.dataframe(['iitax', 's006'])
5656
itax2s = round((df2s['iitax'] * df2s['s006']).sum() * 1e-9, 3)
5757
# ... calculate aggregate inctax using default behavior assumptions
58-
default_beh_dict = tc.Calculator.read_json_assumptions('{}')
58+
default_beh_dict = tc.Calculator.read_json_parameters('{}')
5959
_, df2d = response(calc1, calc2d, default_beh_dict, dump=True)
6060
itax2d = round((df2d['iitax'] * df2d['s006']).sum() * 1e-9, 3)
6161
assert np.allclose(itax2d, itax2s)
@@ -82,7 +82,7 @@ def test_nondefault_response_function(cps_subsample):
8282
"BE_inc": {"2018": -0.1},
8383
"BE_cg": {"2018": -0.79}
8484
}"""
85-
beh_dict = tc.Calculator.read_json_assumptions(beh_json)
85+
beh_dict = tc.Calculator.read_json_parameters(beh_json)
8686
# ... calculate behavioral response to reform
8787
pol = tc.Policy()
8888
calc1 = tc.Calculator(records=rec, policy=pol)
@@ -98,7 +98,7 @@ def test_nondefault_response_function(cps_subsample):
9898
itax2 = round((df2['iitax'] * df2['s006']).sum() * 1e-9, 3)
9999
del df1
100100
del df2
101-
assert np.allclose([itax1, itax2], [1422.156, 1368.489])
101+
assert np.allclose([itax1, itax2], [1441.722, 1385.666])
102102

103103

104104
def test_alternative_behavior_parameters(cps_subsample):
@@ -112,7 +112,7 @@ def test_alternative_behavior_parameters(cps_subsample):
112112
assert refyear >= 2018
113113
reform = {refyear: {'_II_em': [1500]}}
114114
# ... specify alternative set of behavior parameters
115-
beh_dict = tc.Calculator.read_json_assumptions(
115+
beh_dict = tc.Calculator.read_json_parameters(
116116
'{"BE_inc": {"2018": -0.10}}'
117117
)
118118
# ... use the alternative behavior parameters and dump option
@@ -198,7 +198,7 @@ def test_sub_effect_independence(stcg):
198198
recs = tc.Records(data=input_dataframe,
199199
start_year=refyear,
200200
gfactors=None, weights=None)
201-
beh_dict = tc.Calculator.read_json_assumptions(beh_json)
201+
beh_dict = tc.Calculator.read_json_parameters(beh_json)
202202
pol = tc.Policy()
203203
calc1 = tc.Calculator(records=recs, policy=pol)
204204
assert calc1.current_year == refyear

behresp/tests/test_tbi.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_parameter_errors():
1717
Test parameter_errors function.
1818
"""
1919
behv_json = '{"BE_sub": {"2018": -0.25}}'
20-
behv_dict = tc.Calculator.read_json_assumptions(behv_json)
20+
behv_dict = tc.Calculator.read_json_parameters(behv_json)
2121
errmsg = parameter_errors(behv_dict, 2013, 10)
2222
assert errmsg
2323

@@ -33,7 +33,7 @@ def test_behavioral_response(cps_subsample):
3333
reform_json = '{"policy": {"_II_em": {"2020": [1500]}}}'
3434
params = tc.Calculator.read_json_param_objects(reform_json, None)
3535
beh_json = '{"BE_sub": {"2013": 0.25}}'
36-
beh_dict = tc.Calculator.read_json_assumptions(beh_json)
36+
beh_dict = tc.Calculator.read_json_parameters(beh_json)
3737
# specify keyword arguments used in tbi function call
3838
kwargs = {
3939
'start_year': 2019,
@@ -44,8 +44,6 @@ def test_behavioral_response(cps_subsample):
4444
'policy': params['policy'],
4545
'growdiff_baseline': params['growdiff_baseline'],
4646
'growdiff_response': params['growdiff_response'],
47-
'behavior': params['behavior'],
48-
'growmodel': params['growmodel'],
4947
'consumption': params['consumption']
5048
},
5149
'behavior': beh_dict,
@@ -139,7 +137,7 @@ def test_fuzzing_and_returning_dict():
139137
reform_json = '{"policy": {"_II_em": {"2020": [1500]}}}'
140138
params = tc.Calculator.read_json_param_objects(reform_json, None)
141139
beh_json = '{"BE_sub": {"2013": 0.25}}'
142-
beh_dict = tc.Calculator.read_json_assumptions(beh_json)
140+
beh_dict = tc.Calculator.read_json_parameters(beh_json)
143141
# specify keyword arguments used in tbi function call
144142
kwargs = {
145143
'start_year': 2020,
@@ -150,8 +148,6 @@ def test_fuzzing_and_returning_dict():
150148
'policy': params['policy'],
151149
'growdiff_baseline': params['growdiff_baseline'],
152150
'growdiff_response': params['growdiff_response'],
153-
'behavior': params['behavior'],
154-
'growmodel': params['growmodel'],
155151
'consumption': params['consumption']
156152
},
157153
'behavior': beh_dict,

conda.recipe/meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ package:
55
requirements:
66
build:
77
- python
8-
- taxcalc
8+
- "taxcalc>=1.0"
99

1010
run:
1111
- python
12-
- taxcalc
12+
- "taxcalc>=1.0"
1313

1414
test:
1515
imports:

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ channels:
33
- PSLmodels
44
dependencies:
55
- python
6-
- taxcalc
6+
- "taxcalc>=1.0"

0 commit comments

Comments
 (0)