Generate upper and lower limits based on x and y, and delta's.
176899
void setFromFractions(final double latFraction, final double lonFraction,
                          final double latFractionDelta, final double lonFractionDelta) {
        assert (lonFractionDelta >= 0.0);
        assert (latFractionDelta != 0.0);
        lonFractionMin = lonFraction;
        lonFractionMax = lonFraction + lonFractionDelta;
        if (latFractionDelta < 0) {
            latFractionMin = latFraction + 1 + latFractionDelta;    // y + yDelta can NOT be represented.
            latFractionMax = latFraction + 1;                       // y CAN be represented.
        } else {
            latFractionMin = latFraction;
            latFractionMax = latFraction + latFractionDelta;
        }
    }
1226886
def limit_y(
        self,
        limit_lower = None,
        limit_upper = None
        ):

        

        if limit_lower is None and limit_upper is None:
            return self._limit_y
        elif hasattr(limit_lower, "__iter__"):
            self._limit_y = limit_lower[:2]
        else:
            self._limit_y = [limit_lower, limit_upper]
        if self._limit_y[0] == self._limit_y[1]:
            self._limit_y[1] += 1
        self._limit_y[0] -= self.mod_y
        self._limit_y[1] += self.mod_y
172594
def _MakeRanges(pairs):
  """"""
  ranges = []
  last = -100

  def evenodd(last, a, b, r):
    if a != last+1 or b != _AddDelta(a, r[2]):
      return False
    r[1] = a
    return True

  def evenoddpair(last, a, b, r):
    if a != last+2:
      return False
    delta = r[2]
    d = delta
    if type(delta) is not str:
      return False
    if delta.endswith('Skip'):
      d = delta[:-4]
    else:
      delta = d + 'Skip'
    if b != _AddDelta(a, d):
      return False
    r[1] = a
    r[2] = delta
    return True

  for a, b in pairs:
    if ranges and evenodd(last, a, b, ranges[-1]):
      pass
    elif ranges and evenoddpair(last, a, b, ranges[-1]):
      pass
    else:
      ranges.append([a, a, _Delta(a, b)])
    last = a
  return ranges
949517
def open01(x, limit=1.e-6):
    """"""
    try:
        return np.array([min(max(y, limit), 1. - limit) for y in x])
    except TypeError:
        return min(max(x, limit), 1. - limit)
916287
def getLimit(self, alpha, upper=True):
        
        dlnl = onesided_cl_to_dlnl(1.0 - alpha)
        return self.getDeltaLogLike(dlnl, upper=upper)
250616
def apply_bbox(sf,ax):
    
    limits = sf.bbox
    xlim = limits[0],limits[2]
    ylim = limits[1],limits[3]
    ax.set_xlim(xlim)
    ax.set_ylim(ylim)
227094
def xlim(self, low, high):
        
        self.chart['xAxis'][0]['min'] = low
        self.chart['xAxis'][0]['max'] = high
        return self
227111
def non_increasing(values):
    """"""
    return all(x >= y for x, y in zip(values, values[1:]))
78188
def limits(self, x1, x2, y1, y2):
        """"""

        self.x1 = x1
        self.x2 = x2
        self.y1 = y1
        self.y2 = y2
        self.xscale = (self.cx2 - self.cx1) / (self.x2 - self.x1)
        self.yscale = (self.cy2 - self.cy1) / (self.y2 - self.y1)

        # Determine the limits of the canvas
        (cx1, cy1) = self.p2c((0, -math.pi / 2.0))
        (cx2, cy2) = self.p2c((2 * math.pi, math.pi / 2.0))
        # # set the scroll region to the size of the camvas plus a boundary to allow the canvas edge to be at centre
        self.config(scrollregion=(
            cx2 - self.width / 2.0, cy2 - self.height / 2.0, cx1 + self.width / 2.0, cy1 + self.height / 2.0))
432916
def clamp(n, lower, upper):
    
    if lower > upper:
        lower, upper = upper, lower
    return max(min(upper, n), lower)
324221
def _set_lim_and_transforms(self):
        
        # Get the standard transform setup from the Axes base class
        Axes._set_lim_and_transforms(self)

        # Need to put the skew in the middle, after the scale and limits,
        # but before the transAxes. This way, the skew is done in Axes
        # coordinates thus performing the transform around the proper origin
        # We keep the pre-transAxes transform around for other users, like the
        # spines for finding bounds
        self.transDataToAxes = (self.transScale
                                + (self.transLimits
                                   + transforms.Affine2D().skew_deg(self.rot, 0)))

        # Create the full transform from Data to Pixels
        self.transData = self.transDataToAxes + self.transAxes

        # Blended transforms like this need to have the skewing applied using
        # both axes, in axes coords like before.
        self._xaxis_transform = (
            transforms.blended_transform_factory(self.transScale + self.transLimits,
                                                 transforms.IdentityTransform())
            + transforms.Affine2D().skew_deg(self.rot, 0)) + self.transAxes
625975
def _get_deltas(event):
        """"""
        delta_x = round(event.deltaX())
        delta_y = round(event.deltaY())
        delta_z = round(event.deltaZ())
        return delta_x, delta_y, delta_z
474502
private float limit(float value, float min, float max) {
    return Math.min(Math.max(min, value), max);
  }
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)
523376
def genslices(n):
    """"""
    def range_with_none():
        yield None
        yield from range(-n, n+1)

    for t in product(range_with_none(), range_with_none(), range_with_none()):
        s = slice(*t)
        if s.step != 0:
            yield s
1321516
def setedgeval(delta, is_multigraph, graph, orig, dest, idx, key, value):
    """"""
    if is_multigraph(graph):
        if (
            graph in delta and 'edges' in delta[graph] and
            orig in delta[graph]['edges'] and dest in delta[graph]['edges'][orig]
            and idx in delta[graph]['edges'][orig][dest]
            and not delta[graph]['edges'][orig][dest][idx]
        ):
            return
        delta.setdefault(graph, {}).setdefault('edge_val', {})\
            .setdefault(orig, {}).setdefault(dest, {})\
            .setdefault(idx, {})[key] = value
    else:
        if (
                                    graph in delta and 'edges' in delta[graph] and
                                orig in delta[graph]['edges'] and dest in delta[graph]['edges'][orig]
                and not delta[graph]['edges'][orig][dest]
        ):
            return
        delta.setdefault(graph, {}).setdefault('edge_val', {})\
            .setdefault(orig, {}).setdefault(dest, {})[key] = value
1078972
def gen_rsd_cdf(K, delta, c):
    """"""

    mu = gen_mu(K, delta, c)
    return [sum(mu[:d+1]) for d in range(K)]