code: def _compute_nearest_weights_edge(idcs, ndist, variant):
      
      # Get out-of-bounds indices from the norm_distances. Negative
      # means "too low", larger than or equal to 1 means "too high"
      lo = (ndist < 0)
      hi = (ndist > 1)
  
      # For "too low" nodes, the lower neighbor gets weight zero;
      # "too high" gets 1.
      if variant == 'left':
          w_lo = np.where(ndist <= 0.5, 1.0, 0.0)
      else:
          w_lo = np.where(ndist < 0.5, 1.0, 0.0)
  
      w_lo[lo] = 0
      w_lo[hi] = 1
  
      # For "too high" nodes, the upper neighbor gets weight zero;
      # "too low" gets 1.
      if variant == 'left':
          w_hi = np.where(ndist <= 0.5, 0.0, 1.0)
      else:
          w_hi = np.where(ndist < 0.5, 0.0, 1.0)
  
      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 nearest interpolation mimicing the linear case.