Skip to content

Commit

Permalink
Merge pull request #1578 from martinholmer/fix-default-warnings
Browse files Browse the repository at this point in the history
Relax parameter value warning logic when min or max value is "default"
  • Loading branch information
martinholmer authored Oct 13, 2017
2 parents 621cdd9 + 12ed745 commit 27c1b14
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 3 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ Release 0.12.0 on 2017-??-??
by Martin Holmer]

**Bug Fixes**
- None
- Relax _STD and _STD_Dep minimum value warning logic
[[#1578](https://github.com/open-source-economics/Tax-Calculator/pull/1578)
by Martin Holmer]

Release 0.11.0 on 2017-09-21
----------------------------
Expand Down
9 changes: 9 additions & 0 deletions taxcalc/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ def _validate_parameter_values(self, parameters_set):
# pylint: disable=too-many-locals
# pylint: disable=too-many-branches
# pylint: disable=too-many-nested-blocks
rounding_error = 100.0
# above handles non-rounding of inflation-indexed parameter values
clp = self.current_law_version()
parameters = sorted(parameters_set)
syr = Policy.JSON_START_YEAR
Expand All @@ -387,6 +389,13 @@ def _validate_parameter_values(self, parameters_set):
if isinstance(vval, six.string_types):
if vval == 'default':
vvalue = getattr(clp, pname)
if vop == 'min':
vvalue -= rounding_error
# the follow branch can never be reached, so it
# is commented out because it can never be tested
# (see test_range_infomation in test_policy.py)
# --> elif vop == 'max':
# --> vvalue += rounding_error
else:
vvalue = getattr(self, vval)
else:
Expand Down
14 changes: 13 additions & 1 deletion taxcalc/tests/test_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,13 +798,17 @@ def test_range_infomation(tests_path):
range = param.get('range', None)
if range:
json_range_params.add(pname)
assert param['out_of_range_action'] in warn_stop_list
oor_action = param['out_of_range_action']
assert oor_action in warn_stop_list
range_items = range.items()
assert len(range_items) == 2
for vop, vval in range_items:
assert vop in min_max_list
if isinstance(vval, six.string_types):
if vval == 'default':
if vop != 'min' or oor_action != 'warn':
msg = 'USES DEFAULT FOR min OR FOR error'
assert pname == msg
continue
elif vval in clpdict:
if vop == 'min':
Expand Down Expand Up @@ -880,6 +884,14 @@ def test_validate_param_values_warnings_errors():
ref6 = {2026: {'_ID_BenefitSurtax_Switch': [[False, True, 0, 2, 0, 1, 0]]}}
pol6.implement_reform(ref6)
assert len(pol6.reform_errors) > 0
# raise stdded for everybody but widows, leaving widow value unchanged,
# which is the logic TaxBrain has been using at least until 2017-10-05
# when this "7" test was added
pol7 = Policy()
ref7 = {2013: {'_STD': [[20000, 20000, 20000, 20000, 12200]]}}
pol7.implement_reform(ref7)
assert pol7.reform_errors == ''
assert pol7.reform_warnings == ''


def test_indexing_rates_for_update():
Expand Down

0 comments on commit 27c1b14

Please sign in to comment.