Version of distance which is possibly scaled to [0,1].
489672
public double score(StringWrapper s,StringWrapper t) {
		if (scaling) {
			int minLen = Math.min( s.unwrap().length(), t.unwrap().length() );
			return super.score(s,t) / (minLen * CHAR_EXACT_MATCH_SCORE);
		} else {
			return super.score(s,t);
		}
	}
791778
def inverse_distance(xp, yp, variable, grid_x, grid_y, r, gamma=None, kappa=None,
                     min_neighbors=3, kind='cressman'):
    """"""
    return inverse_distance_to_grid(xp, yp, variable, grid_x, grid_y, r, gamma=gamma,
                                    kappa=kappa, min_neighbors=min_neighbors, kind=kind)
679773
def unscale_and_snap_to_nearest(x, tune_params, eps):
    """"""
    x_u = [i for i in x]
    for i, v in enumerate(tune_params.values()):
        #create an evenly spaced linear space to map [0,1]-interval
        #to actual values, giving each value an equal chance
        #pad = 0.5/len(v)  #use when interval is [0,1]
        pad = 0.5*eps      #use when interval is [0, eps*len(v)]
        linspace = numpy.linspace(pad, (eps*len(v))-pad, len(v))

        #snap value to nearest point in space, store index
        idx = numpy.abs(linspace-x[i]).argmin()

        #safeguard that should not be needed
        idx = min(max(idx, 0), len(v)-1)

        #use index into array of actual values
        x_u[i] = v[idx]
    return x_u
778778
private static double distance(double[] p1, double[] p2) {
		switch (p1.length) {
			case 2: return Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]));
			case 3: return Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) + (p1[2] - p2[2]) * (p1[2] - p2[2]));
			default: {
				double dist = 0;
				for (int i = p1.length - 1; i >= 0; i--) {
					final double d = (p1[i] - p2[i]);
					dist += d * d;
				}
				return Math.sqrt(dist);
			}
		}
	}
504105
def _scale_shape(dshape, scale = (1,1,1)):
    """"""
    nshape = np.round(np.array(dshape) * np.array(scale))
    return tuple(nshape.astype(np.int))
800943
def _distance_last_evaluations(self):
        
        if self.X.shape[0] < 2:
            # less than 2 evaluations
            return np.inf
        return np.sqrt(np.sum((self.X[-1, :] - self.X[-2, :]) ** 2))
673384
public static float distance (int x0, int y0, int x1, int y1)
    {
        return (float)Math.sqrt(((x1 - x0) * (x1 - x0)) +
                                ((y1 - y0) * (y1 - y0)));
    }
266280
public static int distance(int index0, int index1, int size) {
		if( index0 > index1 ) {
			int tmp = index0;
			index0 = index1;
			index1 = tmp;
		}
		int distance0 = index1-index0;
		int distance1 = index0 + size-index1;
		if( distance0 < distance1)
			return distance0;
		else
			return distance1;
	}
1349152
def _distance(self, x0, y0, x1, y1):
        """"""
        dx = x1-x0
        dy = y1-y0
        # roll displacements across the borders
        if self.pix:
            dx[ dx > self.Lx/2 ] -= self.Lx
            dx[ dx < -self.Lx/2 ] += self.Lx
        if self.piy:
            dy[ dy > self.Ly/2 ] -= self.Ly
            dy[ dy < -self.Ly/2 ] += self.Ly
        return dx, dy
964444
def distance(self, piecex, piecey):
        ''''''
        return max(abs(piecex[0] - piecey[0]), abs(piecex[1], piecey[1]))
1143750
def distance_to_closest(self, ps: Union["Units", List["Point2"], Set["Point2"]]) -> Union[int, float]:
        
        assert ps
        closest_distance_squared = math.inf
        for p2 in ps:
            if not isinstance(p2, Point2):
                p2 = p2.position
            distance = (self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2
            if distance < closest_distance_squared:
                closest_distance_squared = distance
        return closest_distance_squared ** 0.5
813875
def distance(self) -> ErrorValue:
        """"""
        if 'DistCalibrated' in self._data:
            dist = self._data['DistCalibrated']
        else:
            dist = self._data["Dist"]
        if 'DistCalibratedError' in self._data:
            disterr = self._data['DistCalibratedError']
        elif 'DistError' in self._data:
            disterr = self._data['DistError']
        else:
            disterr = 0.0
        return ErrorValue(dist, disterr)
411406
def _distance(self,x):
        """"""
        distance = np.empty([len(self.mu)])

        for i in np.arange(len(self.mu)):
            if self.d == 'mahalanobis' and self.is_invertible(self.Z[i]):
                    distance[i] = (x - self.mu[i]).dot(np.linalg.inv(self.Z[i])).dot((x - self.mu[i]).transpose())
            else:
                distance[i] = (x - self.mu[i]).dot((x - self.mu[i]).transpose())

        return distance
1090546
def closestDirectDistance(arr, ksize=30, dtype=np.uint16):
    '''
    
    '''

    out = np.zeros_like(arr, dtype=dtype)
    _calc(out, arr, ksize)
    return out
850145
def distance(self, x, y):
        
        if scipy.sparse.issparse(x):
            return numpy.sum(numpy.absolute((x-y).toarray().ravel()))
        else:
            return numpy.sum(numpy.absolute(x-y))
608010
def distance(other)
      @globe.inverse(phi, la, other.phi, other.la).first
    end
895579
function (letter1, letter2) {
  var index1 = scale.indexOf(letter1);
  var index2 = scale.indexOf(letter2);
  var distance = mod(index2 - index1, scale.length) + 1;

  assert(index1 > -1);
  assert(index2 > -1);
  assert(distance > 0 && distance <= scale.length);

  return distance;
}