Returns the constraint callable given a value
506377
def constraint_from_type(cls, value):
        
        if value is None:
            return None
        value_type = type(value)
        if value_type in (str, int, bool):
            return value_type
        raise ParameterError('Parameter type cannot be %s' % value_type)
1236308
def constrain(value, lower=-np.Inf, upper=np.Inf, allow_equal=False):
    

    ok = flib.constrain(value, lower, upper, allow_equal)
    if ok == 0:
        raise ZeroProbability
1270970
def create_query_constraint():
    
    op = oneOf("= < > >= <= != <>", caseless=True).setName("operator")
    basic_constraint = (var + op + var_val).setResultsName("operator")
    between = (
        var + Suppress(upkey("between")) + value + Suppress(and_) + value
    ).setResultsName("between")
    is_in = (var + Suppress(upkey("in")) + set_).setResultsName("in")
    fxn = (
        function("attribute_exists", var)
        | function("attribute_not_exists", var)
        | function("attribute_type", var, types)
        | function("begins_with", var, Group(string))
        | function("contains", var, value)
        | (function("size", var) + op + value)
    ).setResultsName("function")
    all_constraints = between | basic_constraint | is_in | fxn
    return Group(all_constraints).setName("constraint")
778813
def constraint_matches(self, c, m):
        
        if isinstance(m, tuple):
            d = {}
            if isinstance(c, Operator) and c._op_name == m[0]:
                for c1, m1 in zip(c._args, m[1:]):
                    r = self.constraint_matches(c1, m1)
                    if r is False:
                        return r
                    d.update(r)
                return d
            return False
        return m.match(c)
833123
private static Optional<String> getMethodReturnValueName(ConstraintViolation<?> violation) {
        int returnValueNames = -1;

        final StringBuilder result = new StringBuilder("server response");
        for (Path.Node node : violation.getPropertyPath()) {
            if (node.getKind().equals(ElementKind.RETURN_VALUE)) {
                returnValueNames = 0;
            } else if (returnValueNames >= 0) {
                result.append(returnValueNames++ == 0 ? " " : ".").append(node);
            }
        }

        return returnValueNames >= 0 ? Optional.of(result.toString()) : Optional.empty();
    }
627183
def callable(cls, nans=False, reverse=False, scalar=False):
        
        _valgetter = cls._valgetter_scalar if scalar else cls._valgetter
        valgetter = nb.njit(_valgetter)
        outersetter = nb.njit(cls._outersetter)

        _cls_inner = nb.njit(cls._inner)
        if nans:
            def _inner(ri, val, ret, counter, mean):
                if not np.isnan(val):
                    _cls_inner(ri, val, ret, counter, mean)
            inner = nb.njit(_inner)
        else:
            inner = _cls_inner

        def _loop(group_idx, a, ret, counter, mean, outer, fill_value, ddof):
            # fill_value and ddof need to be present for being exchangeable with loop_2pass
            size = len(ret)
            rng = range(len(group_idx) - 1, -1 , -1) if reverse else range(len(group_idx))
            for i in rng:
                ri = group_idx[i]
                if ri < 0:
                    raise ValueError("negative indices not supported")
                if ri >= size:
                    raise ValueError("one or more indices in group_idx are too large")
                val = valgetter(a, i)
                inner(ri, val, ret, counter, mean)
                outersetter(outer, i, ret[ri])
        return nb.njit(_loop, nogil=True)
692060
def indicator_constraints(self,x):
        
        x = np.atleast_2d(x)
        I_x = np.ones((x.shape[0],1))
        if self.constraints is not None:
            for d in self.constraints:
                try:
                    exec('constraint = lambda x:' + d['constraint'], globals())
                    ind_x = (constraint(x) <= 0) * 1
                    I_x *= ind_x.reshape(x.shape[0],1)
                except:
                    print('Fail to compile the constraint: ' + str(d))
                    raise
        return I_x
