Skip to content

Commit

Permalink
Change name of auxiliary dictionary to bilt
Browse files Browse the repository at this point in the history
Patient factors and conditions report now life in the bilt dictionary.
  • Loading branch information
mnwhite committed Aug 10, 2023
1 parent e2a46be commit 1af5a0a
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions HARK/ConsumptionSaving/ConsIndShockModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ def __init__(self, verbose=1, quiet=False, **kwds):
self.quiet = quiet
self.solve_one_period = make_one_period_oo_solver(ConsPerfForesightSolver)
set_verbosity_level((4 - verbose) * 10)

self.bilt = {}
self.update_Rfree() # update interest rate if time varying

def pre_solve(self):
Expand Down Expand Up @@ -1908,7 +1908,7 @@ def get_poststates(self):
def log_condition_result(self, name, result, message, verbose):
"""
Records the result of one condition check in the attribute condition_report
and in the message log.
of the bilt dictionary, and in the message log.
Parameters
----------
Expand All @@ -1925,14 +1925,14 @@ def log_condition_result(self, name, result, message, verbose):
self.conditions[name] = result
set_verbosity_level((4 - verbose) * 10)
_log.info(message)
self.conditions_report += message + '\n'
self.bilt['conditions_report'] += message + '\n'

def check_AIC(self, verbose=None):
"""
Evaluate and report on the Absolute Impatience Condition.
"""
name = "AIC"
APFac = self.auxiliary['APFac']
APFac = self.bilt['APFac']
result = APFac < 1.

messages = {
Expand All @@ -1947,7 +1947,7 @@ def check_GICRaw(self, verbose=None):
Evaluate and report on the Growth Impatience Condition for the Perfect Foresight model.
"""
name = "GICRaw"
GPFacRaw = self.auxiliary['GPFacRaw']
GPFacRaw = self.bilt['GPFacRaw']
result = GPFacRaw < 1.

