Transform an 'elm' constraint into a proper one.

 @param elm_constraint [String] The elm constraint

 @return [Array] The transform constraints
424262
def transform_constraint(elm_constraint)
      elm_constraint.gsub!(/\s/, '')

      CONVERTERS
        .map { |regexp, prefix| [elm_constraint.match(regexp), prefix] }
        .select { |(match)| match }
        .map { |(match, prefix)| "#{prefix} #{match[1]}" }
        .map { |constraint| Solve::Constraint.new constraint }
    end
317312
def format_python_constraint(constraint):
    
    if isinstance(constraint, Version):
        if constraint.precision >= 3:
            return "=={}".format(str(constraint))

        # Transform 3.6 or 3
        if constraint.precision == 2:
            # 3.6
            constraint = parse_constraint(
                "~{}.{}".format(constraint.major, constraint.minor)
            )
        else:
            constraint = parse_constraint("^{}.0".format(constraint.major))

    if not isinstance(constraint, VersionUnion):
        return str(constraint)

    formatted = []
    accepted = []

    for version in PYTHON_VERSION:
        version_constraint = parse_constraint(version)
        matches = constraint.allows_any(version_constraint)
        if not matches:
            formatted.append("!=" + version)
        else:
            accepted.append(version)

    # Checking lower bound
    low = accepted[0]

    formatted.insert(0, ">=" + ".".join(low.split(".")[:2]))

    return ", ".join(formatted)
134924
def build_constraint_matrix(constrs)
      store_constraint_indexes constrs

      # Construct a matrix of non-zero values in CSC format
      start = []
      index = []
      value = []
      col_start = 0
      @variables.each do |var|
        # Mark the start of this column
        start << col_start

        var.constraints.each do |constr|
          col_start += 1
          index << constr.index
          value << constr.expression.terms[var]
        end
      end
      start << col_start

      [start, index, value]
    end
759948
def process_soln_constraints(workspace, solution_constraints, valid_packages)
      gecode = workspace.gecode_wrapper

      # create shadow package whose dependencies are the solution constraints
      soln_constraints_pkg_id = gecode.add_package(0, 0, 0)

      soln_constraints_on_non_existent_packages = []
      soln_constraints_that_match_no_versions = []

      # generate constraints imposed by solution_constraints
      solution_constraints.each do |soln_constraint|
        # look up the package in the cloned dep_graph that corresponds to soln_constraint
        pkg_name = soln_constraint.package.name
        pkg = workspace.package(pkg_name)
        constraint = soln_constraint.constraint

        # record invalid solution constraints and raise an exception
        # afterwards
        unless pkg.valid? || (valid_packages && valid_packages.include?(pkg))
          soln_constraints_on_non_existent_packages << soln_constraint
          next
        end
        if pkg[constraint].empty?
          soln_constraints_that_match_no_versions << soln_constraint
          next
        end

        pkg_id = pkg.gecode_package_id

        gecode.mark_preferred_to_be_at_latest(pkg_id, 10)
        gecode.mark_required(pkg_id)

        if constraint
          acceptable_versions = pkg.densely_packed_versions[constraint]
          gecode.add_version_constraint(soln_constraints_pkg_id, 0, pkg_id, acceptable_versions.min, acceptable_versions.max)
        else
          # this restricts the domain of the variable to >= 0, which
          # means -1, the shadow package, cannot be assigned, meaning
          # the package must be bound to an actual version
          gecode.add_version_constraint(soln_constraints_pkg_id, 0, pkg_id, 0, pkg.densely_packed_versions.range.max)
        end
      end

      if soln_constraints_on_non_existent_packages.any? || soln_constraints_that_match_no_versions.any?
        raise Exceptions::InvalidSolutionConstraints.new(soln_constraints_on_non_existent_packages,
                                                         soln_constraints_that_match_no_versions)
      end
    end
363826
function () {
			var args = slice.call(arguments),
				constraint = options.args_map.getOrPut(args, function() {
					return new Constraint(function () {
						return getter_fn.apply(options.context, args);
					});
				});
			return constraint.get();
		}
577293
def _get_constraints(self):
        """"""
        num_edges = len(self.edges)
        for k in range(num_edges):
            for i in range(num_edges):
                # add to constraints if i shared an edge with k
                if k != i and self.edges[k].is_adjacent(self.edges[i]):
                    self.edges[k].neighbors.append(i)
