Build set of variables from list.

    Args:
        lovs: nested lists of variables such as the one produced by
            :func:`list_of_vars`.
    Returns:
        set of str: flattened set of all the variables present in the
        nested lists.
965674
def set_of_vars(lovs):
    
    return set(var for pvars in lovs for svars in pvars for var in svars)
1059714
def indexes(self) -> 'Mapping[Any, pd.Index]':
        
        if self._indexes is None:
            self._indexes = default_indexes(self._variables, self._dims)
        return Indexes(self._indexes)
368867
def reinit_nested_vars(variables, indices=None):
  
  if isinstance(variables, (tuple, list)):
    return tf.group(*[
        reinit_nested_vars(variable, indices) for variable in variables])
  if indices is None:
    return variables.assign(tf.zeros_like(variables))
  else:
    zeros = tf.zeros([tf.shape(indices)[0]] + variables.shape[1:].as_list())
    return tf.scatter_update(variables, indices, zeros)
1032388
def get_variables(self) -> Set[str]:
        
        variables = set()
        for cmd in self._cmd:
            for var in self.__formatter.parse(cmd):
                logger.debug("Checking variable: %s", var)
                # creates and requires are special class values
                if var[1] is not None and var[1] not in ["creates", "requires"]:
                    variables.add(var[1])
        return variables
520518
def get_vars(self):
        
        if self.parent is None:
            vars = {}
            vars.update(self.variables)
            return vars
        vars = self.parent.get_vars()
        vars.update(self.variables)
        return vars
88878
def collect_variables(self, g_scope='gen', d_scope='discrim'):
        
        self.g_vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, g_scope)
        assert self.g_vars
        self.d_vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, d_scope)
        assert self.d_vars
695465
def _level_coords(self):
        
        level_coords = OrderedDict()
        for cname, var in self._coords.items():
            if var.ndim == 1 and isinstance(var, IndexVariable):
                level_names = var.level_names
                if level_names is not None:
                    dim, = var.dims
                    level_coords.update({lname: dim for lname in level_names})
        return level_coords
741303
def set_env_vars(variables)
      save_vars = {}
      variables.each do |k, v|
        k = k.to_s
        save_vars[k] = ENV[k]
        ENV[k] = v.nil? ? v : v.to_s
      end
      begin
        yield
      ensure
        variables.each_key do |k|
          k = k.to_s
          ENV[k] = save_vars[k]
        end
      end
      true
    end
360864
def get_safe_variables(self,query,var_dict):
        '''  '''

        variables_bounded_to_constants = []

        for constraint in query.constraints:
            if (constraint.get_left_side().is_variable() and
                constraint.get_right_side().is_constant() and
                constraint.is_equality_constraint()):
                    variables_bounded_to_constants.append(constraint.get_left_side())

        safe_variables = list(var_dict) + variables_bounded_to_constants

        return safe_variables
1341912
def split_indexes(
    dims_or_levels,  # type: Union[Any, List[Any]]
    variables,  # type: OrderedDict[Any, Variable]
    coord_names,  # type: Set
    level_coords,  # type: Dict[Any, Any]
    drop=False,  # type: bool
):
    # type: (...) -> Tuple[OrderedDict[Any, Variable], Set]
    
    if isinstance(dims_or_levels, str):
        dims_or_levels = [dims_or_levels]

    dim_levels = defaultdict(list)  # type: Dict[Any, list]
    dims = []
    for k in dims_or_levels:
        if k in level_coords:
            dim_levels[level_coords[k]].append(k)
        else:
            dims.append(k)

    vars_to_replace = {}
    vars_to_create = OrderedDict()  # type: OrderedDict[Any, Variable]
    vars_to_remove = []

    for d in dims:
        index = variables[d].to_index()
        if isinstance(index, pd.MultiIndex):
            dim_levels[d] = index.names
        else:
            vars_to_remove.append(d)
            if not drop:
                vars_to_create[d + '_'] = Variable(d, index)

    for d, levs in dim_levels.items():
        index = variables[d].to_index()
        if len(levs) == index.nlevels:
            vars_to_remove.append(d)
        else:
            vars_to_replace[d] = IndexVariable(d, index.droplevel(levs))

        if not drop:
            for lev in levs:
                idx = index.get_level_values(lev)
                vars_to_create[idx.name] = Variable(d, idx)

    new_variables = variables.copy()
    for v in set(vars_to_remove):
        del new_variables[v]
    new_variables.update(vars_to_replace)
    new_variables.update(vars_to_create)
    new_coord_names = (coord_names | set(vars_to_create)) - set(vars_to_remove)

    return new_variables, new_coord_names
