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

Move logic for reading JSON parameter revisions to Parameter class #2312

Merged
merged 6 commits into from
May 6, 2019
Merged

Move logic for reading JSON parameter revisions to Parameter class #2312

merged 6 commits into from
May 6, 2019

Conversation

martinholmer
Copy link
Collaborator

This pull request simplifies the process of specifying and reading JSON reform files by moving the logic for reading JSON parameter revisions from the Calculator class to the Parameter class, which is a more sensible place for it. The simplification in specifying JSON policy reform files is that the top-level "policy" key is no longer mandatory. Also, when reading just a JSON policy reform file, the reading of it has been made easier by the addition of the Policy.read_json_reform method.

So, before this pull request a JSON reform file had to be specified this way:

{
    "policy": {
        "II_em": {"2022": 1000}
    }
}

but now it can be simplified to this:

{
    "II_em": {"2022": 1000}
}

Assume that the above JSON (either version) is in a file whose name is contained in the json string variable.

Before this pull request that JSON reform file had to be used this way:

pol = Policy()
param_dict = Calculator.read_json_param_objects(json, None)
pol.implement_reform(param_dict['policy'])

but now it is easier:

pol = Policy()
pol.implement_reform(Policy.read_json_reform(json))

Note that the old specification of JSON reform files still works and the old way of reading a JSON reform file is still available. It is just that now there are easier ways to do these things than by using the legacy code.

@codecov
Copy link

codecov bot commented May 1, 2019

Codecov Report

Merging #2312 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #2312   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          12      12           
  Lines        2839    2809   -30     
======================================
- Hits         2839    2809   -30
Impacted Files Coverage Δ
taxcalc/consumption.py 100% <100%> (ø) ⬆️
taxcalc/parameters.py 100% <100%> (ø) ⬆️
taxcalc/growdiff.py 100% <100%> (ø) ⬆️
taxcalc/calculator.py 100% <100%> (ø) ⬆️
taxcalc/policy.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2084369...7653c85. Read the comment docs.

@martinholmer martinholmer merged commit fd5df03 into PSLmodels:master May 6, 2019
@martinholmer martinholmer deleted the read-json-revision branch May 6, 2019 20:25
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.

1 participant