Convert to interval ends from a list of anchors
    extend modifies the xmax, ymax boundary of the box,
    which can be positive or negative
    very useful when we want to make the range as fuzzy as we specify
341571
def make_range(clusters, extend=0):
    
    eclusters = []
    for cluster in clusters:
        xlist, ylist, scores = zip(*cluster)
        score = _score(cluster)

        xchr, xmin = min(xlist)
        xchr, xmax = max(xlist)
        ychr, ymin = min(ylist)
        ychr, ymax = max(ylist)

        # allow fuzziness to the boundary
        xmax += extend
        ymax += extend
        # because extend can be negative values, we don't want it to be less than min
        if xmax < xmin:
            xmin, xmax = xmax, xmin
        if ymax < ymin:
            ymin, ymax = ymax, ymin

        eclusters.append(((xchr, xmin, xmax),
                          (ychr, ymin, ymax), score))

    return eclusters
504694
def bbox_vflip(bbox, rows, cols):
    """"""
    x_min, y_min, x_max, y_max = bbox
    return [x_min, 1 - y_max, x_max, 1 - y_min]
1137419
def xpointerNewRange(self, startindex, end, endindex):
        
        if end is None: end__o = None
        else: end__o = end._o
        ret = libxml2mod.xmlXPtrNewRange(self._o, startindex, end__o, endindex)
        if ret is None:raise treeError('xmlXPtrNewRange() failed')
        return xpathObjectRet(ret)
40600
def normalize_bbox(coords, ymax, scaler=2):
    
    return [
        coords[0] * scaler,
        ymax - (coords[3] * scaler),
        coords[2] * scaler,
        ymax - (coords[1] * scaler),
    ]
1168938
function(options, extremes) {
            // if there are no extremes (i.e. no meaningful data was extracted), go with 0 to 100
            if(!extremes.min && !extremes.max) {
                options.min = 0;
                options.max = 100;
                return;
            }
            // if the min or max is such that no data makes it onto the chart, we hard-code some reasonable extremes
            if(extremes.min > extremes.dataMax && extremes.min > 0 && this.userMax === Infinity) {
                options.max = (this.logScale) ? extremes.min + 2 : extremes.min * 2;
                return;
            }
            if(extremes.max < extremes.dataMin && extremes.max < 0 && this.userMin === -Infinity) {
                options.min = (this.logScale) ? extremes.max - 2 : extremes.max * 2;
                return;
            }
            // if either data extreme is exactly zero, remove the padding on that side so the axis doesn't extend beyond zero
            if(extremes.dataMin === 0 && this.userMin === -Infinity) {
                options.min = 0;
                options.minPadding = 0;
            }
            if(extremes.dataMax === 0 && this.userMax === Infinity) {
                options.max = 0;
                options.maxPadding = 0;
            }
        }
1233230
def bounding_box(positions):
    '''
    '''
    (x0, y0, z0) = (x1, y1, z1) = positions[0]
    for x, y, z in positions:
        x0 = min(x0, x)
        y0 = min(y0, y)
        z0 = min(z0, z)
        x1 = max(x1, x)
        y1 = max(y1, y)
        z1 = max(z1, z)
    return (x0, y0, z0), (x1, y1, z1)
319541
function axisPositiveSideProperties(_ref2) {
    var tPos = _ref2.tPos,
        tDim = _ref2.tDim;
    // substract also anchor placeholder from the beginning
    return {
      position: tPos + tDim - anchorSize
    };
  }
449718
private boolean cCreateFromScratch(Bounds i, int from, int to) {
		//Conversion
		long max = i.max;
		long min = i.min;
		if (i.max == APSPSolver.INF) max = H-O;
		if (i.min == -APSPSolver.INF) min = -1 * (H - O);
		i = new Bounds(min,max);

		// Checks
		if (i.min > i.max) return false; 
		if (from == to) return false;
		if (tPoints[from] == null) return false;

		//Already existing edge
		SimpleDistanceConstraint con = tPoints[from].getOut(to);
		if (con != null) {
			//check intersection between active con and new con
			if ( (con.getMinimum() > i.max) || (con.getMaximum() < i.min) ) return false;
			//check con does not contain active con
			if ( (con.getMinimum() > i.min) && (con.getMaximum() < i.max) ) {
				//OK it is. I save con without doing anything else
				if (!con.addInterval(i)) return false;
				return true;
			}
			//Update active con
			long oldd = con.getMinimum();
			long oldD = con.getMaximum();
			if (con.getMinimum() < i.min) con.setMinimum(i.min);
			if (con.getMaximum() > i.max) con.setMaximum(i.max);

			if (!con.addInterval(i)) return false;
			
			if (backupDMatrixSimple) saveDMatrixInternal();
			if (!fromScratchDistanceMatrixComputation()) {
				//Inconsistency. Rollback
				con.removeInterval(i);
				if (backupDMatrixSimple) restoreDMatrixInternal();
				return false;
			}

			//[lb,ub] = [-di0,d0i]
			for (int j = 0; j < MAX_USED+1; j++)
				if (tPoints[j].isUsed()) {
					tPoints[j].setLowerBound(sum(-distance[j][0],O));
					tPoints[j].setUpperBound(sum(distance[0][j],O));
				}
		}				
		else {
			con = new SimpleDistanceConstraint();
			con.setFrom(this.getVariable(from));
			con.setTo(this.getVariable(to));
			con.setMinimum(i.min);
			con.setMaximum(i.max);
			con.addInterval(new Bounds(i.min,i.max));
			//Add edge to tp
			tPoints[from].setOut(to,con);

			if (backupDMatrixSimple) saveDMatrixInternal();
			if (!fromScratchDistanceMatrixComputation()) {
				tPoints[from].setOut(to,null);
				if (backupDMatrixSimple) restoreDMatrixInternal();
				return false;
			}

			//[lb,ub] = [-di0,d0i]
			for (int j = 0; j < MAX_USED+1; j++) {
				if (tPoints[j].isUsed() == true) {
					tPoints[j].setLowerBound (sum(-distance[j][0],O));
					tPoints[j].setUpperBound (sum(distance[0][j],O));
				}
			}
		}
		return true;	
	}
