Returns a SQlite-compliant LIMIT statement that
    takes the *lower* and *upper* bounds into account.

    :param lower: The lower bound.
    :param upper: The upper bound.
330683
def limit(lower, upper):
    
    offset = lower or 0
    lim = (upper - offset) if upper else -1
    smt = 'LIMIT %d OFFSET %d' % (lim, offset)
    return smt, ()
193784
def move_to_limit(self, position):
        
        cmd = 'MOVE', [Float, Integer]
        self._write(cmd, position, 1)
239150
def getLimits(locations, current, sortResults=True, verbose=False):
    
    limit = {}
    for l in locations:
        a, b = current.common(l)
        if a is None:
            continue
        for name, value in b.items():
            f = a[name]
            if name not in limit:
                limit[name] = {}
                limit[name]['<'] = {}
                limit[name]['='] = {}
                limit[name]['>'] = {}
                if f > 0:
                    limit[name]['>'] = {0: [Location()]}
                elif f<0:
                    limit[name]['<'] = {0: [Location()]}
                else:
                    limit[name]['='] = {0: [Location()]}
            if current[name] < value - _EPSILON:
                if value not in limit[name]["<"]:
                    limit[name]["<"][value] = []
                limit[name]["<"][value].append(l)
            elif current[name] > value + _EPSILON:
                if value not in limit[name][">"]:
                    limit[name][">"][value] = []
                limit[name][">"][value].append(l)
            else:
                if value not in limit[name]["="]:
                    limit[name]["="][value] = []
                limit[name]["="][value].append(l)
    if not sortResults:
        return limit
    # now we have all the data, let's sort to the relevant values
    l = {}
    for name, lims in  limit.items():
        less = []
        more = []
        if lims[">"].keys():
            less = sorted(lims[">"].keys())
            lim_min = less[-1]
        else:
            lim_min = None
        if lims["<"].keys():
            more = sorted(lims["<"].keys())
            lim_max = more[0]
        else:
            lim_max = None
        if lim_min is None and lim_max is not None:
            # extrapolation < min
            if len(limit[name]['='])>0:
                l[name] = (None, list(limit[name]['='].keys())[0], None)
            elif len(more) > 1 and len(limit[name]['='])==0:
                # extrapolation
                l[name] = (None,  more[0], more[1])
        elif lim_min is not None and lim_max is None:
            # extrapolation < max
            if len(limit[name]['='])>0:
                # less > 0, M > 0, more = None
                # -> end of a limit
                l[name] = (None, limit[name]['='], None)
            elif len(less) > 1 and len(limit[name]['='])==0:
                # less > 0, M = None, more = None
                # extrapolation
                l[name] = (less[-2], less[-1], None)
        else:
            if len(limit[name]['=']) > 0:
                l[name] = (None, list(limit[name]['='].keys())[0], None)
            else:
                l[name] = (lim_min,  None, lim_max)
    return l
238091
def randbetween(lower: int, upper: int) -> int:
    
    if not isinstance(lower, int) or not isinstance(upper, int):
        raise TypeError('lower and upper must be integers')
    if lower < 0 or upper <= 0:
        raise ValueError('lower and upper must be greater than zero')

    return randbelow(upper - lower + 1) + lower
1084085
def control_low_limit(self) -> Optional[Union[int, float]]:
        
        return self._get_field_value(SpecialDevice.PROP_CONTROL_LOW_LIMIT)
192965
function isBetween(lower, upper) {
	return function (val) {
		return isNumber(val) && val > lower && val < upper;
	}
}
111217
def _generate_limit_items(lower, upper):
    
    # Use value + 0 to convert any -0.0 to 0.0 which looks better.
    if lower is not None and upper is not None and lower == upper:
        yield 'fixed', upper + 0
    else:
        if lower is not None:
            yield 'lower', lower + 0
        if upper is not None:
            yield 'upper', upper + 0
1243322
def getLowerDetectionLimit(self):
        
        ldl = self.getField('LowerDetectionLimit').get(self)
        try:
            return float(ldl)
        except ValueError:
            return 0
37975
public static int bound (int low, int value, int high)
    {
        return Math.min(high, Math.max(low, value));
    }
628211
def limit(self, limit: int) -> "QuerySet":
        
        queryset = self._clone()
        queryset._limit = limit
        return queryset
1059195
def limit(self, value):
        
        self._query = self._query.limit(value)

        return self
1194251
def limitsSql(startIndex=0, maxResults=0):
    
    if startIndex and maxResults:
        return " LIMIT {}, {}".format(startIndex, maxResults)
    elif startIndex:
        raise Exception("startIndex was provided, but maxResults was not")
    elif maxResults:
        return " LIMIT {}".format(maxResults)
    else:
        return ""
378300
def range_by_lex(self, low, high, start=None, num=None, reverse=False):
        
        if reverse:
            fn = self.database.zrevrangebylex
            low, high = high, low
        else:
            fn = self.database.zrangebylex
        return fn(self.key, low, high, start, num)
288135
def _constraint_lb_and_ub_to_gurobi_sense_rhs_and_range_value(lb, ub):
    """"""
    if lb is None and ub is None:
        raise Exception("Free constraint ...")
    elif lb is None:
        sense = '<'
        rhs = float(ub)
        range_value = 0.
    elif ub is None:
        sense = '>'
        rhs = float(lb)
        range_value = 0.
    elif lb == ub:
        sense = '='
        rhs = float(lb)
        range_value = 0.
    elif lb > ub:
        raise ValueError("Lower bound is larger than upper bound.")
    else:
        sense = '='
        rhs = float(lb)
        range_value = float(ub - lb)
    return sense, rhs, range_value
862994
def _clip(value, lower, upper):
    
    return lower if value < lower else upper if value > upper else value
836354
def range_pad(lower, upper, padding=None, log=False):
    
    if padding is not None and not isinstance(padding, tuple):
        padding = (padding, padding)
    if is_number(lower) and is_number(upper) and padding is not None:
        if not isinstance(lower, datetime_types) and log and lower > 0 and upper > 0:
            log_min = np.log(lower) / np.log(10)
            log_max = np.log(upper) / np.log(10)
            lspan = (log_max-log_min)*(1+padding[0]*2)
            uspan = (log_max-log_min)*(1+padding[1]*2)
            center = (log_min+log_max) / 2.0
            start, end = np.power(10, center-lspan/2.), np.power(10, center+uspan/2.)
        else:
            if isinstance(lower, datetime_types) and not isinstance(lower, cftime_types):
                # Ensure timedelta can be safely divided
                lower, upper = np.datetime64(lower), np.datetime64(upper)
                span = (upper-lower).astype('>m8[ns]')
            else:
                span = (upper-lower)
            lpad = span*(padding[0])
            upad = span*(padding[1])
            start, end = lower-lpad, upper+upad
    else:
        start, end = lower, upper

    return start, end
877454
def limit(self, n):
    
    data = self._data
    self._data = (next(data) for _ in xrange(int(round(n))))
    return self