Use snake_case for new interpolator
@@ -4216,39 +4216,39 @@ class DiscreteInterp(MetricObject):
An interpolator for variables that can only take a discrete set of values.
If the function we wish to interpolate, f(args) can take on the list of
- values DiscreteVals, this class expects an interpolator for the index of
- f's value in DiscreteVals.
- E.g., if f(a,b,c) = DiscreteVals[5], then IndexInterp(a,b,c) = 5.
+ values discrete_vals, this class expects an interpolator for the index of
+ f's value in discrete_vals.
+ E.g., if f(a,b,c) = discrete_vals[5], then index_interp(a,b,c) = 5.
Parameters
----------
- IndexInterp: HARKInterpolator
+ index_interp: HARKInterpolator
An interpolator giving an approximation to the index of the value in
- DiscreteVals that corresponds to a given set of arguments.
- DiscreteVals: numpy.array
+ discrete_vals that corresponds to a given set of arguments.
+ discrete_vals: numpy.array
A 1D array containing the values in the range of the discrete function
to be interpolated.
"""
- distance_criteria = ["IndexInterp"]
+ distance_criteria = ["index_interp"]
- def __init__(self, IndexInterp, DiscreteVals):
+ def __init__(self, index_interp, discrete_vals):
- self.IndexInterp = IndexInterp
- self.DiscreteVals = DiscreteVals
- self.nVals = len(self.DiscreteVals)
+ self.index_interp = index_interp
+ self.discrete_vals = discrete_vals
+ self.n_vals = len(self.discrete_vals)
def __call__(self, *args):
# Interpolate indices and round to integers
- inds = np.rint(self.IndexInterp(*args)).astype(int)
+ inds = np.rint(self.index_interp(*args)).astype(int)
if type(inds) is not np.ndarray:
inds = np.array(inds)
# Deal with out-of range indices
inds[inds < 0] = 0
- inds[inds >= self.nVals] = self.nVals - 1
+ inds[inds >= self.n_vals] = self.n_vals - 1
# Get values from grid
- return self.DiscreteVals[inds]
+ return self.discrete_vals[inds]
###############################################################################
## Functions used in discrete choice models with T1EV taste shocks ############
