diff --git a/taxcalc/calculator.py b/taxcalc/calculator.py index d0b92a598..14129d585 100644 --- a/taxcalc/calculator.py +++ b/taxcalc/calculator.py @@ -105,7 +105,7 @@ def __init__(self, policy=None, records=None, verbose=False, if self.__policy.current_year < self.__records.data_year: self.__policy.set_year(self.__records.data_year) if consumption is None: - self.__consumption = Consumption() + self.__consumption = Consumption(policy.nyrs) elif isinstance(consumption, Consumption): self.__consumption = copy.deepcopy(consumption) else: diff --git a/taxcalc/consumption.py b/taxcalc/consumption.py index 0be9ea904..bfc12b4e1 100644 --- a/taxcalc/consumption.py +++ b/taxcalc/consumption.py @@ -28,14 +28,16 @@ class instance: Consumption """ JSON_START_YEAR = Policy.JSON_START_YEAR - DEFAULT_NUM_YEARS = Policy.DEFAULT_NUM_YEARS + NUM_YEARS = Policy.NUM_YEARS DEFAULTS_FILE_NAME = 'consumption.json' DEFAULTS_FILE_PATH = os.path.abspath(os.path.dirname(__file__)) - def __init__(self): + def __init__(self, nyrs=NUM_YEARS): + # put JSON contents of DEFAULTS_FILE_NAME into self._vals dictionary super().__init__() + print("Consumption num years = ", nyrs) self.initialize(Consumption.JSON_START_YEAR, - Consumption.DEFAULT_NUM_YEARS) + nyrs) @staticmethod def read_json_update(obj): diff --git a/taxcalc/growdiff.py b/taxcalc/growdiff.py index e4cc4ac9e..8f45d6727 100644 --- a/taxcalc/growdiff.py +++ b/taxcalc/growdiff.py @@ -28,14 +28,18 @@ class instance: GrowDiff """ JSON_START_YEAR = Policy.JSON_START_YEAR - DEFAULT_NUM_YEARS = Policy.DEFAULT_NUM_YEARS + NUM_YEARS = Policy.NUM_YEARS DEFAULTS_FILE_NAME = 'growdiff.json' DEFAULTS_FILE_PATH = os.path.abspath(os.path.dirname(__file__)) - def __init__(self): + def __init__(self, nyrs=NUM_YEARS): + # Update defaults to user defined budget window + self.defaults = super().get_defaults() + label = self.defaults["schema"]["labels"]["year"] + label["validators"]["range"]["max"] = GrowDiff.JSON_START_YEAR + nyrs - 1 super().__init__() self.initialize(GrowDiff.JSON_START_YEAR, - GrowDiff.DEFAULT_NUM_YEARS) + nyrs) @staticmethod def read_json_update(obj, topkey): diff --git a/taxcalc/parameters.py b/taxcalc/parameters.py index d3eac686f..f4e3d1b85 100644 --- a/taxcalc/parameters.py +++ b/taxcalc/parameters.py @@ -102,19 +102,12 @@ def __init__(self, start_year=None, num_years=None, last_known_year=None, self.DEFAULTS_FILE_NAME ) - # def get_defaults(self): - """ - Method to allow for the defaults to be modified. - """ - label = self.default["schema"]["labels"]["year"] - label["validators"]["range"]["max"] = 2074#year_to_extend - return self.defaults - + last_budget_year = start_year + num_years - 1 if last_known_year is None: self._last_known_year = start_year else: assert last_known_year >= start_year - assert last_known_year <= self.LAST_BUDGET_YEAR + assert last_known_year <= last_budget_year self._last_known_year = last_known_year self._removed_params = removed or self.REMOVED_PARAMS @@ -129,8 +122,17 @@ def __init__(self, start_year=None, num_years=None, last_known_year=None, kwargs["initial_state"] = { "year": start_year or self.JSON_START_YEAR } + # Update defaults to user defined budget window + self.defaults = super().get_defaults() + label = self.defaults["schema"]["labels"]["year"] + label["validators"]["range"]["max"] = start_year + num_years - 1 super().__init__(**kwargs) + # def get_defaults(self): + # label = self.defaults["schema"]["labels"]["year"] + # label["validators"]["range"]["max"] = 2074 + # return self.defaults + def adjust( self, params_or_path, print_warnings=True, raise_errors=True, **kwargs ): @@ -827,4 +829,4 @@ def is_paramtools_format(params: Union[TaxcalcReform, ParamToolsAdjustment]): else: # Not doing a specific check to see if the value is a list # since it could be a list or just a scalar value. - return True + return True \ No newline at end of file diff --git a/taxcalc/policy.py b/taxcalc/policy.py index 435f3c3c1..4a8279417 100644 --- a/taxcalc/policy.py +++ b/taxcalc/policy.py @@ -40,9 +40,8 @@ class instance: Policy JSON_START_YEAR = 2013 # remains the same unless earlier data added LAST_KNOWN_YEAR = 2025 # last year for which indexed param vals are known # should increase LAST_KNOWN_YEAR by one every calendar year - LAST_BUDGET_YEAR = 2074 # last extrapolation year - # should increase LAST_BUDGET_YEAR by one every calendar year - DEFAULT_NUM_YEARS = LAST_BUDGET_YEAR - JSON_START_YEAR + 1 + DEFAULT_LAST_BUDGET_YEAR = 2034 # last extrapolation year + NUM_YEARS = DEFAULT_LAST_BUDGET_YEAR - JSON_START_YEAR + 1 # NOTE: the following three data structures use internal parameter names: # (1) specify which Policy parameters have been removed or renamed @@ -81,11 +80,9 @@ class instance: Policy # (3) specify which Policy parameters are wage (rather than price) indexed WAGE_INDEXED_PARAMS = ['SS_Earnings_c', 'SS_Earnings_thd'] - def __init__(self, gfactors=None, **kwargs): + def __init__(self, gfactors=None, last_budget_year=DEFAULT_LAST_BUDGET_YEAR, **kwargs): # put JSON contents of DEFAULTS_FILE_NAME into self._vals dictionary super().__init__() - # print(self.__dict__) - # self._vals["schema"]["labels"]["year"]["validators"]["range"]["max"] = 2074 # handle gfactors argument if gfactors is None: self._gfactors = GrowFactors() @@ -95,27 +92,13 @@ def __init__(self, gfactors=None, **kwargs): raise ValueError('gfactors is not None or a GrowFactors instance') # read default parameters and initialize syr = Policy.JSON_START_YEAR - nyrs = Policy.DEFAULT_NUM_YEARS + self.nyrs = last_budget_year - syr + 1 self._inflation_rates = None self._wage_growth_rates = None - self.initialize(syr, nyrs, Policy.LAST_KNOWN_YEAR, + self.initialize(syr, self.nyrs, Policy.LAST_KNOWN_YEAR, Policy.REMOVED_PARAMS, Policy.REDEFINED_PARAMS, Policy.WAGE_INDEXED_PARAMS, **kwargs) - print("Defaults = ", self.defaults) - # json_params = self.get_defaults() - # label = json_params["schema"]["labels"]["year"] - # label["validators"]["range"]["max"] = 2074 - # return self.defaults - # json_params["schema"]["labels"]["year"]["validators"]["range"]["max"] = 2074 - # self.defaults = json_params - self.initialize(syr, nyrs, Policy.LAST_KNOWN_YEAR, - Policy.REMOVED_PARAMS, - Policy.REDEFINED_PARAMS, - Policy.WAGE_INDEXED_PARAMS, **kwargs) - # quit() - print("Num years = ", nyrs) - # self.defaults = self.get_defaults() @staticmethod def tmd_constructor(growfactors_path): # pragma: no cover @@ -191,4 +174,4 @@ def set_rates(self): self._wage_growth_rates = self._gfactors.wage_growth_rates( self.start_year, self.end_year - ) + ) \ No newline at end of file