diff --git a/taxcalc/behavior.json b/taxcalc/behavior.json index 4754f4ba8..4cc91cfc0 100644 --- a/taxcalc/behavior.json +++ b/taxcalc/behavior.json @@ -46,6 +46,6 @@ "row_label": ["2013"], "col_label": "", "value": [0.0], - "validations": {"max":0.0} + "validations": {"max": 0.0} } } diff --git a/taxcalc/behavior.py b/taxcalc/behavior.py index 69995db2e..459570731 100644 --- a/taxcalc/behavior.py +++ b/taxcalc/behavior.py @@ -84,12 +84,12 @@ def has_response(self): the current_year; returns false if all elasticities are zero. """ # pylint: disable=no-member - if (self.BE_sub == 0.0 and self.BE_inc == 0.0 and self.BE_cg == 0.0 and - self.BE_charity_itemizers == 0.0 and - self.BE_charity_non_itemizers == 0.0): - return False - else: - return True + all_zero = (self.BE_sub == 0.0 and + self.BE_inc == 0.0 and + self.BE_cg == 0.0 and + self.BE_charity_itemizers == 0.0 and + self.BE_charity_non_itemizers == 0.0) + return not all_zero def has_any_response(self): """ @@ -184,10 +184,9 @@ def response(calc_x, calc_y): new_ltcg = calc_x.records.p23250 * exp_term ltcg_chg = new_ltcg - calc_x.records.p23250 # calculate charitable giving effect - if (calc_y.behavior.BE_charity_itemizers == 0.0 and - calc_y.behavior.BE_charity_non_itemizers == 0.0): - charity_itemizers = np.zeros(calc_x.records.dim) - charity_non_itemizers = np.zeros(calc_x.records.dim) + no_charity_response = (calc_y.behavior.BE_charity_itemizers == 0.0 and + calc_y.behavior.BE_charity_non_itemizers == 0.0) + if no_charity_response: c_charity_chg = np.zeros(calc_x.records.dim) nc_charity_chg = np.zeros(calc_x.records.dim) else: @@ -198,14 +197,12 @@ def response(calc_x, calc_y): c_charity_mtr_x, c_charity_mtr_y = Behavior._mtr_xy( calc_x, calc_y, mtr_of='e19800', tax_type='combined') c_charity_price_pch = (((1. + c_charity_mtr_y) / - (1. + c_charity_mtr_x)) - - 1.) + (1. + c_charity_mtr_x)) - 1.) # non-cash: nc_charity_mtr_x, nc_charity_mtr_y = Behavior._mtr_xy( calc_x, calc_y, mtr_of='e20100', tax_type='combined') nc_charity_price_pch = (((1. + nc_charity_mtr_y) / - (1. + nc_charity_mtr_x)) - - 1.) + (1. + nc_charity_mtr_x)) - 1.) # identify itemizers under calc_y itemizer = np.where(calc_y.records.c04470 > calc_y.records._standard, @@ -241,6 +238,7 @@ def _validate_elasticity_values(self): """ Check that behavioral-response elasticities have valid values. """ + # pylint: disable=too-many-branches msg = '{} elasticity cannot be {} in year {}; value is {}' pos = 'positive' neg = 'negative' diff --git a/taxcalc/tests/test_taxcalcio.py b/taxcalc/tests/test_taxcalcio.py index 26ce30331..d7ec52acc 100644 --- a/taxcalc/tests/test_taxcalcio.py +++ b/taxcalc/tests/test_taxcalcio.py @@ -454,7 +454,7 @@ def test_ceeu_with_behavior(lumpsumreformfile, assumpfile2): assert tcio.tax_year() == taxyear -def test_bad_ctor_when_using_growmodel(lumpsumreformfile, assumpfile2): +def test_bad_ctor_with_growmodel(lumpsumreformfile, assumpfile2): """ Test improper TaxCalcIO constructor calls when using GrowModel analysis. """ @@ -513,7 +513,7 @@ def test_bad_assumption_file(reformfile1, assumpfile_bad1): exact_calculations=False) -def test_growmodel_analysis(reformfile1, assumpfile1, assumpfile2): +def test_growmodel_analysis(reformfile1, assumpfile1): """ Test TaxCalcIO.growmodel_analysis method with no output. """