Check if the variable values are within the limits.

        Return False if fails.
341662
def check_limit(self, varname, vmin=None, vmax=None):
        
        retval = True
        assert varname in self.__dict__

        if varname in self._algebs:
            val = self.system.dae.y[self.__dict__[varname]]
        elif varname in self._states:
            val = self.system.dae.x[self.__dict__[varname]]
        else:  # service or temporary variable
            val = matrix(self.__dict__[varname])

        vmin = matrix(self.__dict__[vmin])
        comp = altb(val, vmin)
        comp = mul(self.u, comp)
        for c, n, idx in zip(comp, self.name, range(self.n)):
            if c == 1:
                v = val[idx]
                vm = vmin[idx]
                self.log(
                    'Init of <{}.{}>={:.4g} is lower than min={:6.4g}'.format(
                        n, varname, v, vm), ERROR)
                retval = False

        vmax = matrix(self.__dict__[vmax])
        comp = agtb(val, vmax)
        comp = mul(self.u, comp)
        for c, n, idx in zip(comp, self.name, range(self.n)):
            if c == 1:
                v = val[idx]
                vm = vmax[idx]
                self.log(
                    'Init of <{}.{}>={:.4g} is higher than max={:.4g}'.format(
                        n, varname, v, vm), ERROR)
                retval = False
        return retval
68179
def isAboveUpperDetectionLimit(self):
        
        if self.isUpperDetectionLimit():
            return True

        result = self.getResult()
        if result and str(result).strip().startswith(UDL):
            return True

        if api.is_floatable(result):
            return api.to_float(result) > self.getUpperDetectionLimit()

        return False
1348910
def check(self, value, major):
        
        if self._min is not None and value < self._min:
            raise ValueError("Integer %d is lower than minimum %d."
                             % (value, self._min))
        if self._max is not None and value > self._max:
            raise ValueError("Integer %d is higher than maximum %d."
                             % (value, self._max))
714799
def _safe_minmax(values):
    """"""

    # Nan and inf guarded min and max
    isfinite = np.isfinite(values)
    if np.any(isfinite):
        # Only use finite values
        values = values[isfinite]

    minval = np.min(values)
    maxval = np.max(values)

    return minval, maxval
200403
def has_bounds(self):
        """"""
        bounds = self.bounds
        if bounds in (None, [None, None]):
            return False
        for ib, bound in enumerate(bounds):
            if bound is not None:
                sign_ = 2 * ib - 1
                for bound_i in bound:
                    if bound_i is not None and sign_ * bound_i < np.inf:
                        return True
        return False
13311
public boolean hasBoundaryMatches()
    {
        for (Transition<DFAState<T>> t : transitions.values())
        {
            CharRange range = t.getCondition();
            if (range.getFrom() < 0)
            {
                return true;
            }
        }
        return false;
    }
40701
def _check_bounds(self, v):
        
        below_bounds = v < self._x[0]
        above_bounds = v > self._x[-1]

        if self.bounds_error and below_bounds.any():
            raise ValueError("A value in x_new is below the interpolation "
                "range.")
        if self.bounds_error and above_bounds.any():
            raise ValueError("A value in x_new is above the interpolation "
                "range.")

        return below_bounds, above_bounds
1296323
def check_limit(self, limit):
        
        if limit > 0:
            self.limit = limit
        else:
            raise ValueError("Rule limit must be strictly > 0 ({0} given)"
                             .format(limit))

        return self
146218
public boolean containsBadValues() {
    	for(int i=0; i<values.length; i++) {
    		if(s.isNaN(values[i])) {
    			return true;
    		}
    		if (s.lt(values[i], s.zero()) || values[i] == s.posInf()) {
    			return true;
    		}
    	}
    	return false;
    }
886775
def validate_VALUERANGE(in_value, restriction):
    
    if len(restriction) != 2:
        raise ValidationError("Template ERROR: Only two values can be specified in a date range.")
    value = _get_val(in_value)
    if type(value) is list:
        for subval in value:
            if type(subval) is tuple:
                subval = subval[1]
            validate_VALUERANGE(subval, restriction)
    else:
        min_val = Decimal(restriction[0])
        max_val = Decimal(restriction[1])
        val     = Decimal(value)
        if val < min_val or val > max_val:
            raise ValidationError("VALUERANGE: %s, %s"%(min_val, max_val))
898515
def _check_hint_bounds(self, ds):
        '''
        
        '''
        ret_val = []
        boundary_variables = cfutil.get_cell_boundary_variables(ds)
        for name in ds.variables:
            if name.endswith('_bounds') and name not in boundary_variables:
                msg = ('{} might be a cell boundary variable but there are no variables that define it '
                       'as a boundary using the `bounds` attribute.'.format(name))
                result = Result(BaseCheck.LOW,
                                True,
                                self.section_titles['7.1'],
                                [msg])
                ret_val.append(result)

        return ret_val
1333564
def all_enclosing_scopes(scope, allow_global=True):
  """"""

  _validate_full_scope(scope)

  # TODO: validate scopes here and/or in `enclosing_scope()` instead of assuming correctness.
  def scope_within_range(tentative_scope):
    if tentative_scope is None:
      return False
    if not allow_global and tentative_scope == GLOBAL_SCOPE:
      return False
    return True

  while scope_within_range(scope):
    yield scope
    scope = (None if scope == GLOBAL_SCOPE else enclosing_scope(scope))
1206727
def check_limits(user_rule):
    

    def wrapper(*args, **kwargs):
        """The body of the decorator """
        global _state
        _state["cnt_elements"] += 1
        _state["depth"] += 1
        matrix = _state["ctx"].get_matrix()
        # TODO: add check of transparency = 0
        if _state["depth"] >= MAX_DEPTH:
            logger.info("stop recursion by reaching max depth {}".format(MAX_DEPTH))
        else:
            min_size_scaled = SIZE_MIN_FEATURE / min(WIDTH, HEIGHT)
            current_scale = max([abs(matrix[i]) for i in range(2)])
            if (current_scale < min_size_scaled):
                logger.info("stop recursion by reaching min feature size")
                # TODO: check feature size with respect to current ink size
            else:
                if _state["cnt_elements"] > MAX_ELEMENTS:
                    logger.info("stop recursion by reaching max elements")
                else:
                    user_rule(*args, **kwargs)
        _state["depth"] -= 1
    return wrapper
1061861
def var_contains(var, value):
    '''
    
    '''
    setval = get_var(var)
    # Remove any escaping that was needed to past through salt
    value = value.replace('\\', '')
    if setval is None:
        return False
    return value in setval.split()
909523
def q_limited(self):
        
        if (self.q >= self.q_max) or (self.q <= self.q_min):
            return True
        else:
            return False
459328
private int rangeCheck(int value, int begin, int end) {
        if (value >= begin && value <= end) { // (begin,end]
            return value;
        }

        throw new IllegalArgumentException("Value [" + value + "] not in range [" + begin + "," + end + "]");
    }
917294
function (value, min, max) {
        min = min | 0;
        let length = ((value || '') + '').length;
        if (length < min) {
            return false;
        }
        if (max && length > max) {
            return false;
        }
        return true;
    }