103918
def Constant(cls, irsb_c, val, ty):
        
        assert not (isinstance(val, VexValue) or isinstance(val, IRExpr))
        rdt = irsb_c.mkconst(val, ty)
        return cls(irsb_c, rdt)
29522
def from_callable_parameter(cls, parameter):
        
        if parameter.kind == parameter.KEYWORD_ONLY or \
                parameter.kind == parameter.POSITIONAL_OR_KEYWORD and parameter.default is not parameter.empty:
            if parameter.annotation is not parameter.empty:
                constraint = parameter.annotation
            else:
                constraint = Parameter.constraint_from_type(parameter.default)
            return cls(
                name=parameter.name,
                value=parameter.default,
                constraint=constraint,
            )
        else:
            raise ParameterError('Only keyword parameters are supported')
740525
int getConstraintIndex(String constraintName) {

        for (int i = 0, size = constraintList.length; i < size; i++) {
            if (constraintList[i].getName().name.equals(constraintName)) {
                return i;
            }
        }

        return -1;
    }
66327
function Constraint(constraintName, constraintPayload) {
	var name = constraintName;
	var payload = constraintPayload;

	/**
	 * The constraint name.
	 * @returns {String} a name
	 */
	this.getName = function () {
		return name;
	};

	/**
	 * Sets the name of the constraint.
	 * @param {String} n name
	 */
	this.setName = function (n) {
		name = n;
	};

	/**
	 * The payload (a map)
	 * @returns {Object} an object
	 */
	this.getPayload = function () {
		return payload;
	};

	/**
	 * Sets the payload.
	 * @param {Object} p the payload object
	 */
	this.setPayload = function (p) {
		payload = p;
	};
}
1113616
public static ConstraintField getInstance(int value)
   {
      ConstraintField result = null;

      if (value >= 0 && value < FIELD_ARRAY.length)
      {
         result = FIELD_ARRAY[value];
      }

      return (result);
   }
470432
def constraint_to_si(expr):
    

    satisfiable = True
    replace_list = [ ]

    satisfiable, replace_list = backends.vsa.constraint_to_si(expr)

    # Make sure the replace_list are all ast.bvs
    for i in xrange(len(replace_list)):
        ori, new = replace_list[i]
        if not isinstance(new, Base):
            new = BVS(new.name, new._bits, min=new._lower_bound, max=new._upper_bound, stride=new._stride, explicit_name=True)
            replace_list[i] = (ori, new)

    return satisfiable, replace_list
539211
def is_callable(instance, attribute, value):
    """"""

    if not callable(value):
        raise TypeError("'{}' must be callable".format(attribute.name))
294440
def from_string(cls, constraint):
        
        obj = constraint.split(':')
        marathon_constraint = cls.from_json(obj)

        if marathon_constraint:
            return marathon_constraint

        raise ValueError("Invalid string format. "
                         "Expected `field:operator:value`")
520689
def _constraint(self, params):
        
        if (params["spin1x"]**2 + params["spin1y"]**2 +
                params["spin1z"]**2)**2 > 1:
            return False
        elif (params["spin2x"]**2 + params["spin2y"]**2 +
                  params["spin2z"]**2)**2 > 1:
            return False
        else:
            return True
1217602
function constraintsRepr(
    constraints,    // :: StrMap (Array TypeClass)
    outer,          // :: String -> String
    inner           // :: String -> TypeClass -> String -> String
  ) {
    var $reprs = [];
    (sortedKeys (constraints)).forEach (function(k) {
      var f = inner (k);
      constraints[k].forEach (function(typeClass) {
        $reprs.push (f (typeClass) (stripNamespace (typeClass) + ' ' + k));
      });
    });
    return when ($reprs.length > 0)
                (wrap ('') (outer (' => ')))
                (when ($reprs.length > 1)
                      (parenthesize (outer))
                      (joinWith (outer (', '), $reprs)));
  }