code: def _compute_linear_weights_edge(idcs, ndist):
      
      # Get out-of-bounds indices from the norm_distances. Negative
      # means "too low", larger than or equal to 1 means "too high"
      lo = np.where(ndist < 0)
      hi = np.where(ndist > 1)
  
      # For "too low" nodes, the lower neighbor gets weight zero;
      # "too high" gets 2 - yi (since yi >= 1)
      w_lo = (1 - ndist)
      w_lo[lo] = 0
      w_lo[hi] += 1
  
      # For "too high" nodes, the upper neighbor gets weight zero;
      # "too low" gets 1 + yi (since yi < 0)
      w_hi = np.copy(ndist)
      w_hi[lo] += 1
      w_hi[hi] = 0
  
      # For upper/lower out-of-bounds nodes, we need to set the
      # lower/upper neighbors to the last/first grid point
      edge = [idcs, idcs + 1]
      edge[0][hi] = -1
      edge[1][lo] = 0
  
      return w_lo, w_hi, edge
docs: Helper for linear interpolation.