Returns the distance between the furthest unit from this group to the target unit
428508
def furthest_distance_to(self, position: Union[Unit, Point2, Point3]) -> Union[int, float]:
        
        assert self.exists
        if isinstance(position, Unit):
            position = position.position
        return position.distance_to_furthest([u.position for u in self])
557740
def farthest(self, dt1, dt2, *dts):
        from functools import reduce

        
        dt1 = pendulum.instance(dt1)
        dt2 = pendulum.instance(dt2)

        dts = [dt1, dt2] + [pendulum.instance(x) for x in dts]
        dts = [(abs(self - dt), dt) for dt in dts]

        return max(dts)[1]
1355934
private int hammingDistance(BinarySolution solutionOne, BinarySolution solutionTwo) {
    int distance = 0;
    for (int i = 0; i < problem.getNumberOfVariables(); i++) {
      distance += hammingDistance(solutionOne.getVariableValue(i), solutionTwo.getVariableValue(i));
    }

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

    out = np.zeros_like(arr, dtype=dtype)
    _calc(out, arr, ksize)
    return out
591020
int closestPoint( Point2D_F64 target ) {
		double bestDistance = Double.MAX_VALUE;
		int bestIndex = -1;
		for (int i = 0; i < contour.size(); i++) {
			Point2D_I32 c = contour.get(i);

			double d = UtilPoint2D_F64.distanceSq(target.x,target.y,c.x,c.y);
			if( d < bestDistance ) {
				bestDistance = d;
				bestIndex = i;
			}
		}
		return bestIndex;
	}
1156608
public double distance(Instance first, Instance second) {
    return distance(first, second, Double.POSITIVE_INFINITY);
  }
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
925544
private double max(ArrayList<DistanceSet> v) {
        double max = 0.0;
        for (DistanceSet n : v) {
            if (max < n.dist.get(n.dist.size() - 1)) {
                max = n.dist.get(n.dist.size() - 1);
            }
        }
        return max;
    }
158300
function distanceToFurthestCorner(x, y, rect) {
    var /** @type {?} */ distX = Math.max(Math.abs(x - rect.left), Math.abs(x - rect.right));
    var /** @type {?} */ distY = Math.max(Math.abs(y - rect.top), Math.abs(y - rect.bottom));
    return Math.sqrt(distX * distX + distY * distY);
}
3265
def _calculate_cluster_distance(end_iter):
    
    out = []
    sizes = []
    for x in end_iter:
        out.append(x)
        sizes.append(x.end1 - x.start1)
        sizes.append(x.end2 - x.start2)
    distance = sum(sizes) // len(sizes)
    return distance, out
564587
def sort_by_distance(self, ps: Union["Units", List["Point2"]]) -> List["Point2"]:
        
        if len(ps) == 1:
            return ps[0]
        # if ps and all(isinstance(p, Point2) for p in ps):
        #     return sorted(ps, key=lambda p: self._distance_squared(p))
        return sorted(ps, key=lambda p: self._distance_squared(p.position))
297816
function levenshteinDistance(source, target) {
  var sourceLen = source.length;
  var targetLen = target.length;
  var sourceSegment = void 0,
      targetSegment = void 0;
  var temp = 0;
  if (sourceLen === 0 || targetLen === 0) {
    return null;
  }
  var dist = [];
  for (var i = 0; i <= sourceLen; i++) {
    dist[i] = [];
    dist[i][0] = { min: i };
  }
  for (var j = 0; j <= targetLen; j++) {
    dist[0][j] = { min: j };
  }

  for (var _i4 = 1; _i4 <= sourceLen; _i4++) {
    sourceSegment = source[_i4 - 1];
    for (var _j2 = 1; _j2 <= targetLen; _j2++) {
      targetSegment = target[_j2 - 1];
      if (isEqual(sourceSegment, targetSegment)) {
        temp = 0;
      } else {
        temp = 1;
      }
      var del = dist[_i4 - 1][_j2].min + 1;
      var add = dist[_i4][_j2 - 1].min + 1;
      var modify = dist[_i4 - 1][_j2 - 1].min + temp;
      dist[_i4][_j2] = getMinDiff(del, add, modify);
    }
  }
  return dist;
}
104800
private double [] getDistanceWeightedVotes(double distances[], int[] nnIndices, Instances instances){

		double v[] = new double[this.maxClassValue +1];
        for (int nnIdx : nnIndices) {
            v[(int)instances.instance(nnIdx).classValue()] += 1./Math.max(distances[nnIdx], 0.000000001);
        }
		return v;
	}
985392
static int maximumDistance(List<Point2D_I32> contour , int indexA , int indexB ) {
		Point2D_I32 a = contour.get(indexA);
		Point2D_I32 b = contour.get(indexB);

		int best = -1;
		double bestDistance = -Double.MAX_VALUE;

		for (int i = 0; i < contour.size(); i++) {
			Point2D_I32 c = contour.get(i);
			// can't sum sq distance because some skinny shapes it maximizes one and not the other
//			double d = Math.sqrt(distanceSq(a,c)) + Math.sqrt(distanceSq(b,c));
			double d = distanceAbs(a,c) + distanceAbs(b,c);
			if( d > bestDistance ) {
				bestDistance = d;
				best = i;
			}
		}

		return best;
	}
614774
def distance(self, there):
        
        return haversine_distance((self.latitude, self.longitude),
                                  (there.latitude, there.longitude))
736869
public static float distanceSq( float[] a , float[]b ) {
		float ret = 0;
		for( int i = 0; i < a.length; i++ ) {
			float d = a[i] - b[i];
			ret += d*d;
		}
		return ret;
	}
1186780
def _get_distance(self, pnt1, pnt2):
        """"""
        lat1, lon1 = pnt1
        lat2, lon2 = pnt2
        radius = 6356752  # km
        dlat = math.radians(lat2 - lat1)
        dlon = math.radians(lon2 - lon1)
        a = math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.radians(lat1)) \
            * math.cos(math.radians(lat2)) * math.sin(dlon / 2) * math.sin(dlon / 2)
        c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
        d = radius * c
        return d