-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Provide simpler syntax to specify policy reforms and assumption updates #2292
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2292 +/- ##
==========================================
- Coverage 100% 99.78% -0.22%
==========================================
Files 12 12
Lines 2851 2839 -12
==========================================
- Hits 2851 2833 -18
- Misses 0 6 +6
Continue to review full report at Codecov.
|
There has been a substantial discussion of issue #2291, and now that conversation has widened to include the issue of whether or not to make Python reform dictionaries and JSON reform files have the same parameter, year, value order, and if so, which ordering should become the standard. I agree that this is an important topic, but I think it needs more discussion. Also, this pull request (#2292) is already quite large. So, I propose that #2292 be merged and the additional issue still being discussed can be handled in a follow-up pull request. Does that make sense? |
I said yesterday:
Actually, I think we have quickly reached a consensus on the ordering issue, so I'm going to implement the changes to the structure of Python reform/revision dictionaries in this pull request. |
"col_var": "", | ||
"col_label": [], | ||
"vi_name": "", | ||
"vi_vals": [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martinholmer, what does "vi" stand for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vi
stands for vector index
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. Thanks.
@martinholmer would you mind leaving #2292 open through Monday so that people have a chance to test it out? |
@@ -133,7 +133,7 @@ | |||
"indexable": true, | |||
"indexed": false, | |||
"vi_name": "MARS", | |||
"vi_vals": ["single", "joint", "separate", "headhousehold", "widow"], | |||
"vi_vals": ["single", "mjoint", "marsep", "headhh", "widow"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martinholmer These names are displayed over the parameter boxes on the webapp:
What do you think about choosing names that are more human readable like:
["single", "married joint", "married separate", "head household", "widow"]
The difference is only a few characters, and they are readable to those who are not familiar with the naming scheme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the new values for the vector indexes are more succinct and perfectly understandable to those using Tax-Calculator (or Tax-Brain) via Python programming or the tc
command-line tool. If you think users of the TaxBrain webapp need longer labels on the boxes, then by all means you should supply them with longer box labels. That's your call.
@martinholmer import taxcalc
import json
# 2.0 styled reform
ref = {
"policy": {
"STD": {"2018": [10001, 10000, 10000, 10000, 10000]},
"STD-indexed": {"2018": False},
}
}
ref_json = json.dumps(ref)
# Use read_json_param_objects to parse JSON reform
pol = taxcalc.Calculator.read_json_param_objects(ref_json, None)
# Note that keys are integers now.
print("parsed params: ", pol["policy"])
print("Parsed parameters load without errors.")
taxcalc.Policy().implement_reform(pol["policy"])
print("Parameters with string years throw an error.")
taxcalc.Policy().implement_reform(ref["policy"]) outputs:
It seems like |
Ok, I see. Glad my question was helpful. |
This pull request resolves issue #2291 by providing Tax-Calculator users with a less complicated syntax with which to specify policy reforms or updates to assumption parameters.
This pull request is the culmination of a series of enhancements to the Parameters class in recent pull requests #2281, #2282, #2283, #2284, #2285, #2289, and #2290. Only this #2292 pull request includes changes that make new versions of Tax-Calculator incompatible with earlier versions of Tax-Calculator. One of the major changes is the one discussed in issue #2291: changing the format of Python dictionaries supplied to the
Policy.implement_reform
,Consumption.update_consumption
, andGrowDiff.update_growdiff
methods so that the newparam : year : value
format is the same as used in JSON reform/assumption files. If you are specifying reforms with dictionaries (rather than in JSON files), you will have to edit the format of the dictionaries so that the oldyear : param : value
format is transformed into the newparam : year : value
format. See the newTax-Calculator/new_json.py
file for a script that may help you change your personal JSON reform files.Taken together, all these enhancements to the Parameters class mean that any other model that is already importing the Tax-Calculator package can automatically use this new syntax by creating its own classes derived from the Tax-Calculator Parameters class. An example, of the resulting simplification can be seen in Business-Taxation pull request 88 that specifies a Business-Taxation Policy class derived from the Tax-Calculator Parameters class in just a few lines of code.
This pull request also brings the name of the CPI offset policy parameter into line with other parameter names by changing it from
cpi_offset
toCPI_offset
. A new parameter name-change capability will notify users who forget to use the new name.The few lines of untested code cannot be tested until this pull request is merged. When it is merged, the
@pytest.mark.skip
decorators will be removed and those lines of code will be tested.