636074
def _remove_boundaries(self, interval):
        
        begin = interval.begin
        end = interval.end
        if self.boundary_table[begin] == 1:
            del self.boundary_table[begin]
        else:
            self.boundary_table[begin] -= 1

        if self.boundary_table[end] == 1:
            del self.boundary_table[end]
        else:
            self.boundary_table[end] -= 1
414426
function decodeAndClamp(value, addend, coefficient, max) {
    value = addend + value * coefficient;
    // Clamp the value to the range
    return (value < 0 ? 0 : (value > max ? max : value));
  }
188499
function BoundingBox3D( xMin , yMin , zMin , xMax , yMax , zMax ) {
	this.min = new Vector3D( xMin , yMin , zMin ) ;
	this.max = new Vector3D( xMax , yMax , zMax ) ;
}
154073
def scale_between(minval, maxval, numStops):
    

    scale = []

    if numStops < 2:
        return [minval, maxval]
    elif maxval < minval:
        raise ValueError()
    else:
        domain = maxval - minval
        interval = float(domain) / float(numStops)
        for i in range(numStops):
            scale.append(round(minval + interval * i, 2))
        return scale
1178237
function (ed) {
      // Adjust selection so that a end container with a end offset of zero is not included in the selection
      // as this isn't visible to the user.
      var rng = RangeNormalizer.normalize(ed.selection.getRng());
      var start = rng.startContainer;
      var end = rng.endContainer;

      if (start !== end && rng.endOffset === 0) {
        var newEnd = findSelectionEnd(start, end);
        var endOffset = newEnd.nodeType === 3 ? newEnd.data.length : newEnd.childNodes.length;

        rng.setEnd(newEnd, endOffset);
      }

      return rng;
    }
904659
private IntervalRBTreeNode<T> addRange(IntervalRBTreeNode<T> n, Integer left,
      Integer right, ArrayList<MtasTreeHit<T>> list) {
    IntervalRBTreeNode<T> localN = n;
    if (localN == null) {
      String key = left.toString() + "_" + right.toString();
      localN = new IntervalRBTreeNode<>(left, right, IntervalRBTreeNode.RED, 1);
      localN.addList(list);
      index.put(key, localN);
    } else {
      if (left <= localN.left) {
        localN.leftChild = addRange(localN.leftChild, left, right, list);
        updateMaxMin(localN, localN.leftChild);
      } else {
        localN.rightChild = addRange(localN.rightChild, left, right, list);
        updateMaxMin(localN, localN.rightChild);
      }
      if (isRed(localN.rightChild) && !isRed(localN.leftChild)) {
        localN = rotateLeft(localN);
      }
      if (isRed(localN.leftChild) && isRed(localN.leftChild.leftChild)) {
        localN = rotateRight(localN);
      }
      if (isRed(localN.leftChild) && isRed(localN.rightChild)) {
        flipColors(localN);
      }
      localN.n = size(localN.leftChild) + size(localN.rightChild) + 1;
    }
    return localN;
  }
166461
def __expand_limits(ax, limits, which='x'):
    ''''''

    if which == 'x':
        getter, setter = ax.get_xlim, ax.set_xlim
    elif which == 'y':
        getter, setter = ax.get_ylim, ax.set_ylim
    else:
        raise ValueError('invalid axis: {}'.format(which))

    old_lims = getter()
    new_lims = list(limits)

    # infinite limits occur on new axis objects with no data
    if np.isfinite(old_lims[0]):
        new_lims[0] = min(old_lims[0], limits[0])

    if np.isfinite(old_lims[1]):
        new_lims[1] = max(old_lims[1], limits[1])

    setter(new_lims)
190917
function BoundingBox2D( xMin , yMin , xMax , yMax ) {
	this.min = new Vector2D( xMin , yMin ) ;
	this.max = new Vector2D( xMax , yMax ) ;
}
435003
def _interval_split(interval, only=None, context=None, event_re=re.compile("[A-Z][0-9]+")):
    
    def split_event(event):
        "Helper to parse events."
        kind, val = event[:1], event[1:]
        try:
            return kind, float(val)
        except (TypeError, ValueError):
            return None, 0

    if hasattr(interval, "fetch"):
        interval = interval.fetch("custom_activations")
    ##import sys; print >>sys.stderr, "!!!!!isplit", interval, event_re.findall(interval)

    return list(reversed([split_event(i) for i in event_re.findall(interval) if not only or i.startswith(only)]))