Returns the cartesian distance of this parse issue from the given column/line
in column/line units
495002
private double getDistanceFromPosition( IParseIssue pi, int line, int col )
  {
    if( pi.getSource() != null && pi.getSource().getLocation() != null )
    {
      int squaredDist = ((pi.getSource().getLocation().getLineNum() - line) * (pi.getSource().getLocation().getLineNum() - line)) +
                        ((pi.getSource().getLocation().getColumn() - col) * (pi.getSource().getLocation().getColumn() - col));
      return Math.sqrt( squaredDist );
    }
    else
    {
      return Double.MAX_VALUE;
    }
  }
1085148
def _parse_col_positions(frame_style, header_line):
    

    separator = re.escape(FRAMES[frame_style.lower()]["VERTICAL"])

    if frame_style == "None":
        separator = r"[\s]{2}[^\s]"
        # Matches two whitespaces followed by a non-whitespace.
        # Our column headers are serated by 3 spaces by default.

    col_positions = []
    # Abuse regexp engine to anotate vertical-separator positions:
    re.sub(separator, lambda group: col_positions.append(group.start()), header_line)
    if frame_style == "None":
        col_positions.append(len(header_line) - 1)
    return col_positions
1308020
def get_distance_term(self, C, rrup):
        
        f_p = C["c1"] * rrup
        idx = np.logical_and(rrup > self.CONSTANTS["r1"],
                             rrup <= self.CONSTANTS["r2"])
        f_p[idx] = (C["c1"] * self.CONSTANTS["r1"]) +\
            C["c2"] * (rrup[idx] - self.CONSTANTS["r1"])
        idx = rrup > self.CONSTANTS["r2"]
        f_p[idx] = C["c1"] * self.CONSTANTS["r1"] +\
            C["c2"] * (self.CONSTANTS["r2"] - self.CONSTANTS["r1"]) +\
            C["c3"] * (rrup[idx] - self.CONSTANTS["r2"])
        return f_p
1300985
def getshapestring(self, startrow=1, nrow=-1, rowincr=1):
        """"""
        return self._table.getcolshapestring(self._column,
                                             startrow, nrow, rowincr)
1362942
def from_position(tu, file, line, column):
        
        return conf.lib.clang_getLocation(tu, file, line, column)
1239760
def sorted_by_distance_to(self, position: Union[Unit, Point2], reverse: bool = False) -> "Units":
        
        if len(self) in [0, 1]:
            return self
        position = position.position
        return self.sorted(keyfn=lambda unit: unit.position._distance_squared(position), reverse=reverse)
579760
def linecol_to_pos(text, line, col):
    
    nth_newline_offset = 0
    for i in range(line - 1):
        new_offset = text.find("\n", nth_newline_offset)
        if new_offset < 0:
            raise ValueError("Text does not have {0} lines."
                             .format(line))
        nth_newline_offset = new_offset + 1
    offset = nth_newline_offset + col
    if offset > len(text):
        raise ValueError("Line {0} column {1} is not within the text"
                         .format(line, col))
    return offset
1372341
def get_distance(a, b, xaxis=True):
    
    if xaxis:
        arange = ("0", a.qstart, a.qstop, a.orientation)  # 0 is the dummy chromosome
        brange = ("0", b.qstart, b.qstop, b.orientation)
    else:
        arange = ("0", a.sstart, a.sstop, a.orientation)
        brange = ("0", b.sstart, b.sstop, b.orientation)

    dist, oo = range_distance(arange, brange, distmode="ee")
    dist = abs(dist)

    return dist
1123552
def _get_column(self, column_or_label):
        """"""
        c = column_or_label
        if isinstance(c, collections.Hashable) and c in self.labels:
            return self[c]
        elif isinstance(c, numbers.Integral):
            return self[c]
        elif isinstance(c, str):
            raise ValueError('label "{}" not in labels {}'.format(c, self.labels))
        else:
            assert len(c) == self.num_rows, 'column length mismatch'
            return c
136579
function (line, dist) {
        var sum = 0;

        if (dist <= 0) return line[0];

        for (var i = 0; i < line.length - 1; i++) {
            var p0 = line[i];
            var p1 = line[i + 1];
            var d = this.distance(p0, p1);
            sum += d;
            if (sum > dist) return interpolate(p0, p1, (dist - (sum - d)) / d);
        }

        return line[line.length - 1];
    }
