return a distance as a string
420361
def dist_string(self, val_meters):
        ''''''
        if self.settings.dist_unit == 'nm':
            return "%.1fnm" % (val_meters * 0.000539957)
        if self.settings.dist_unit == 'miles':
            return "%.1fmiles" % (val_meters * 0.000621371)
        return "%um" % val_meters
493329
public static function distance($distance_in_m) : string {
		if (self::$options['format_uom'] == 'METRIC') {
			return round($distance_in_m / 1000, 2) . i18n(null, 'km');
		} else {
			return round($distance_in_m / 1.60934 / 1000, 2) . i18n(null, 'mi');
		}
	}
1034249
function _getDistanceFromLastNewline(str, i) {
    var distance = i;
    var lastNewlineIndex = str.lastIndexOf('\n');
    if (lastNewlineIndex !== -1) {
        distance = (i - lastNewlineIndex - 1);
    }

    return distance;
}
1048504
def distance(self, other):
        """"""
        return math.acos(self._pos3d.dot(other.vector))
64077
def skip_connection_distance(a, b):
    """"""
    if a[2] != b[2]:
        return 1.0
    len_a = abs(a[1] - a[0])
    len_b = abs(b[1] - b[0])
    return (abs(a[0] - b[0]) + abs(len_a - len_b)) / (max(a[0], b[0]) + max(len_a, len_b))
557618
def strings(self):
        
        return [
            toString(self.lat, LAT),
            toString(self.lon, LON)
        ]
228541
def distance(self, x):
        """"""

        d = x - self.ctr

        return np.sqrt(np.dot(np.dot(d, self.am), d))
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
915974
def _visibility_to_text(self, distance):
        

        if not isinstance(distance, (int, long)):
            raise ValueError("Distance must be an integer not", type(distance))
        if distance < 0:
            raise ValueError("Distance out of bounds, should be 0 or greater")

        if 0 <= distance < 1000:
            return 'VP'
        elif 1000 <= distance < 4000:
            return 'PO'
        elif 4000 <= distance < 10000:
            return 'MO'
        elif 10000 <= distance < 20000:
            return 'GO'
        elif 20000 <= distance < 40000:
            return 'VG'
        else:
            return 'EX'
1287079
def distance(x,y):
    
    assert len(x) == len(y), "The vector must have same length"
    result = ()
    sum = 0
    for i in range(len(x)):
        result += (x[i] -y[i],)
    for component in result:
        sum += component**2
    return math.sqrt(sum)
809741
function distance$1(s1, s2) {
                if (typeof(s1) !== "string" || typeof(s2) !== "string") {
                    return 0;
                }

                if (s1.length === 0 || s2.length === 0) {
                    return 0;
                }

                s1 = s1.toLowerCase(), s2 = s2.toLowerCase();

                var matchWindow = (Math.floor(Math.max(s1.length, s2.length) / 2.0)) - 1;
                var matches1 = new Array(s1.length);
                var matches2 = new Array(s2.length);
                var m = 0; // number of matches
                var t = 0; // number of transpositions
                var i = 0; // index for string 1
                var k = 0; // index for string 2

                //debug helpers
                //console.log("s1: " + s1 + "; s2: " + s2);
                //console.log(" - matchWindow: " + matchWindow);

                for (i = 0; i < s1.length; i++) { // loop to find matched characters
                    var start = Math.max(0, (i - matchWindow)); // use the higher of the window diff
                    var end = Math.min((i + matchWindow + 1), s2.length); // use the min of the window and string 2 length

                    for (k = start; k < end; k++) { // iterate second string index
                        if (matches2[k]) { // if second string character already matched
                            continue;
                        }
                        if (s1[i] !== s2[k]) { // characters don't match
                            continue;
                        }

                        // assume match if the above 2 checks don't continue
                        matches1[i] = true;
                        matches2[k] = true;
                        m++;
                        break;
                    }
                }

                // nothing matched
                if (m === 0) {
                    return 0.0;
                }

                k = 0; // reset string 2 index
                for(i = 0; i < s1.length; i++) { // loop to find transpositions
                    if (!matches1[i]) { // non-matching character
                        continue;
                    }
                    while(!matches2[k]) { // move k index to the next match
                        k++;
                    }
                    if (s1[i] !== s2[k]) { // if the characters don't match, increase transposition
                        t++;
                    }
                    k++; // iterate k index normally
                }

                // transpositions divided by 2
                t = t / 2.0;

                return ((m / s1.length) + (m / s2.length) + ((m - t) / m)) / 3.0;
            }
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
720294
def distance2_to(self, other: "Point2"):
        """"""
        assert isinstance(other, Point2)
        return (self[0] - other[0]) ** 2 + (self[1] - other[1]) ** 2
250306
def distance(self, val):
        
        tmp = 2
        try:
            int(val)
            if val > 0 and val <= 2:
                tmp = val
        except (ValueError, TypeError):
            pass
        self._distance = tmp
57760
def get_distance_term(self, C, rrup, mag):
        
        return (C["r1"] + C["r2"] * mag) *\
            np.log(np.sqrt(rrup ** 2. + C["h1"] ** 2.))
569588
def get_length(self):
        
        length = 0
        for i, point in enumerate(self.points):
            if i != 0:
                length += point.distance(self.points[i - 1])
        return length
1294338
def __hammingDistance(s1, s2):
        '''
        
        '''

        l1 = len(s1)
        l2 = len(s2)

        if l1 != l2:
            raise ValueError("Hamming distance requires strings of same size.")

        return sum(ch1 != ch2 for ch1, ch2 in zip(s1, s2))