812867
def copy_public_vars(self):
        
        vars = self.get_vars()
        vars = dict([k for k in list(vars.items()) if not k[0].startswith('_')])
        return deepcopy(vars)
496693
def _nest_vars_in_rec(var_items, rec_items, input_order, items_by_key, parallel):
    
    num_items = var_items
    var_items = list(var_items)[0]
    if rec_items:
        rec_items = list(rec_items)[0]
        if ((rec_items == 1 and var_items > 1) or parallel.startswith("batch")):
            num_items = set([rec_items])
            for var_key in (k for (k, t) in input_order.items() if t != "record"):
                var_key = tuple(var_key.split("__"))
                items_by_key[var_key] = [items_by_key[var_key]] * rec_items
        else:
            assert var_items == rec_items, (var_items, rec_items)
    return items_by_key, num_items
521649
def _get_virtual_variable(variables, key, level_vars=None, dim_sizes=None):
    
    if level_vars is None:
        level_vars = {}
    if dim_sizes is None:
        dim_sizes = {}

    if key in dim_sizes:
        data = pd.Index(range(dim_sizes[key]), name=key)
        variable = IndexVariable((key,), data)
        return key, key, variable

    if not isinstance(key, str):
        raise KeyError(key)

    split_key = key.split('.', 1)
    if len(split_key) == 2:
        ref_name, var_name = split_key
    elif len(split_key) == 1:
        ref_name, var_name = key, None
    else:
        raise KeyError(key)

    if ref_name in level_vars:
        dim_var = variables[level_vars[ref_name]]
        ref_var = dim_var.to_index_variable().get_level_variable(ref_name)
    else:
        ref_var = variables[ref_name]

    if var_name is None:
        virtual_var = ref_var
        var_name = key
    else:
        if _contains_datetime_like_objects(ref_var):
            ref_var = xr.DataArray(ref_var)
            data = getattr(ref_var.dt, var_name).data
        else:
            data = getattr(ref_var, var_name).data
        virtual_var = Variable(ref_var.dims, data)

    return ref_name, var_name, virtual_var
1010193
def _create_variables_no_pretrain(self, n_features):
        
        self.encoding_w_ = []
        self.encoding_b_ = []

        for l, layer in enumerate(self.layers):

            w_name = 'enc-w-{}'.format(l)
            b_name = 'enc-b-{}'.format(l)

            if l == 0:
                w_shape = [n_features, self.layers[l]]
            else:
                w_shape = [self.layers[l - 1], self.layers[l]]

            w_init = tf.truncated_normal(shape=w_shape, stddev=0.1)
            W = tf.Variable(w_init, name=w_name)
            tf.summary.histogram(w_name, W)
            self.encoding_w_.append(W)

            b_init = tf.constant(0.1, shape=[self.layers[l]])
            b = tf.Variable(b_init, name=b_name)
            tf.summary.histogram(b_name, b)
            self.encoding_b_.append(b)
929535
def _to_variable_type(x, records):
    
    var_mapping = {"string": "String", "File": "File", "null": "String",
                   "long": "Float", "double": "Float", "int": "Int"}
    if isinstance(x, dict):
        if x["type"] == "record":
            struct_name, records = _record_to_struct(x, records)
            return struct_name, records
        else:
            assert x["type"] == "array", x
            cur_type, records = _to_variable_type(x["items"], records)
            return "Array[%s]" % cur_type, records
    elif isinstance(x, (list, tuple)):
        vars = [v for v in x if v != "null"]
        return var_mapping[vars[0]], records
    else:
        return var_mapping[x], records
505917
def _get_variables(self) -> Dict[str, str]:
        
        variables = {}  # type: Dict[str, str]
        for group in self.groups:
            setting_variables = self._read_group_variables(group)
            variables.update(setting_variables)
        return variables
20060
def load_var_files(opt, p_obj=None):
    """"""
    obj = {}
    if p_obj:
        obj = p_obj

    for var_file in opt.extra_vars_file:
        LOG.debug("loading vars from %s", var_file)
        obj = merge_dicts(obj.copy(), load_var_file(var_file, obj))

    return obj