Define variables within the namespace.

        This is similar to :meth:`.Problem.define` except that names must be
        given as an iterable. This method accepts the same keyword arguments
        as :meth:`.Problem.define`.
11239
def define(self, names, **kwargs):
        
        define_kwargs = dict(self._define_kwargs)
        define_kwargs.update(kwargs)
        self._problem.define(
            *((self, name) for name in names), **define_kwargs)
977861
def _compute_search_spaces(self, used_variables):
        
        return tuple(len(domain) for name, domain in self._vars.iteritems())
105128
def variable(self):
        """"""
        # Use a character invalid in python identifiers to avoid clashing.
        name = "@py_assert" + str(next(self.variable_counter))
        self.variables.append(name)
        return name
1354743
def create_variable(descriptor):
    
    if descriptor['type'] == 'continuous':
        return ContinuousVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', 1))
    elif descriptor['type'] == 'bandit':
        return BanditVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', None))  # bandits variables cannot be repeated
    elif descriptor['type'] == 'discrete':
        return DiscreteVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', 1))
    elif descriptor['type'] == 'categorical':
        return CategoricalVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', 1))
    else:
        raise InvalidConfigError('Unknown variable type ' + descriptor['type'])
1336252
def variables(template):
    ''''''
    vars = set()
    for varlist in TEMPLATE.findall(template):
        if varlist[0] in OPERATOR:
            varlist = varlist[1:]
        varspecs = varlist.split(',')
        for var in varspecs:
            # handle prefix values
            var = var.split(':')[0]
            # handle composite values
            if var.endswith('*'):
                var = var[:-1]
            vars.add(var)
    return vars
191518
def _create_variables_dic(self):
        
        self.name_to_variable = {}
        for variable in self.space_expanded:
            self.name_to_variable[variable.name] = variable
849182
def namespaces(
            self,
            name=None,
            function=None,
            recursive=None,
            allow_empty=None):
        

        return (
            self._find_multiple(
                scopedef.scopedef_t._impl_matchers[namespace_t.namespace],
                name=name,
                function=function,
                recursive=recursive,
                allow_empty=allow_empty)
        )
515194
def variables(
            self,
            name=None,
            function=None,
            decl_type=None,
            header_dir=None,
            header_file=None,
            recursive=None,
            allow_empty=None):

        """"""
        return (
            self._find_multiple(
                self._impl_matchers[
                    scopedef_t.variable],
                name=name,
                function=function,
                decl_type=decl_type,
                header_dir=header_dir,
                header_file=header_file,
                recursive=recursive,
                allow_empty=allow_empty)
        )
450881
def _bind_variables(self, instance, space):
        
        instance.api = self
        if space:
            instance.space = space
        return instance
1127905
def set(self, name, value):
        
        if self.vars is None:
            self.vars = {}
        self.vars[name] = value
663345
def method_missing(meth, *args, &block)
      meth_str = meth.to_s

      if /^(\w+)\=$/.match(meth_str)
        _set($1, *args, &block)
      elsif args.length > 0 || block_given?
        _add(meth, *args, &block)
      elsif /^(\w+)\?$/.match(meth_str)
        !!_get($1)
      else
        _get_or_create_namespace(meth)
      end
    end
772313
def add_variable(self, name):
        """"""
        if name in self._variables:
            raise ValueError(
                "A variable named " + name + " already exists."
            )
        self._variables[name] = len(self._variables)
        self.bounds[name] = (0, None)

        new_col = np.zeros(shape=[len(self._constraints), 1])
        self._add_col_to_A(new_col)
        self._reset_solution()
549404
def add_variable(self, node):
        
        if node.name not in self.variable_names:
            self.variables.append(node)
            self.variable_names.add(node.name)
            node.parent = self
1252440
def define(cls, name, parent=None, interleave=False):
        """"""
        node = cls("define", parent, interleave=interleave)
        node.occur = 0
        node.attr["name"] = name
        return node
852263
def resolve_variables(self, task):
        

        variables = {**task.variables, **self.project.variables}

        values = {}

        for variable in variables.values():
            value = self.variables.get(variable.name) or variable.default
            if value is None:
                raise LookupError(variable)
            values[variable.name] = value

        return values
571425
def p_namespace(self, p):
        ''''''
        p[0] = ast.Namespace(scope=p[2], name=p[3], lineno=p.lineno(1))
579068
def namespace(self, value):
        
        if not isinstance(value, str):
            raise ValueError("Namespace must be a string")
        self._namespace = value