Skip to content

Commit

Permalink
Fix GrowFactors.update method logic
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Jun 14, 2024
1 parent 951f789 commit df2cc75
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/contributing/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Python

Tax-Calculator currently runs on Python 3.9, 3.10, 3.11, and 3.12.
We generally support at least three of the latest major Python releases.
We generally support at least the three latest major Python releases.

Updating the Python version requires modifying the following files:
* `.github/workflows/*.yml`
Expand Down
14 changes: 5 additions & 9 deletions taxcalc/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,17 @@ def __init__(self, policy=None, records=None, verbose=False,
print(' ' +
var)
current_year_is_data_year = (
self.__records.current_year == self.__records.data_year
)
extrapolating = self.__records.current_year > self.__records.data_year
self.__records.current_year == self.__records.data_year)
if sync_years and current_year_is_data_year:
if verbose:
print('You loaded data for ' +
str(self.__records.data_year) + '.')
while self.__records.current_year < self.__policy.current_year:
self.__records.increment_year()
if verbose and extrapolating:
print( # pragma: no cover
'Tax-Calculator startup automatically ' +
'extrapolated your data to ' +
str(self.__records.current_year) + '.'
)
if verbose:
print('Tax-Calculator startup automatically ' +
'extrapolated your data to ' +
str(self.__records.current_year) + '.')
else:
if verbose:
print('Tax-Calculator startup did not ' +
Expand Down
7 changes: 3 additions & 4 deletions taxcalc/growfactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def update(self, name, year, diff):
msg = 'cannot update growfactors after they have been used'
raise ValueError(msg)
assert name in GrowFactors.VALID_NAMES
assert year >= self.first_year
assert year <= self.last_year
assert isinstance(diff, float)
self.gfdf.loc[year, name] += diff
if year >= self.first_year and year <= self.last_year:
assert isinstance(diff, float)
self.gfdf.loc[year, name] += diff
3 changes: 2 additions & 1 deletion taxcalc/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def cps_constructor(data=None,

@staticmethod
def tmd_constructor(data, # path to tmd.csv file or dataframe
gfactors=TMD_GROWFACTORS_FILENAME,
exact_calculations=False): # pragma: no cover
"""
Static method returns a Records object instantiated with TMD
Expand All @@ -241,7 +242,7 @@ def tmd_constructor(data, # path to tmd.csv file or dataframe
weights = os.path.join(Records.CODE_PATH, Records.TMD_WEIGHTS_FILENAME)
return Records(data=data,
start_year=Records.TMDCSV_YEAR,
gfactors=Records.TMD_GROWFACTORS_FILENAME,
gfactors=gfactors,
weights=weights,
adjust_ratios=Records.TMD_RATIOS_FILENAME,
exact_calculations=exact_calculations)
Expand Down

0 comments on commit df2cc75

Please sign in to comment.