def bounded_curvature_extrema_interpolate(x_vals, y_vals, extrema_indices,
                                                            max_curvature):
    extrema_weight = 10**3
    smoothing_factor = 10**4
    num_points = len(x_vals)
    s_vals = np.arange(num_points)
    weights = np.empty(num_points)
    weights.fill(1)
    for i in extrema_indices:
        weights[i] = extrema_weight    
    x_spline, y_spline = iterative_smoothing_interpolation_2d(x_vals, y_vals,
                                    weights, smoothing_factor, max_curvature)
    curvature_array_2d = curvature.parametric_splines_2d_curvature(x_spline,
                                                           y_spline, s_vals)
    y_vals = y_spline(s_vals)
    return [y_vals, curvature_array_2d]
def bounded_curvature_graph_interpolate(graph_points, max_curvature):
    x_vals, y_vals = np.transpose(graph_points)
    num_points = graph_points.shape[0]
    s_vals = np.arange(num_points)
    end_weights = 10**3
    weights = np.empty(num_points)
    weights.fill(1)
    weights[0] = weights[-1] = end_weights
    smoothing_factor = 10**10
    x_spline, y_spline = iterative_smoothing_interpolation_2d(x_vals, y_vals,
                                    weights, smoothing_factor, max_curvature)
    curvature_array_2d = curvature.parametric_splines_2d_curvature(x_spline,
                                                           y_spline, s_vals)
    x_vals = x_spline(s_vals)
    y_vals = y_spline(s_vals)
    interpolated_points = np.transpose(np.array([x_vals, y_vals]))
    return [interpolated_points, curvature_array_2d]
def bounded_error_graph_interpolation(graph_points, resolution):
    points_array = np.array([np.array(point) for point in graph_points])
    s_vals = np.arange(len(graph_points))
    points_x_vals_array, points_y_vals_array = np.transpose(points_array)
    end_weights = 10**3
    weights = np.empty(len(graph_points))
    weights.fill(1)
    weights[0] = weights[-1] = end_weights
    smoothing_factor = 10**4
    x_spline, y_spline = smoothing_interpolation_with_max_error(
        points_x_vals_array, points_y_vals_array, s_vals, weights,
                                     smoothing_factor, resolution)
    sampled_x_vals = x_spline(s_vals)
    sampled_y_vals = y_spline(s_vals)
    interpolated_points = np.transpose([sampled_x_vals, sampled_y_vals])
    curvature_array_2d = curvature.parametric_splines_2d_curvature(x_spline,
                                                           y_spline, s_vals)
    return [interpolated_points, curvature_array_2d]