original_docstring: Provides an array of curvatures and its distances by applying a spline interpolation
    to the path described by the nodes data.
    
docstring: Provides an array of curvatures and its distances by applying a spline interpolation
  to the path described by the nodes data.
docstring_tokens: Provides an array of curvatures and its distances by applying a spline interpolation to the path described by the nodes data .
code: def spline_curvature_calculations(vect, dist_prev):
    """Provides an array of curvatures and its distances by applying a spline interpolation
    to the path described by the nodes data.
    """
    # We need to artificially enhance the data before applying spline interpolation to avoid getting
    # inexistent curvature values close to irregularities on the road when the resolution of nodes data
    # approaching the irregularity is low.
  
    # - Find indexes where dist_prev is greater than threshold
    too_far_idxs = np.nonzero(dist_prev >= _MIN_NODE_DISTANCE)[0]
  
    # - Traversing in reverse order, enhance data by adding points at the found indexes.
    for idx in too_far_idxs[::-1]:
      dp = dist_prev[idx]  # distance of vector that needs to be replaced by higher resolution vectors.
      n = int(np.ceil(dp / _ADDED_NODES_DIST))  # number of vectors that need to be added.
      new_v = vect[idx, :] / n  # new relative vector to insert.
      vect = np.delete(vect, idx, axis=0)  # remove the relative vector to be replaced by the insertion of new vectors.
      vect = np.insert(vect, [idx] * n, [new_v] * n, axis=0)  # insert n new relative vectors
  
    # Data is now enhanced, we can proceed with curvature evaluation.
    # - Create cumulative arrays for distance traveled and vector (x, y)
    ds = np.cumsum(dist_prev, axis=0)
    vs = np.cumsum(vect, axis=0)
  
    # - spline interpolation
    tck, u = splprep([vs[:, 0], vs[:, 1]])
  
    # - evaluate every _SPLINE_EVAL_STEP mts.
    n = max(int(ds[-1] / _SPLINE_EVAL_STEP), len(u))
    unew = np.arange(0, n + 1) / n
  
    # - get derivatives
    d1 = splev(unew, tck, der=1)
    d2 = splev(unew, tck, der=2)
  
    # - calculate curvatures
    num = d1[0] * d2[1] - d1[1] * d2[0]
    den = (d1[0]**2 + d1[1]**2)**(1.5)
    curv = num / den
    curv_ds = unew * ds[-1]
  
    return curv, curv_ds
code_tokens: def spline_curvature_calculations ( vect , dist_prev ) : too_far_idxs = np . nonzero ( dist_prev >= _MIN_NODE_DISTANCE ) [ 0 ] for idx in too_far_idxs [ : : - 1 ] : dp = dist_prev [ idx ] n = int ( np . ceil ( dp / _ADDED_NODES_DIST ) ) new_v = vect [ idx , : ] / n vect = np . delete ( vect , idx , axis = 0 ) vect = np . insert ( vect , [ idx ] * n , [ new_v ] * n , axis = 0 ) ds = np . cumsum ( dist_prev , axis = 0 ) vs = np . cumsum ( vect , axis = 0 ) tck , u = splprep ( [ vs [ : , 0 ] , vs [ : , 1 ] ] ) n = max ( int ( ds [ - 1 ] / _SPLINE_EVAL_STEP ) , len ( u ) ) unew = np . arange ( 0 , n + 1 ) / n d1 = splev ( unew , tck , der = 1 ) d2 = splev ( unew , tck , der = 2 ) num = d1 [ 0 ] * d2 [ 1 ] - d1 [ 1 ] * d2 [ 0 ] den = ( d1 [ 0 ] ** 2 + d1 [ 1 ] ** 2 ) ** ( 1.5 ) curv = num / den curv_ds = unew * ds [ - 1 ] return curv , curv_ds
short_docstring: Provides an array of curvatures and its distances by applying a spline interpolation
  to the path described by the nodes data.
short_docstring_tokens: Provides an array of curvatures and its distances by applying a spline interpolation to the path described by the nodes data .
comment: """Provides an array of curvatures and its distances by applying a spline interpolation
    to the path described by the nodes data.
    """$SEP$# We need to artificially enhance the data before applying spline interpolation to avoid getting$SEP$# inexistent curvature values close to irregularities on the road when the resolution of nodes data$SEP$# approaching the irregularity is low.$SEP$# - Find indexes where dist_prev is greater than threshold$SEP$# - Traversing in reverse order, enhance data by adding points at the found indexes.$SEP$# distance of vector that needs to be replaced by higher resolution vectors.$SEP$# number of vectors that need to be added.$SEP$# new relative vector to insert.$SEP$# remove the relative vector to be replaced by the insertion of new vectors.$SEP$# insert n new relative vectors$SEP$# Data is now enhanced, we can proceed with curvature evaluation.$SEP$# - Create cumulative arrays for distance traveled and vector (x, y)$SEP$# - spline interpolation$SEP$# - evaluate every _SPLINE_EVAL_STEP mts.$SEP$# - get derivatives$SEP$# - calculate curvatures