1163352
def _compute_line(source_code, start, length):
        
        total_length = len(source_code)
        source_code = source_code.splitlines(True)
        counter = 0
        i = 0
        lines = []
        starting_column = None
        ending_column = None
        while counter < total_length:
            # Determine the length of the line, and advance the line number
            lineLength = len(source_code[i])
            i = i + 1

            # Determine our column numbers.
            if starting_column is None and counter + lineLength > start:
                starting_column = (start - counter) + 1
            if starting_column is not None and ending_column is None and counter + lineLength > start + length:
                ending_column = ((start + length) - counter) + 1

            # Advance the current position counter, and determine line numbers.
            counter += lineLength
            if counter > start:
                lines.append(i)

            # If our advanced position for the next line is out of range, stop.
            if counter > start + length:
                break

        return (lines, starting_column, ending_column)
110696
def distance(args):
    
    from jcvi.utils.iter import pairwise

    p = OptionParser(distance.__doc__)
    p.add_option("--distmode", default="ss", choices=("ss", "ee"),
            help="Distance mode between paired reads. ss is outer distance, " \
                 "ee is inner distance [default: %default]")
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    bedfile, = args
    sortedbedfile = sort([bedfile])
    valid = total = 0
    fp = open(sortedbedfile)
    for a, b in pairwise(fp):
        a = BedLine(a)
        b = BedLine(b)
        ar = (a.seqid, a.start, a.end, "+")
        br = (b.seqid, b.start, b.end, "+")
        dist, oo = range_distance(ar, br, distmode=opts.distmode)
        total += 1
        if dist > 0:
            print(dist)
            valid += 1

    logging.debug("Total valid (> 0) distances: {0}.".\
                  format(percentage(valid, total)))
5536
def pointToLineDistance(p, p1, p2):
    """"""
    d = np.sqrt(vtk.vtkLine.DistanceToLine(p, p1, p2))
    return d
1315908
function(unit, distance, round) {

			if(distance == 0 || typeof distance == 'undefined') {

				if(geolib.distance == 0) {
					// throw 'No distance given.';
					return 0;
				} else {
					distance = geolib.distance;
				}

			}

			unit = unit || 'm';
			round = (null == round ? 4 : round);

			switch(unit) {

				case 'm':    // Meter
					return geolib.round(distance, round);
					break;
				case 'km':    // Kilometer
					return geolib.round(distance / 1000, round);
					break;
				case 'cm':    // Centimeter
					return geolib.round(distance * 100, round);
					break;
				case 'mm':    // Millimeter
					return geolib.round(distance * 1000, round);
					break;
				case 'mi':    // Miles
					return geolib.round(distance * (1 / 1609.344), round);
					break;
				case 'sm':    // Seamiles
					return geolib.round(distance * (1 / 1852.216), round);
					break;
				case 'ft':    // Feet
					return geolib.round(distance * (100 / 30.48), round);
					break;
				case 'in':    // Inch
					return geolib.round(distance * 100 / 2.54, round);
					break;
				case 'yd':    // Yards
					return geolib.round(distance * (1 / 0.9144), round);
					break;
			}

			return distance;

		}
1306190
protected double distanceSum( LineGeneral2D_F64 line , int c0 , int c1 , List<Point2D_I32> contour ) {
		double total = 0;
		if( c0 < c1  ) {
			int length = c1-c0+1;
			int samples = Math.min(maxLineSamples,length);

			for (int i = 0; i < samples; i++) {
				int index = c0 + i*(length-1)/(samples-1);
				total += distance(line,contour.get(index));
			}
		} else {
			int lengthFirst = contour.size()-c0;
			int lengthSecond = c1+1;

			int length = lengthFirst+c1+1;
			int samples = Math.min(maxLineSamples,length);

			int samplesFirst = samples*lengthFirst/length;
			int samplesSecond = samples*lengthSecond/length;

			for (int i = 0; i < samplesFirst; i++) {
				int index = c0 + i*lengthFirst/(samples-1);
				total += distance(line,contour.get(index));
			}
			for (int i = 0; i < samplesSecond; i++) {
				int index = i*lengthSecond/(samples-1);
				total += distance(line,contour.get(index));
			}
		}
		return total;
	}
951256
def find_column(self, t):
        
        cr = max(self.text.rfind(l, 0, t.lexpos) for l in self.line_terminators)
        if cr == -1:
            return t.lexpos + 1
        return t.lexpos - cr
310430
def distance_to(self, p: Union["Unit", Point2, Point3], bot: "BotAI" = None) -> Union[int, float]:
        
        if bot and isinstance(p, Unit):
            index = bot.distances_tag_dict
            return (bot.unit_distances_dict[index[self.tag]][index[p.tag]]) ** 0.5
        return self.position.distance_to_point2(p.position)