def _lowess_update_nn(x, cur_nn, i):
 while True:
  if (cur_nn[1] < x.size):
   left_dist = (x[i] - x[cur_nn[0]])
   new_right_dist = (x[cur_nn[1]] - x[i])
   if (new_right_dist < left_dist):
    cur_nn[0] = (cur_nn[0] + 1)
    cur_nn[1] = (cur_nn[1] + 1)
   else:
    break
  else:
   break

def _lowess_update_nn ( x , cur_nn , i ) : while True : if ( cur_nn [ 1 ] < x . size ) : left_dist = ( x [ i ] - x [ cur_nn [ 0 ] ] ) new_right_dist = ( x [ cur_nn [ 1 ] ] - x [ i ] ) if ( new_right_dist < left_dist ) : cur_nn [ 0 ] = ( cur_nn [ 0 ] + 1 ) cur_nn [ 1 ] = ( cur_nn [ 1 ] + 1 ) else : break else : break
update the endpoints of the nearest neighbors to the ith point .