Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing policy_current_law.json to incorporate ARPA.json values #2588

Merged
merged 17 commits into from
May 17, 2021

Conversation

amshoulders
Copy link
Contributor

This pull request edits the policy_current_law.json file to incorporate the ARPA.json parameter values.

cc @jdebacker

{
"year": 2021,
"value": 1000.00
},
{
"year": 2013,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This year should be 2022. See error message from tests about CTC_new_c:

The Value objects for CTC_new_c do not span the specified parameter space. Duplicate combinations:
14085
E           	[((2013,), 2)]

@jdebacker
Copy link
Member

jdebacker commented Apr 22, 2021

@amshoulders After fixing that year index in the JSON file, you will need to do a couple things to make sure tests pass:

  1. You'll need to update the csv files against which output are tested (since these cached files need to match the results produced from the model under current law). If you run the test suite locally, you'll see a message displayed with the names of the files to replace. Note that you will only be able to do this with the CPS-based files. I'll open a PR to your branch to update the PUF-based results.
  2. You'll need to update the the tests/test_reforms.test_round_trip_tcja_reform() function. This function starts with 2017 law and layers on tax law changes since to get to current law. If you look at some in-line comments there you can see how the TCJA and the CARES Act were added. You'll want to do similar with the ARPA law change. For the ARPA changes, you can either paste in the dictionary of parameter updates from the ARPA.json file (this is what is done for the CARES Act) OR you can point to the url for ARPA.json file in the PSL/Examples repository (the TCJA changes point to the JSON file within the Tax-Calculator repo - you'd do similar, but passing a URL rather than file path).

@amshoulders amshoulders changed the title (Ready for review) Editing policy_current_law.json to incorporate ARPA.json values [WIP] Editing policy_current_law.json to incorporate ARPA.json values Apr 26, 2021
@jdebacker
Copy link
Member

I'm don't understand the failure with test_parameters.py::test_json_file_contents[policy_current_law.json]. Here's the error message:

>           raise ValueError(failures)
247
E           ValueError: param:<ALD_BusinessLosses_c>; len(value_yrs)=9; known_years={2016, 2017, 2018, 2019, 2026, 2013, 2014, 2015}
248
E           param:<EITC_c>; len(value_yrs)=9; known_years={2016, 2017, 2018, 2019, 2013, 2014, 2015}
249
E           param:<EITC_ps>; len(value_yrs)=9; known_years={2016, 2017, 2018, 2019, 2013, 2014, 2015}
250
E           param:<EITC_InvestIncome_c>; len(value_yrs)=8; known_years={2016, 2017, 2018, 2019, 2013, 2014, 2015}
251
E           param:<CTC_new_ps>; len(value_yrs)=9; known_years={2016, 2017, 2018, 2019, 2013, 2014, 2015}

But the ALD_BusinessLosses_c looks like it is defined correctly in my view. I thought gaps in years would be filled in by the extrapolation in ParamTools. Can anyone let me and @amshoulders know what the issue is here? Thanks!

cc @hdoupe

@jdebacker
Copy link
Member

@hdoupe I the issue here with the ALD_BusinessLosses_c parameter (highlighted in comment above) an instance where we need to use the clobber function you demonstrated in the PSL Demo Day today?

@hdoupe
Copy link
Collaborator

hdoupe commented May 4, 2021

@jdebacker sorry I just saw this. It looks like this test only loads the JSON file and does not feed it through ParamTools for extrapolation:

with open(os.path.join(tests_path, "..", fname)) as f:
allparams = json.loads(f.read())
for pname in allparams:
if pname == "schema":
continue
# check that param contains required keys
param = allparams[pname]
# check that indexable and indexed are False in many files
if fname != 'policy_current_law.json':
assert param.get('indexable', False) is False
assert param.get('indexed', False) is False
# check that indexable is True when indexed is True
if param.get('indexed', False) and not param.get('indexable', False):
msg = 'param:<{}>; indexed={}; indexable={}'
fail = msg.format(pname,
param.get('indexed', False),
param.get('indexable', False))
failures += fail + '\n'
# check that indexable param has value_type float
if param.get('indexable', False) and param['type'] != 'float':
msg = 'param:<{}>; type={}; indexable={}'
fail = msg.format(pname, param['type'],
param.get('indexable', False))
failures += fail + '\n'
# ensure that indexable is False when value_type is not real
if param.get('indexable', False) and param['type'] != 'float':
msg = 'param:<{}>; indexable={}; type={}'
fail = msg.format(pname,
param.get('indexable', False),
param['value_type'])
failures += fail + '\n'
# check that indexed parameters have all known years in value_yrs list
# (form_parameters are those whose value is available only on IRS form)
form_parameters = []
if param.get('indexed', False):
defined_years = set(
vo["year"] for vo in param["value"]
)
error = False
if pname in long_params:
exp_years = long_known_years
else:
exp_years = known_years
if pname in form_parameters:
if defined_years != exp_years:
error = True
else:
if defined_years != exp_years:
error = True

Maybe a better test would be:

  • check the min / max years of the JSON contents
  • load JSON with appropriate class (tc.Policy, etc.)
  • make sure years are filled in correctly

@jdebacker
Copy link
Member

Ah - thanks @hdoupe! I'll take a stab at rewriting this test.

@codecov
Copy link

codecov bot commented May 11, 2021

Codecov Report

Merging #2588 (5133def) into master (cb0297d) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2588   +/-   ##
=======================================
  Coverage   98.46%   98.46%           
=======================================
  Files          14       14           
  Lines        2611     2611           
=======================================
  Hits         2571     2571           
  Misses         40       40           
Flag Coverage Δ
unittests 98.46% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@jdebacker
Copy link
Member

@amshoulders This PR looks good to me -- thanks for your work! You can go ahead and remove the [WIP] from the title.

@MattHJensen I have one question confirming that you are ok with a change to a unit test, but after that, this is ready for your final review.

@amshoulders amshoulders changed the title [WIP] Editing policy_current_law.json to incorporate ARPA.json values Editing policy_current_law.json to incorporate ARPA.json values May 13, 2021
taxcalc/tests/test_parameters.py Outdated Show resolved Hide resolved
taxcalc/tests/test_parameters.py Outdated Show resolved Hide resolved
Co-authored-by: Henry "Hank" Doupe <henrymdoupe@gmail.com>
Co-authored-by: Henry "Hank" Doupe <henrymdoupe@gmail.com>
@MattHJensen
Copy link
Contributor

Thanks very much @amshoulders for the PR, @jdebacker for your review and contributions, and @hdoupe for your review and suggestions. Merging.

@MattHJensen MattHJensen merged commit c3a86b6 into PSLmodels:master May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants