Simple lint edits commits for dcegm.py
@@ -7,6 +7,7 @@ choice models with (or without) taste shocks" by Iskhakov et al. (2016)
import numpy as np
from HARK.interpolation import LinearInterp
+
def calcSegments(x, v):
"""
Find index vectors `rise` and `fall` such that `rise` holds the indeces `i`
@@ -84,6 +85,8 @@ def calcSegments(x, v):
return rise, fall
# think! nanargmax makes everythign super ugly because numpy changed the wraning
# in all nan slices to a valueerror...it's nans, aaarghgghg
+
+
def calcMultilineEnvelope(M, C, V_T, commonM):
"""
Do the envelope step of the DCEGM algorithm. Takes in market ressources,
@@ -141,8 +144,8 @@ def calcMultilineEnvelope(M, C, V_T, commonM):
m_eval = commonM[in_range]
# re-interpolate to common grid
- commonV_T[in_range,j] = LinearInterp(m_idx_j, V_T[idxs], lower_extrap=True)(m_eval)
- commonC[in_range,j] = LinearInterp(m_idx_j, C[idxs], lower_extrap=True)(m_eval) # Interpolat econsumption also. May not be nesserary
+ commonV_T[in_range, j] = LinearInterp(m_idx_j, V_T[idxs], lower_extrap=True)(m_eval) # NOQA
+ commonC[in_range, j] = LinearInterp(m_idx_j, C[idxs], lower_extrap=True)(m_eval) # NOQA Interpolat econsumption also. May not be nesserary
# for each row in the commonV_T matrix, see if all entries are np.nan. This
# would mean that we have no valid value here, so we want to use this boolean
# vector to filter out irrelevant entries of commonV_T.
@@ -170,8 +173,6 @@ def calcMultilineEnvelope(M, C, V_T, commonM):
# going outside all the sub-line segments
IsNaN = np.isnan(upperV_T)
upperV_T[IsNaN] = LinearInterp(commonM[IsNaN == False], upperV_T[IsNaN == False])(commonM[IsNaN])
-
-
LastBeforeNaN = np.append(np.diff(IsNaN) > 0, 0)
LastId = LastBeforeNaN*idx_max # Find last id-number
idx_max[IsNaN] = LastId[IsNaN]
@@ -188,8 +189,10 @@ def calcMultilineEnvelope(M, C, V_T, commonM):
return upperM, upperC, upperV_T
+
def main():
print("Sorry, HARK.dcegm doesn't actually do anything on its own.")
+
if __name__ == '__main__':
main()
