-
-
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
Cap state/local deductions as fraction of AGI #1711
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1711 +/- ##
======================================
Coverage 100% 100%
======================================
Files 37 37
Lines 3000 3000
======================================
Hits 3000 3000 Continue to review full report at Codecov.
|
taxcalc/current_law_policy.json
Outdated
@@ -1124,6 +1124,28 @@ | |||
"out_of_range_maxmsg": "", | |||
"out_of_range_action": "stop" | |||
}, | |||
|
|||
"_ID_StateLocalTax_crt": { | |||
"long_name": "Maximum state and local income and sales taxes deduction as a fraction of AGI.", |
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.
Could you take a look at _ID_Charity_crt_all
(https://github.com/open-source-economics/Tax-Calculator/blob/master/taxcalc/current_law_policy.json#L1262) and model your long_name
and description
off of that?
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'll be sure to model the ID_StateLocalTax_ct description after that parameter. Thanks!
taxcalc/functions.py
Outdated
c18300 = c18400 + c18500 | ||
if ID_StateLocalTax_crt < 1: | ||
c18300 = min(c18400 + c18500, | ||
ID_StateLocalTax_crt * max(c00100, 0)) |
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.
It looks to me like this line applies the cap to the combination of state and local income and sales taxes and state, local, and foreign real estate taxes. If that is your intent, the description of the parameters should be changed.
taxcalc/functions.py
Outdated
@@ -551,7 +554,11 @@ def ItemDed(e17500_capped, e18400_capped, e18500_capped, | |||
ID_StateLocalTax_c[MARS - 1]) | |||
c18500 = min((1. - ID_RealEstate_hc) * e18500_capped, | |||
ID_RealEstate_c[MARS - 1]) | |||
c18300 = c18400 + c18500 | |||
if ID_StateLocalTax_crt < 1: |
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 don't think you should end up needing a conditional here given that you set ID_StateLocalTax_crt at 1 under current law.
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.
Thanks for the comments, Matt! I included the conditional to take care of rare cases where one's state and local tax deductions exceed their AGI (I think this happens when someone can write off a large business loss). I had considered setting the parameter at 9e99 under current law, but this still wouldn't take care of cases of itemizers with negative AGI. I'm more than open to suggestions which take care of the if condition.
@derrickchoe, thanks for opening a PR to add this new feature! Just commented a few lines with suggestions. I also recommend adding a test that confirms setting |
Thanks for the suggestions, @MattHJensen. I've split the reform parameter into separate state/local and real estate tax deduction ceilings (as fractions of AGI). I've also set the baseline value for these parameters at 9e99, to take care of cases where one's deductions exceed their AGI. I'm having a bit of trouble understanding the issues with my current code. It seems like they stem from utils.py and calculate.py, neither of which I edited. Is this happening because my taxcalc branch is outdated? If so, I'd appreciate any insight you might have regarding solutions. Thanks! |
@derrickchoe said:
The coverage test is failing because the following two lines are untested.
But that's not your fault at all. I think you can ignore that coverage test failure because these two untested lines will be removed soon as part of the resolution in Tax-Calculator of PolicyBrain issue 73. @derrickchoe also asked:
No. You've done a good job. Your confusion is my fault for leaving two untested statements on the master branch. Sorry about that. |
@derrickchoe asked:
Again, I think the answer is no. But it is true that your branch does not include many recent changes on the master branch. So, for future reference, when you have a long-running development branch on your local computer, it is good practice to incorporate recent master changes into that branch. Do that by following the directions in Workflow Step 6 in the Contributor Guide. Thanks for your contribution to Tax-Calculator. |
@martinholmer, thanks for clarifying. I'll be sure to keep my branches updated with recent changes to the master branch in the future. I appreciate your help! |
@derrickchoe said:
Sure, no problem. There are a lot of moving parts involved in making even a modest contribution to Tax-Calculator. You've done very well. |
@MattHJensen, Is pull request #1711 ready to be merged? If so, go ahead and do that. |
@derrickchoe, this is excellent. Thanks. I do still recommend taking the additional step of adding a couple of tests to ensure that setting _ID_StateLocalTax_crt to 0 generates the same results as setting _ID_StateLocalTax_hc to 1 and same for real estate taxes. See https://github.com/open-source-economics/Tax-Calculator/blob/master/taxcalc/tests/test_calculate.py#L255 for an example. Alternatively, you could add these (4) reforms to |
@MattHJensen, I'm happy to add those tests (it will be valuable python practice as well). I'll make the changes to test_calculate.py and push them once I'm finished. Thanks! |
Thanks! |
I've just gotten to writing in some tests to make sure that capping state/local and real estate tax deductions at 0% of AGI is equivalent to a full haircut of those respective parameters. I wrote two functions in test_calculate.py, modeled after the code you linked. I'm not too familiar with tests-- are there any other files in taxcalc that I should edit so that the tests run properly? Thanks to both of you for your help, and sorry in advance if this info was covered somewhere in the tax calc documentation. |
@derrickchoe said:
Are you running Python 3.6 (rather than 2.7)? |
@derrickchoe, I just downloaded PR#1711 and changed the two Can you make those coding changes (like @codykallen suggested) and commit them and push them, so that I can merge #1711? We'll figure out later what sort of problems you're having with the tests. But both @GoFroggyRun and I have confirmed that the @codykallen revisions eliminate all the test failures that I reported yesterday. One additional question: when you are not on GitHub would you say your name is Derrick Choe? |
Thanks for asking-- yes my name is Derrick Choe. In response to:
I believe I am running Python 3.6. I did install a Python 2.7 environment via Anaconda, though. I'm still familiarizing myself with this, and I'll be sure to confirm exactly with what version of Python I'm running tax-calculator. In response to:
I'll pull up the test error message shortly. I also had a couple of issues with index.html (which I know I can fix by running make_index.py), as well as an error message related to a missing mock module, but I am told that these are not problems with the code itself. Lastly:
I'll be sure to do that now. Thanks again for all of your guidance with this pull request! |
Thanks, @derrickchoe, for the enhancements in pull request #1711. |
@martinholmer Also, thanks for merging the changes! |
@derrickchoe said:
I think your experience using Python 3.6 is the same as @MattHJensen's experience in #1715. There seems to be slight differences in the floating-point libraries in 2.7 vs 3.6, which produce slightly different numerical results. Can you post the So, you didn't do anything wrong and there's nothing to be sorry for. Thanks again for this contribution. |
@martinholmer I get the following results when I run the test using Python 3.6 (please let me know if the screenshots are too messy-- I'm not exactly sure how to best show failed tests): Is this the output that you are referring to? Looking at #1715, I am having a bit of trouble identifying exactly which differences are arising in the tests. |
@derrickchoe, Thanks for the info on test failures under Python 3.6. When you ran these tests your master branch was up-to-date, right? What's the difference between the |
While I had forgotten to update my master branch with changes in pull request #1773, I am getting the same test failures with my now-updated branch. The files In response to:
I'm not too familiar with diff utilities; I'm looking into installing and using one now. I'll send an update once I have a better understanding of the differences between the two files. Thanks! |
Thanks for the report on the test failure in |
Sorry in advance for the large screenshot. I'm getting differences between actual and expected output for the following numbers: 2018 AMT liability All of these differences are in the magnitude of 0.1 billion. Is it possible that this is a rounding error? |
@derrickchoe said:
Yes, I think it is just rounding error caused by differences in the floating-point libraries between Python 2.7 and Python 3.6. We have experienced this before with other tests that use the These test failures are happening even on the master branch, right? I'll try to generalize Thanks for all the help! |
@martinholmer
That's right; I ran these tests on my up-to-date master branch. Thanks for addressing this; I'll be sure to stay in the loop. I'm happy to run the tests whenever you think is appropriate. In the meantime, I'm glad that the recent additions to tax-calculator are running smoothly! I'm looking forward to making future contributions. |
@derrickchoe, Can you update your master branch to include several recent merges on GitHub, and then run all the tests including the Thanks so much in advance for helping me out on this. I don't have Python 3.6, so I'm thankful that you do and that you are willing to run the tests. |
I've updated my master branch, and I'm happy to help out-- given enough time working with tax-calculator, I hope to be able to help fix minor issues (such as these ones) in the future as well. |
@martinholmer
I should mention that I'm working on my personal computer now, and I noticed that a new test failed (I suspect it just has to do with my installation of taxcalc). In |
@derrickchoe said:
No its not common, but more on that below. My understanding is that subprocess is part of the standard, built-in Python library.
Nobody has ever reported this as a problem, but maybe that's because all the other developers are working on Macs and you're working on Windows. That's just a guess. Are you executing |
@martinholmer said:
I don't think that's the issue. I'm working on Windows, and I've never had this problem. |
@derrickchoe said:
Thanks for the helpful feedback. I'll fix these problems in my next pull request. And then I'm hoping you can run the tests again to see that all the test failures caused by numerical results differences have been eliminated. |
@codykallen said:
OK, I didn't know you were working on Windows, @codykallen. Are you using Python 2.7 or Python 3.6? So @derrickchoe's problem seems related to the Python 3.6 setup on his personal computer. |
@martinholmer, I use Python 2.7 on my work computer and Python 3.6 on my personal computer. |
@derrickchoe, Hopefully with the merge of PR #1789 there will be no small numerical differences when you run the full set of tests under Python 3.6. Thanks again for helping me out on this. |
@martinholmer in response to:
I'm executing py.test -n4 from the command line. Specifically, I'm using the taxcalc-dev environment in Anaconda Prompt. For some reason, the -n4 specification only works when working from this environment.
Thanks @codykallen for comparing with your installation-- I'll continue looking into this issue. I'm only failing the |
In response to:
I'm no longer running into any issues besides the one involving subprocess.py. Thanks for resolving all of the issues that I was running into using python 3.6! |
I'm adding a reform I made a few months back for a project. I created the parameter StateLocalTax_crt, which caps state/local tax deductions as a decimal fraction of agi.