Unpack the numpy array and bind each column to one of the variables in self.var_names
        Returns inferred dict of variable: val pairs
198741
def _parse_var_array(self, X: np.ndarray) -> dict:
        
        arg_vars = {}
        # Get the shape and tensor rank
        shape = X.shape
        tensor_rank = len(shape)
        T = self._check_forward_mode_input_array(X)
        if tensor_rank == 0:
            #there is only 1 var name, so this will only run once
            for var_name in self.var_names:
                arg_vars[var_name] = X
        if tensor_rank == 1 and T == shape[0]:
            #there is only 1 var name, so this will only run once
            for var_name in self.var_names:
                arg_vars[var_name] = X.squeeze()
        elif tensor_rank == 1:
            for j, var_name in enumerate(sorted(self.var_names)):
                arg_vars[var_name] = X[j].squeeze()
        elif tensor_rank == 2:
            for j, var_name in enumerate(sorted(self.var_names)):
                arg_vars[var_name] = X[:,j].squeeze()
        return arg_vars
400956
def get(self, varname, idx=0, units=None):
        ''''''
        if not varname in self.mapping.vars:
            raise fgFDMError('Unknown variable %s' % varname)
        if idx >= self.mapping.vars[varname].arraylength:
            raise fgFDMError('index of %s beyond end of array idx=%u arraylength=%u' % (
                varname, idx, self.mapping.vars[varname].arraylength))
        value = self.values[self.mapping.vars[varname].index + idx]
        if units:
            value = self.convert(value, self.mapping.vars[varname].units, units)
        return value
1358116
def _get_var_array(self, k, use_raw=False, layer='X'):
        """"""
        in_raw_obs_names = k in self.raw.obs_names if self.raw is not None else False

        if use_raw and self.raw is None:
            raise ValueError('.raw doesn\'t exist')

        if k in self.var.keys():
            x = self._var[k]
        elif in_raw_obs_names and use_raw and layer == 'X':
            x = self.raw[k].X
        elif k in self.obs_names and not use_raw and (layer == 'X' or layer in self.layers.keys()):
            x = self[k].X if layer=='X' else self[k].layers[layer]
        elif use_raw and layer != 'X':
            raise ValueError('No layers in .raw')
        elif layer != 'X' and layer not in self.layers.keys():
            raise ValueError('Did not find {} in layers.keys.'
                             .format(layer))
        else:
            raise ValueError('Did not find {} in var.keys or obs_names.'
                             .format(k))
        return x
24334
def _get_variable_name_or_register(var, variables, names, params, prefix):
    '''
    
    '''
    if var not in variables.values():
        vname = prefix
        if var.data in params:
            vname = params[var.data]
        elif var in names:
            vname = names[var]
        vname = _get_unique_variable_name(vname, variables)
        variables[vname] = var
    else:
        vname = list(variables.keys())[list(variables.values()).index(var)]

    return vname
1005411
def unpack_variable(var):
    """"""
    # If we actually get a structure instance, handle turning that into a variable
    if var.dataType == stream.STRUCTURE:
        return None, struct_to_dtype(var), 'Structure'
    elif var.dataType == stream.SEQUENCE:
        log.warning('Sequence support not implemented!')

    dt = data_type_to_numpy(var.dataType, var.unsigned)
    if var.dataType == stream.OPAQUE:
        type_name = 'opaque'
    elif var.dataType == stream.STRING:
        type_name = 'string'
    else:
        type_name = dt.name

    if var.data:
        log.debug('Storing variable data: %s %s', dt, var.data)
        if var.dataType == stream.STRING:
            data = var.data
        else:
            # Always sent big endian
            data = np.frombuffer(var.data, dtype=dt.newbyteorder('>'))
    else:
        data = None

    return data, dt, type_name
75867
def parse_vars(self, args):
        
        result = {}
        for arg in args:
            if '=' not in arg:
                raise ValueError(
                    'Variable assignment %r invalid (no "=")'
                    % arg)
            name, value = arg.split('=', 1)
            result[name] = value
        return result
363970
def extract_attribute_array(self, data_array, var_name):
        
        if var_name not in self.attributes.keys():
            self.attributes[var_name] = []
        for t in range(self.times.size):
            self.attributes[var_name].append(data_array[self.i[t], self.j[t]])
