def __init__(self, scale_list, values, method='spline', extrapolate=False):
# error checking
if len(values.shape) != 1:
raise ValueError('This class only works for 1D data.')
elif len(scale_list) != 1:
raise ValueError('input and output dimension mismatch.')
if method == 'linear':
k = 1
elif method == 'spline':
k = 3
else:
raise ValueError('Unsuppoorted interpolation method: %s' % method)
offset, scale = scale_list[0]
num_pts = values.shape[0]
points = np.linspace(offset, (num_pts - 1) * scale + offset, num_pts) # type: np.multiarray.ndarray
DiffFunction.__init__(self, [(points[0], points[-1])], delta_list=None)
ext = 0 if extrapolate else 2
self.fun = interp.InterpolatedUnivariateSpline(points, values, k=k, ext=ext)
评论列表
文章目录