143033
function mergeConstraints(env, oldConstraints, newConstraints) {
	const res = {
		min: Math.max(oldConstraints.min || 0, newConstraints.min || 0),
		max: Math.min(
			oldConstraints.max !== undefined ? oldConstraints.max : 2,
			newConstraints.max !== undefined ? newConstraints.max : 2
		),
		force: oldConstraints.force || newConstraints.force,
	};

	if (res.min > res.max) {
		// If oldConstraints.force is set, older constraints win
		if (!oldConstraints.force) {
			// let newConstraints win, but complain
			if (newConstraints.max !== undefined && newConstraints.max > res.min) {
				res.max = newConstraints.max;
			} else if (newConstraints.min && newConstraints.min < res.min) {
				res.min = newConstraints.min;
			}
		}
		res.max = res.min;
		env.log("info/html2wt", 'Incompatible constraints (merge):', res,
			loggableConstraints(oldConstraints), loggableConstraints(newConstraints));
	}

	return res;
}
1307988
def convert_norm(node, **kwargs):
    
    name, input_nodes, attrs = get_inputs(node, kwargs)

    mx_axis = attrs.get("axis", None)
    axes = convert_string_to_list(str(mx_axis)) if mx_axis else None

    keepdims = get_boolean_attribute_value(attrs, "keepdims")
    ord = int(attrs.get("ord", 2))

    onnx_op_name = "ReduceL1" if ord == 1 else "ReduceL2"

    if axes:
        reduce_node = onnx.helper.make_node(
            onnx_op_name,
            input_nodes,
            [name],
            axes=axes,
            keepdims=keepdims,
            name=name
        )
        return [reduce_node]
    else:
        reduce_node = onnx.helper.make_node(
            onnx_op_name,
            input_nodes,
            [name],
            keepdims=keepdims,
            name=name
        )
        return [reduce_node]
324693
def initial_solve_constraints
      @identifier.initial_dependencies.flat_map do |dependency|
        dependency.constraints.map do |constraint|
          [dependency.name, constraint]
        end
      end
    end
978390
def _generate_actual_grp_constraints(network_constraints):
    
    if 'constraints' not in network_constraints:
        return []

    constraints = network_constraints['constraints']
    actual = []
    for desc in constraints:
        descs = _expand_description(desc)
        for desc in descs:
            actual.append(desc)
            if 'symetric' in desc:
                sym = desc.copy()
                sym['src'] = desc['dst']
                sym['dst'] = desc['src']
                actual.append(sym)
    return actual
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
767281
public org.tensorflow.framework.KernelDef.AttrConstraint getConstraint(int index) {
    return constraint_.get(index);
  }
1239336
def constrained_to(self, initial_sequence: torch.Tensor, keep_beam_details: bool = True) -> 'BeamSearch':
        
        return BeamSearch(self._beam_size, self._per_node_beam_size, initial_sequence, keep_beam_details)
301946
def in_constraint(self, node1, node2):
        """"""
        constraint = constraint_table[node2]
        if constraint == 0b0:
            return False

        try:
            value = self.el2bv[node1]
        except KeyError:
            return False

        return constraint & value != 0
808900
def check_opts(constraints, opts)
      opts ||= {}
      opts.each{|k,v| raise "opt not permitted: #{k.inspect}" if !constraints.has_key?(k)}
      Hash[constraints.map do |k,constraint|
             if opts.has_key?(k)
               v = opts[k]
               if constraint.is_a?(Array)
                 raise "unknown value for opt #{k.inspect}: #{v.inspect}. permitted values are: #{constraint.inspect}" if !constraint.include?(v)
                 [k,v]
               elsif constraint.is_a?(Hash)
                 raise "opt #{k.inspect} must be a Hash" if !v.is_a?(Hash)
                 [k,check_opts(constraint, v || {})]
               else
                 [k,v]
               end
             end
           end]
    end
268704
def constraints(self, chunk):
        
        a = [self._map1[w.index] for w in chunk.words if w.index in self._map1]
        b = []; [b.append(constraint) for constraint in a if constraint not in b]
        return b
135603
def replace_constraint(self,name,**kwargs):
        

        for pop in self.poplist:
            pop.replace_constraint(name,**kwargs)
        if name not in self.constraints:
            self.constraints.append(name)