messages = {
Expand All @@ -1963,7 +1963,7 @@ def check_RIC(self, verbose=None):
Evaluate and report on the Return Impatience Condition.
"""
name = "RIC"
RPFac = self.auxiliary['RPFac']
RPFac = self.bilt['RPFac']
result = RPFac < 1.

messages = {
Expand All @@ -1978,7 +1978,7 @@ def check_FHWC(self, verbose=None):
Evaluate and report on the Finite Human Wealth Condition.
"""
name = "FHWC"
FHWFac = self.auxiliary['FHWFac']
FHWFac = self.bilt['FHWFac']
result = FHWFac < 1.

messages = {
Expand All @@ -1993,7 +1993,7 @@ def check_FVAC(self, verbose=None):
Evaluate and report on the Finite Value of Autarky Condition under perfect foresight.
"""
name = "PFFVAC"
PFVAFac = self.auxiliary['PFVAFac']
PFVAFac = self.bilt['PFVAFac']
result = PFVAFac < 1.

messages = {
Expand Down Expand Up @@ -2032,7 +2032,7 @@ def describe_parameters(self):
try:
val = getattr(self,this_entry[0])
except:
val = self.auxiliary[this_entry[0]]
val = self.bilt[this_entry[0]]
this_line = this_entry[2] + f'={val:.5f} : ' + this_entry[1] + ' (' + this_entry[0] + ')\n'
param_desc += this_line

Expand Down Expand Up @@ -2060,7 +2060,7 @@ def calc_limiting_values(self):
-------
None
'''
aux_dict = {}
aux_dict = self.bilt
aux_dict['APFac'] = (self.Rfree * self.DiscFac * self.LivPrb[0]) ** (1 / self.CRRA)
aux_dict['GPFacRaw'] = aux_dict['APFac'] / self.PermGroFac[0]
aux_dict['FHWFac'] = self.PermGroFac[0] / self.Rfree
Expand All @@ -2079,7 +2079,7 @@ def calc_limiting_values(self):
else:
aux_dict['hNrm'] = np.inf

self.auxiliary = aux_dict
self.bilt = aux_dict

def check_conditions(self, verbose=None):
"""
Expand All @@ -2106,7 +2106,7 @@ def check_conditions(self, verbose=None):
None
"""
self.conditions = {}
self.conditions_report = ''
self.bilt['conditions_report'] = ''
self.degenerate = False
verbose = self.verbose if verbose is None else verbose

Expand All @@ -2116,7 +2116,7 @@ def check_conditions(self, verbose=None):
trivial_message = 'No conditions report was produced because this functionality is only supported for infinite horizon models with a cycle length of 1.'
self.log_condition_result(None, None, trivial_message, verbose)
if not self.quiet:
_log.info(self.conditions_report)
_log.info(self.bilt['conditions_report'])
return

# Calculate some useful quantities that will be used in the condition checks
Expand All @@ -2135,7 +2135,7 @@ def check_conditions(self, verbose=None):
# Exit now if verbose output was not requested.
if not verbose:
if not self.quiet:
_log.info(self.conditions_report)
_log.info(self.bilt['conditions_report'])
return

# Report on the degeneracy of the consumption function solution
Expand Down Expand Up @@ -2171,7 +2171,7 @@ def check_conditions(self, verbose=None):

Check warning on line 2171 in HARK/ConsumptionSaving/ConsIndShockModel.py

View check run for this annotation

Codecov / codecov/patch

HARK/ConsumptionSaving/ConsIndShockModel.py#L2169-L2171

Added lines #L2169 - L2171 were not covered by tests
if degenerate: # All of the other checks are meaningless if the solution is degenerate
if not self.quiet:
_log.info(self.conditions_report)
_log.info(self.bilt['conditions_report'])

Check warning on line 2174 in HARK/ConsumptionSaving/ConsIndShockModel.py

View check run for this annotation

Codecov / codecov/patch

HARK/ConsumptionSaving/ConsIndShockModel.py#L2173-L2174

Added lines #L2173 - L2174 were not covered by tests
return

# Report on the consequences of the Absolute Impatience Condition
Expand All @@ -2192,7 +2192,7 @@ def check_conditions(self, verbose=None):
self.log_condition_result(None, None, GIC_message, verbose)

Check warning on line 2192 in HARK/ConsumptionSaving/ConsIndShockModel.py

View check run for this annotation

Codecov / codecov/patch

HARK/ConsumptionSaving/ConsIndShockModel.py#L2192

Added line #L2192 was not covered by tests

if not self.quiet:
_log.info(self.conditions_report)
_log.info(self.bilt['conditions_report'])


# Make a dictionary to specify an idiosyncratic income shocks consumer
Expand Down Expand Up @@ -3189,7 +3189,7 @@ def describe_parameters(self):
try:
val = getattr(self,this_entry[0])
except:
val = self.auxiliary[this_entry[0]]
val = self.bilt[this_entry[0]]
this_line = this_entry[2] + f'={val:.5f} : ' + this_entry[1] + ' (' + this_entry[0] + ')\n'

# Add in the new entry and return it
Expand Down Expand Up @@ -3228,7 +3228,7 @@ def calc_limiting_values(self):
None
'''
PerfForesightConsumerType.calc_limiting_values(self)
aux_dict = self.auxiliary
aux_dict = self.bilt

# Calculate the risk-modified growth impatience factor
PermShkDstn = self.PermShkDstn[0]
Expand Down Expand Up @@ -3292,15 +3292,15 @@ def calc_limiting_values(self):
aux_dict['hNrm'] = hNrm
aux_dict['MPCmax'] = MPCmax

self.auxiliary = aux_dict
self.bilt = aux_dict


def check_GICMod(self, verbose=None):
"""
Evaluate and report on the Risk-Modified Growth Impatience Condition.
"""
name = "GICMod"
GPFacMod = self.auxiliary['GPFacMod']
GPFacMod = self.bilt['GPFacMod']
result = GPFacMod < 1.

messages = {
Expand All @@ -3316,8 +3316,8 @@ def check_GICSdl(self, verbose=None):
Evaluate and report on the Szeidl variation of the Growth Impatience Condition.
"""
name = "GICSdl"
ELogPermShk = self.auxiliary['ELogPermShk']
result = np.log(self.auxiliary['GPFacRaw']) < ELogPermShk
ELogPermShk = self.bilt['ELogPermShk']
result = np.log(self.bilt['GPFacRaw']) < ELogPermShk

messages = {
True: f"E[log Ψ]={ELogPermShk:.5f} : The expected log permanent income shock satisfies the Szeidl Growth Impatience Condition (GICSdl) log(Þ/G) < E[log Ψ].",
Expand All @@ -3332,7 +3332,7 @@ def check_GICHrm(self, verbose=None):
Evaluate and report on the Harmenberg variation of the Growth Impatience Condition.
"""
name = "GICHrm"
GPFacHrm = self.auxiliary['GPFacHrm']
GPFacHrm = self.bilt['GPFacHrm']
result = GPFacHrm < 1.

messages = {
Expand All @@ -3348,7 +3348,7 @@ def check_GICLiv(self, verbose=None):
Evaluate and report on the Mortality-Adjusted Growth Impatience Condition.
"""
name = "GICLiv"
GPFacLiv = self.auxiliary['GPFacLiv']
GPFacLiv = self.bilt['GPFacLiv']
result = GPFacLiv < 1.

messages = {
Expand All @@ -3364,7 +3364,7 @@ def check_FVAC(self, verbose=None):
Evaluate and report on the Finite Value of Autarky condition in the presence of income risk.
"""
name = "FVAC"
VAFac = self.auxiliary['VAFac']
VAFac = self.bilt['VAFac']
result = VAFac < 1.

messages = {
Expand All @@ -3380,7 +3380,7 @@ def check_WRIC(self, verbose=None):
Evaluate and report on the Weak Return Impatience Condition.
"""
name = "WRIC"
WRPFac = self.auxiliary['WRPFac']
WRPFac = self.bilt['WRPFac']
result = WRPFac < 1.

messages = {
Expand Down Expand Up @@ -3410,7 +3410,7 @@ def check_conditions(self, verbose=None):
None
"""
self.conditions = {}
self.conditions_report = ''
self.bilt['conditions_report'] = ''
self.degenerate = False
verbose = self.verbose if verbose is None else verbose

Expand All @@ -3420,7 +3420,7 @@ def check_conditions(self, verbose=None):
trivial_message = 'No conditions report was produced because this functionality is only supported for infinite horizon models with a cycle length of 1.'
self.log_condition_result(None, None, trivial_message, verbose)
if not self.quiet:
_log.info(self.conditions_report)
_log.info(self.bilt['conditions_report'])
return

# Calculate some useful quantities that will be used in the condition checks
Expand All @@ -3444,7 +3444,7 @@ def check_conditions(self, verbose=None):
# Exit now if verbose output was not requested.
if not verbose:
if not self.quiet:
_log.info(self.conditions_report)
_log.info(self.bilt['conditions_report'])
return

# Report on the degeneracy of the consumption function solution
Expand All @@ -3463,7 +3463,7 @@ def check_conditions(self, verbose=None):
# Stop here if the solution is degenerate
if degenerate:

Check warning on line 3464 in HARK/ConsumptionSaving/ConsIndShockModel.py

View check run for this annotation

Codecov / codecov/patch

HARK/ConsumptionSaving/ConsIndShockModel.py#L3459-L3464

Added lines #L3459 - L3464 were not covered by tests
if not self.quiet:
_log.info(self.conditions_report)
_log.info(self.bilt['conditions_report'])
return

# Report on the limiting behavior of the consumption function as m goes to infinity
Expand Down Expand Up @@ -3512,7 +3512,7 @@ def check_conditions(self, verbose=None):
self.log_condition_result(None, None, GICHrm_message, verbose)

if not self.quiet:
_log.info(self.conditions_report)
_log.info(self.bilt['conditions_report'])


def calc_stable_points(self):
Expand Down

0 comments on commit 1af5a0a

Please sign in to comment.