Skip to content

Commit

Permalink
Fix pylint C0115 and C0116 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Jan 4, 2025
1 parent 068bc14 commit 7352558
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 13 deletions.
19 changes: 17 additions & 2 deletions taxcalc/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,23 @@ def get_index_rate(self, param, label_to_extend_val):

def set_rates(self):
"""
This method is implemented by classes inheriting
Parameters.
This method is implemented by classes inheriting Parameters.
"""
raise NotImplementedError()

def wage_growth_rates(self, year=None):
"""
Return wage growth rates used in parameter indexing.
"""
if year is not None:
syr = max(self.start_year, self._gfactors.first_year)
return self._wage_growth_rates[year - syr]
return self._wage_growth_rates or []

def inflation_rates(self, year=None):
"""
Return price inflation rates used in parameter indexing.
"""
if year is not None:
syr = max(self.start_year, self._gfactors.first_year)
return self._inflation_rates[year - syr]
Expand Down Expand Up @@ -665,30 +670,37 @@ def _update(self, revision, print_warnings, raise_errors):
)

def set_year(self, year):
"""Specify parameter year"""
self.set_state(year=year)

@property
def current_year(self):
"""Propery docstring"""
return self.label_grid["year"][0]

@property
def start_year(self):
"""Propery docstring"""
return self._stateless_label_grid["year"][0]

@property
def end_year(self):
"""Propery docstring"""
return self._stateless_label_grid["year"][-1]

@property
def num_years(self):
"""Propery docstring"""
return self.end_year - self.start_year + 1

@property
def parameter_warnings(self):
"""Propery docstring"""
return self.errors or {}

@property
def parameter_errors(self):
"""Propery docstring"""
return self.errors or {}

@staticmethod
Expand Down Expand Up @@ -760,6 +772,9 @@ def convert_year_to_int(syr_dict):
return convert_year_to_int(single_dict)

def metadata(self):
"""
Return parameter specification.
"""
return self.specification(meta_data=True, use_state=False)

@staticmethod
Expand Down
18 changes: 8 additions & 10 deletions taxcalc/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,55 @@

@pytest.fixture
def skip_jit(monkeypatch):
"""Fixture docstring"""
monkeypatch.setenv("TESTING", "True")
yield


@pytest.fixture(scope='session')
def tests_path():
"""Fixture docstring"""
return os.path.abspath(os.path.dirname(__file__))


@pytest.fixture(scope='session')
def cps_path(tests_path):
"""Fixture docstring"""
return os.path.join(tests_path, '..', 'cps.csv.gz')


@pytest.fixture(scope='session')
def cps_fullsample(cps_path):
"""Fixture docstring"""
return pandas.read_csv(cps_path)


@pytest.fixture(scope='session')
def cps_subsample(cps_fullsample):
"""Fixture docstring"""
# draw smaller cps.csv subsample than in test_cpscsv.py
return cps_fullsample.sample(frac=0.01, random_state=123456789)


@pytest.fixture(scope='session')
def puf_path(tests_path):
"""Fixture docstring"""
return os.path.join(tests_path, '..', '..', 'puf.csv')


@pytest.fixture(scope='session')
def puf_fullsample(puf_path):
"""Fixture docstring"""
return pandas.read_csv(puf_path)


@pytest.fixture(scope='session')
def puf_subsample(puf_fullsample):
"""Fixture docstring"""
# draw same puf.csv subsample as in test_pufcsv.py
return puf_fullsample.sample(frac=0.05, random_state=2222)


@pytest.fixture(scope='session')
def tmd_path(tests_path):
return os.path.join(tests_path, '..', '..', 'tmd.csv')


@pytest.fixture(scope='session')
def tmd_fullsample(tmd_path):
return pandas.read_csv(tmd_path)


@pytest.fixture(scope='session', name='test_reforms_init')
def fixture_test_reforms(tests_path):
"""
Expand Down
7 changes: 7 additions & 0 deletions taxcalc/tests/test_consumption.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@


def test_start_year_consistency():
"""Test docstring"""
assert Consumption.JSON_START_YEAR == Policy.JSON_START_YEAR


def test_validity_of_consumption_vars_set():
"""Test docstring"""
records_varinfo = Records(data=None)
assert Consumption.RESPONSE_VARS.issubset(records_varinfo.USABLE_READ_VARS)
useable_vars = set(['housing', 'snap', 'tanf', 'vet', 'wic',
Expand All @@ -25,6 +27,7 @@ def test_validity_of_consumption_vars_set():


def test_update_consumption():
"""Test docstring"""
consump = Consumption()
consump.update_consumption({})
revision = {
Expand Down Expand Up @@ -61,6 +64,7 @@ def test_update_consumption():


def test_incorrect_update_consumption():
"""Test docstring"""
with pytest.raises(paramtools.ValidationError):
Consumption().update_consumption([])
with pytest.raises(paramtools.ValidationError):
Expand All @@ -78,6 +82,7 @@ def test_incorrect_update_consumption():


def test_future_update_consumption():
"""Test docstring"""
consump = Consumption()
assert consump.current_year == consump.start_year
assert consump.has_response() is False
Expand All @@ -101,6 +106,7 @@ def test_future_update_consumption():


def test_consumption_default_data():
"""Test docstring"""
consump = Consumption()
pdata = consump.specification(meta_data=True, ignore_state=True)
for pname in pdata.keys():
Expand All @@ -111,6 +117,7 @@ def test_consumption_default_data():


def test_consumption_response(cps_subsample):
"""Test docstring"""
# pylint: disable=too-many-locals
consump = Consumption()
mpc = 0.5
Expand Down
Loading

0 comments on commit 7352558

Please sign in to comment.