998177
def _get_sliced_variables(var_list):
  
  unsliced_variables = []
  sliced_variables = collections.defaultdict(lambda: [])
  for var in var_list:
    if var._save_slice_info:
      sliced_variables[var._save_slice_info.full_name].append(var)
    else:
      unsliced_variables.append(var)
  return unsliced_variables, sliced_variables
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
251640
def _convert_to_var(self, graph, var_res):
        
        with graph.as_default():
            var = {}
            for key, value in var_res.items():
                if value is not None:
                    var[key] = tf.Variable(value, name="tf_%s" % key)
                else:
                    var[key] = None
        return var
1044889
def extract_vars(template):
    
    keys = set()
    for match in re.finditer(r"\{\{ (?P<key>\w+) \}\}", template.getvalue()):
        keys.add(match.groups()[0])
    return sorted(list(keys))
190191
def _parse_out_variable(self):
        
        self._out_variables = {}
        self._out_variables_type = {}
        if self.tcex.default_args.tc_playbook_out_variables:
            variables = self.tcex.default_args.tc_playbook_out_variables.strip()
            for o in variables.split(','):
                # parse the variable to get individual parts
                parsed_key = self.parse_variable(o)
                variable_name = parsed_key['name']
                variable_type = parsed_key['type']
                # store the variables in dict by name (e.g. "status_code")
                self._out_variables[variable_name] = {'variable': o}
                # store the variables in dict by name-type (e.g. "status_code-String")
                vt_key = '{}-{}'.format(variable_name, variable_type)
                self._out_variables_type[vt_key] = {'variable': o}
1118817
def _process_data_var(string):
    
    key, var = string.split("<-")
    if "structure" in var:
        var, dim = var.replace("structure(", "").replace(",", "").split(".Dim")
        # dtype = int if '.' not in var and 'e' not in var.lower() else float
        dtype = float
        var = var.replace("c(", "").replace(")", "").strip().split()
        dim = dim.replace("=", "").replace("c(", "").replace(")", "").strip().split()
        dim = tuple(map(int, dim))
        var = np.fromiter(map(dtype, var), dtype).reshape(dim, order="F")
    elif "c(" in var:
        # dtype = int if '.' not in var and 'e' not in var.lower() else float
        dtype = float
        var = var.replace("c(", "").replace(")", "").split(",")
        var = np.fromiter(map(dtype, var), dtype)
    else:
        # dtype = int if '.' not in var and 'e' not in var.lower() else float
        dtype = float
        var = dtype(var)
    return key.strip(), var
1367448
def get_vars(n):
    
    op = n[0]
    if op.startswith('_') and op.endswith('_'):
        op = op.strip('_')
        if op == 'var':
            return [n[1]]
        return []
    else:
        ret = []
        for c in n[1:]:
            vs = get_vars(c)
            if vs:
                ret.extend(vs)
        return ret
622842
def read_var_str(self, max_size=sys.maxsize):
        
        length = self.read_var_int(max_size)
        return self.unpack(str(length) + 's', length)
1320711
def vars_(object=None):
    
    filtered_vars = {}
    vars_dict = vars(object)
    for key, value in six.iteritems(vars_dict):
        if key.startswith("_"):
            continue
        filtered_vars[_normalize_arg_name(key)] = value
    return filtered_vars
1015986
def _var_names(var_names, data):
    
    if var_names is not None:

        if isinstance(var_names, str):
            var_names = [var_names]

        if isinstance(data, (list, tuple)):
            all_vars = []
            for dataset in data:
                dataset_vars = list(dataset.data_vars)
                for var in dataset_vars:
                    if var not in all_vars:
                        all_vars.append(var)
        else:
            all_vars = list(data.data_vars)

        excluded_vars = [i[1:] for i in var_names if i.startswith("~") and i not in all_vars]

        all_vars_tilde = [i for i in all_vars if i.startswith("~")]

        if all_vars_tilde:
            warnings.warn(
                """ArviZ treats '~' as a negation character for variable selection.
                   Your model has variables names starting with '~', {0}. Please double check
                   your results to ensure all variables are included""".format(
                    ", ".join(all_vars_tilde)
                )
            )

        if excluded_vars:
            var_names = [i for i in all_vars if i not in excluded_vars]

    return var_names