-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Change param_code to have multiple-statement (rather than single-expression) format #1107
Merged
Merged
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
bb27bb6
new_refundable_credit_code_function
MattHJensen b61eab1
Switch from eval() to exec() in new_refundable_credit_code_function.
martinholmer 05fc3f0
Add np.equal function to visible.
martinholmer 96c218f
Merge branch 'master' into pr-1103-alt
martinholmer 98544f9
Add Policy cpi method and use in functions.py file.
martinholmer ec49b73
Revise Policy cpi method to use assert rather than raise.
martinholmer 3b7a6d5
Add &&<param-code>&& to JSON reform file syntax.
martinholmer 6131848
Revise ALD_Investment_ec_base_code to be statement not expression.
martinholmer bc9b7d2
Merge in recent master changes.
martinholmer 47e6ea4
Remove duplicate entry in current_law_policy.json file.
martinholmer 0b97087
Rename parameters related to new refundable CTC code.
martinholmer 054f717
Change && to || in JSON reform files.
martinholmer bf44afb
Make re.sub pattern matching be non-greedy.
martinholmer 6502d8d
Rename/reorganize investment income exclusion base logic.
martinholmer e0949f2
Rename ALD_invinc as ALD_InvInc.
martinholmer bdd7ce5
Move logic from IITAX to CTC_new_nocode function.
martinholmer 4c45322
Add comments to test_calculate.py param_code section.
martinholmer d7e221b
Update taxcalc/reforms documentation.
martinholmer dffbc6c
Eliminate trailing whitespace in test_calculate.py file.
martinholmer b44d551
Streamline test_reforms.py logic.
martinholmer 19aeb39
Merge branch 'master' into pr-1103-alt
martinholmer 4274dfe
Merge branch 'master' into pr-1103-alt
martinholmer ae2d0d1
Merge branch 'master' into pr-1103-alt
martinholmer 8cf50c0
Merge branch 'master' into pr-1103-alt
martinholmer d1d27a6
Update test_dropq.py for ALD_InvInc_ renames.
martinholmer 3fc3609
Update var name in taxcalc/taxbrain files.
martinholmer fa71bf3
Merge branch 'master' into pr-1103-alt
martinholmer 6a3aec0
Expand error checking in Policy.cpi_for_param_code(); add tests.
martinholmer d0b1b48
Add test and remove Policy code that can never be reached.
martinholmer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,8 @@ class instance: Policy | |
2021: 0.0403, 2022: 0.0413, 2023: 0.0417, 2024: 0.0417, | ||
2025: 0.0415, 2026: 0.0416} | ||
|
||
VALID_PARAM_CODE_NAMES = set(['ALD_Investment_ec_base_code']) | ||
VALID_PARAM_CODE_NAMES = set(['ALD_InvInc_ec_base_code', | ||
'CTC_new_code']) | ||
|
||
PROHIBIT_PARAM_CODE = False | ||
|
||
|
@@ -142,6 +143,12 @@ def __init__(self, parameter_dict=None, | |
else: | ||
raise ValueError('inflation_rates is not None or a dictionary') | ||
|
||
cpi = 1.0 | ||
self._inflation_index = [cpi] | ||
for idx in range(0, num_years): | ||
cpi *= (1.0 + self._inflation_rates[idx]) | ||
self._inflation_index.append(cpi) | ||
|
||
if wage_growth_rates is None: # read default rates | ||
self._wage_growth_rates = [Policy.__wgrates[start_year + i] | ||
for i in range(0, num_years)] | ||
|
@@ -305,6 +312,26 @@ def scan_param_code(code): | |
msg += code | ||
raise ValueError(msg) | ||
|
||
def cpi(self, param_code_name): | ||
""" | ||
Return inflation index for current_year that has | ||
a value of one in first year param_code is active. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be "a value of one if first year param_code is active"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No but I expanded the docstring to give a more complete explanation. |
||
""" | ||
assert param_code_name in Policy.VALID_PARAM_CODE_NAMES | ||
active_name = '_{}_active'.format(param_code_name) | ||
active_param = getattr(self, active_name, None) | ||
zero_year = Policy.JSON_START_YEAR | ||
first_active_year = 9999 | ||
for idx in range(0, len(active_param)): | ||
if active_param[idx]: | ||
first_active_year = idx + zero_year | ||
break | ||
assert first_active_year <= Policy.LAST_BUDGET_YEAR | ||
cpi_current_year = self._inflation_index[self.current_year - zero_year] | ||
cpi_active_year = self._inflation_index[first_active_year - zero_year] | ||
cpi_rebased = cpi_current_year / cpi_active_year | ||
return cpi_rebased | ||
|
||
def current_law_version(self): | ||
""" | ||
Return Policy object same as self except with current-law policy. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 it would be good to add a unit test for this function. Also, it seems to me that the use case is specific enough that a more descriptive name should be used.
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.
Added tests and expanded function name for clarity.