Skip to content

Commit

Permalink
Fix pylint W0201 and W0212 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Jan 5, 2025
1 parent ea8b9f7 commit 1d2df59
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 24 deletions.
4 changes: 2 additions & 2 deletions taxcalc.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Metadata-Version: 2.1
Name: taxcalc
Version: 4.4.0
Summary: taxcalc
Summary: Tax-Calculator
Home-page: https://github.com/PSLmodels/Tax-Calculator
Download-URL: https://github.com/PSLmodels/Tax-Calculator
License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
Expand All @@ -20,7 +20,7 @@ Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.26
Requires-Dist: pandas>=2.2
Requires-Dist: bokeh>=3.6
Requires-Dist: bokeh>=2.4
Requires-Dist: numba
Requires-Dist: paramtools>=0.19.0

Expand Down
2 changes: 1 addition & 1 deletion taxcalc.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
numpy>=1.26
pandas>=2.2
bokeh>=3.6
bokeh>=2.4
numba
paramtools>=0.19.0
2 changes: 2 additions & 0 deletions taxcalc/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,9 @@ def lines(text, num_indent_spaces, max_line_length=77):
label = _label
break
if label:
# pylint: disable=protected-access
lv = baseline._stateless_label_grid[label]
# pylint: enable=protected-access
lv = [
str(item) for item in lv
]
Expand Down
32 changes: 20 additions & 12 deletions taxcalc/tests/test_consumption.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,29 @@ def test_update_consumption():
expected_mpc_e20400 = np.full((consump.num_years,), 0.06)
expected_mpc_e20400[0] = 0.0
expected_mpc_e20400[1] = 0.05
assert np.allclose(consump._MPC_e20400,
expected_mpc_e20400,
rtol=0.0)
assert np.allclose(consump._MPC_e17500,
np.zeros((consump.num_years,)),
rtol=0.0)
assert np.allclose(
consump._MPC_e20400, # pylint: disable=protected-access
expected_mpc_e20400,
rtol=0.0
)
assert np.allclose(
consump._MPC_e17500, # pylint: disable=protected-access
np.zeros((consump.num_years,)),
rtol=0.0
)
expected_ben_mcare_value = np.full((consump.num_years,), 0.80)
expected_ben_mcare_value[0] = 1.0
expected_ben_mcare_value[1] = 0.75
assert np.allclose(consump._BEN_mcare_value,
expected_ben_mcare_value,
rtol=0.0)
assert np.allclose(consump._BEN_snap_value,
np.ones((consump.num_years,)),
rtol=0.0)
assert np.allclose(
consump._BEN_mcare_value, # pylint: disable=protected-access
expected_ben_mcare_value,
rtol=0.0
)
assert np.allclose(
consump._BEN_snap_value, # pylint: disable=protected-access
np.ones((consump.num_years,)),
rtol=0.0
)
consump.set_year(2015)
assert consump.current_year == 2015
assert consump.MPC_e20400 == 0.06
Expand Down
7 changes: 4 additions & 3 deletions taxcalc/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _extrapolate(self, year):
self, 'e00300', val * self.gfactors.factor_value('AINTS', year)
)

# test Recs class for incorrect instantiation
# test Recs class for incorrect instantiation:
with pytest.raises(ValueError):
Recs(data=[], start_year=2000,
gfactors=None, weights=None)
Expand All @@ -100,7 +100,7 @@ def _extrapolate(self, year):
with pytest.raises(ValueError):
Recs(data=cps_subsample, start_year=2000,
gfactors='', weights='')
# test Recs class for correct instantiation with no aging of data
# test Recs class for correct instantiation with no aging of data:
syr = 2014
rec = Recs(data=cps_subsample, start_year=syr,
gfactors=None, weights=None)
Expand Down Expand Up @@ -132,7 +132,8 @@ def _extrapolate(self, year):
assert sum_s006_in_syr_plus_one > sum_s006_in_syr
sum_e00300_in_syr_plus_one = getattr(rec, 'e00300').sum()
assert sum_e00300_in_syr_plus_one > sum_e00300_in_syr
# test private methods
# test private methods:
# pylint: disable=protected-access
rec._read_data(data=None)
rec._read_weights(weights=None)
with pytest.raises(ValueError):
Expand Down
3 changes: 3 additions & 0 deletions taxcalc/tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ def ret_everything(a, b, c, d, e, f):
f)


# pylint: disable=attribute-defined-outside-init


def test_magic_apply_jit():
"""Test docstring"""
pm = Foo()
Expand Down
11 changes: 6 additions & 5 deletions taxcalc/tests/test_growdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def test_update_and_apply_growdiff():
2016: 0.02}
}
gdiff.update_growdiff(diffs)
expected_wage_diffs = [0.00, 0.01, 0.01, 0.02, 0.02]
extra_years = gdiff.num_years - len(expected_wage_diffs)
expected_wage_diffs.extend([0.02] * extra_years)
assert np.allclose(gdiff._AWAGE, expected_wage_diffs, atol=0.0, rtol=0.0)
exp_wage_diffs = [0.00, 0.01, 0.01, 0.02, 0.02]
extra_years = gdiff.num_years - len(exp_wage_diffs)
exp_wage_diffs.extend([0.02] * extra_years)
act_wage_diffs = gdiff._AWAGE # pylint: disable=protected-access
assert np.allclose(act_wage_diffs, exp_wage_diffs, atol=0.0, rtol=0.0)
# apply growdiff to GrowFactors instance
gf = GrowFactors()
syr = gdiff.start_year
Expand All @@ -40,7 +41,7 @@ def test_update_and_apply_growdiff():
gdiff.apply_to(gfactors)
pir_pst = gfactors.price_inflation_rates(syr, lyr)
wgr_pst = gfactors.wage_growth_rates(syr, lyr)
expected_wgr_pst = [wgr_pre[i] + expected_wage_diffs[i]
expected_wgr_pst = [wgr_pre[i] + exp_wage_diffs[i]
for i in range(0, gdiff.num_years)]
assert np.allclose(pir_pre, pir_pst, atol=0.0, rtol=0.0)
assert np.allclose(wgr_pst, expected_wgr_pst, atol=1.0e-9, rtol=0.0)
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/tests/test_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def cmp_policy_objs(pol1, pol2, year_range=None, exclude=None):
else:
pol1.clear_state()
pol2.clear_state()
for param in pol1._data:
for param in pol1._data: # pylint: disable=protected-access
if exclude and param in exclude:
continue
v1 = getattr(pol1, param)
Expand Down

0 comments on commit 1d2df59

Please sign in to comment.