Returns a dict of variables in the selected run table.
    :param run_name: str, required run table name
    :return: dict -> {<int_keys>: <variable_name>}
510767
def get_variables(run_name):
    
    conn, c = open_data_base_connection()
    try:
        # Get latest project
        c.execute("""SELECT variable_name FROM {}""".format(run_name))
        variable_names = np.array(c.fetchall()).squeeze(axis=1)
        variable_names = convert_list_to_dict(variable_names)
        return variable_names
    except sqlite3.OperationalError:
        logging.info("{} not found".format(run_name))
    finally:
        conn.close()
138480
def get_local_variable_from_name(self, variable_name):
        
        return next((v for v in self.variables if v.name == variable_name), None)
648966
def _copy_listed(self: T, names) -> T:
        
        variables = OrderedDict()  # type: OrderedDict[Any, Variable]
        coord_names = set()
        indexes = OrderedDict()  # type: OrderedDict[Any, pd.Index]

        for name in names:
            try:
                variables[name] = self._variables[name]
            except KeyError:
                ref_name, var_name, var = _get_virtual_variable(
                    self._variables, name, self._level_coords, self.dims)
                variables[var_name] = var
                if ref_name in self._coord_names or ref_name in self.dims:
                    coord_names.add(var_name)
                if (var_name,) == var.dims:
                    indexes[var_name] = var.to_index()

        needed_dims = set()  # type: set
        for v in variables.values():
            needed_dims.update(v.dims)

        dims = dict((k, self.dims[k]) for k in needed_dims)

        for k in self._coord_names:
            if set(self.variables[k].dims) <= needed_dims:
                variables[k] = self._variables[k]
                coord_names.add(k)
                if k in self.indexes:
                    indexes[k] = self.indexes[k]

        return self._replace(variables, coord_names, dims, indexes=indexes)
1248111
def get_variables(self, entity = None):
        
        if not entity:
            return self.variables
        else:
            return {
                variable_name: variable
                for variable_name, variable in self.variables.items()
                # TODO - because entities are copied (see constructor) they can't be compared
                if variable.entity.key == entity.key
                }
438612
def _environment_variables() -> Dict[str, str]:
    
    return {key: value
            for key, value in os.environ.items()
            if _is_encodable(value)}
863868
def runs_to_xml(self, runSet, runs, blockname=None):
        
        # copy benchmarkinfo, limits, columntitles, systeminfo from xml_header
        runsElem = util.copy_of_xml_element(self.xml_header)
        runsElem.set("options", " ".join(runSet.options))
        if blockname is not None:
            runsElem.set("block", blockname)
            runsElem.set("name", ((runSet.real_name + ".") if runSet.real_name else "") + blockname)
        elif runSet.real_name:
            runsElem.set("name", runSet.real_name)

        # collect XMLelements from all runs
        for run in runs:
            runsElem.append(run.xml)

        return runsElem
988513
def get_global_variable(self, name):
        
        p = ffi.lib.LLVMPY_GetNamedGlobalVariable(self, _encode_string(name))
        if not p:
            raise NameError(name)
        return ValueRef(p, 'global', dict(module=self))
132914
def _as_dict(self):
        
        values = self._dynamic_columns or {}
        for name, col in self._columns.items():
            values[name] = col.to_database(getattr(self, name, None))
        return values
378199
def _parse_seed_dict(self, var_tbl: dict) -> dict:
        
        var_names = var_tbl.copy()
        # check that all of the variables are bound
        for v in self.var_names:
            if v not in var_tbl:
                raise(KeyError("variable " + v + " is unbound in seed table"))
        # squeeze the variables
        return self._squeeze(var_names)
140254
def variable_names(self):
        
        result = []
        names = javabridge.call(self.jobject, "getVariableNames", "()Ljava/util/Set;")
        for name in javabridge.iterate_collection(names):
            result.append(javabridge.to_string(name))
        return result
1203717
def _get_var_name(self, name, fresh=False):
        
        if name not in self._var_name_mappers:
            self._var_name_mappers[name] = VariableNamer(name)

        if fresh:
            var_name = self._var_name_mappers[name].get_next()
        else:
            var_name = self._var_name_mappers[name].get_current()

        return var_name
507170
def get_variable_name_col(d):
    
    var = ""
    try:
        var = d["variableName"]
    except KeyError:
        try:
            var = d["name"]
        except KeyError:
            num = "unknown"
            if "number" in d:
                num = d["number"]
            print("Error: column number <{}> is missing a variableName. Please fix.".format(num))
            logger_misc.info("get_variable_name_col: KeyError: missing key")
    return var
107088
def get(self, run_id):
        
        config = _read_json(_path_to_config(self.directory, run_id))
        run = _read_json(_path_to_run(self.directory, run_id))
        try:
            info = _read_json(_path_to_info(self.directory, run_id))
        except IOError:
            info = {}

        return _create_run(run_id, run, config, info)
1286670
def runtime_spec(self, id):
        
        try:
            return self.runtimes[id]
        except KeyError:
            raise UnregisteredRuntime('No registered runtime with name: {}'.format(id))
1087085
def get_time_variable(ds):
    '''
    
    '''
    for var in ds.variables:
        if getattr(ds.variables[var], 'axis', '') == 'T':
            return var
    else:
        candidates = ds.get_variables_by_attributes(standard_name='time')
        if len(candidates) == 1:
            return candidates[0].name
        else:  # Look for a coordinate variable time
            for candidate in candidates:
                if candidate.dimensions == (candidate.name,):
                    return candidate.name

    # If we still haven't found the candidate
    time_variables = set(get_time_variables(ds))
    coordinate_variables = set(get_coordinate_variables(ds))
    if len(time_variables.intersection(coordinate_variables)) == 1:
        return list(time_variables.intersection(coordinate_variables))[0]

    auxiliary_coordinates = set(get_auxiliary_coordinate_variables(ds))
    if len(time_variables.intersection(auxiliary_coordinates)) == 1:
        return list(time_variables.intersection(auxiliary_coordinates))[0]
    return None
1026894
def get_figure_stats(run_table_name):
    
    conn, c = open_data_base_connection()

    # Get latest project
    c.execute("""SELECT variable_name FROM {}""".format(run_table_name))
    variable_names = convert_list_to_dict(np.array(c.fetchall()).squeeze(axis=1))
    conn.close()

    return variable_names
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