Recalculate the projection, hash_key, and range_key for the given index.

    :param meta: model.Meta to find columns by name
    :param index: The index to refresh
422083
def refresh_index(meta, index) -> None:
    
    # All projections include model + index keys
    projection_keys = set.union(meta.keys, index.keys)

    proj = index.projection
    mode = proj["mode"]

    if mode == "keys":
        proj["included"] = projection_keys
    elif mode == "all":
        proj["included"] = meta.columns
    elif mode == "include":  # pragma: no branch
        if all(isinstance(p, str) for p in proj["included"]):
            proj["included"] = set(meta.columns_by_name[n] for n in proj["included"])
        else:
            proj["included"] = set(proj["included"])
        proj["included"].update(projection_keys)

    if proj["strict"]:
        proj["available"] = proj["included"]
    else:
        proj["available"] = meta.columns
1371761
def build_index(self, idx_name, _type='default'):
        ""
        indexes = {}
        has_non_string_values = False
        for key, item in self.data.items():
            if idx_name in item:
                value = item[idx_name]
                # A non-string index value switches it into a lazy one.
                if not isinstance(value, six.string_types):
                    has_non_string_values = True
                if value not in indexes:
                    indexes[value] = set([])
                indexes[value].add(key)
        self.indexes[idx_name] = indexes
        if self._meta.lazy_indexes or has_non_string_values:
            # Every index is lazy
            _type = 'lazy'
        self.index_defs[idx_name] = {'type': _type}
587815
def _add_index(self, index):
        
        index_name = index.get_name()
        index_name = self._normalize_identifier(index_name)
        replaced_implicit_indexes = []

        for name, implicit_index in self._implicit_indexes.items():
            if implicit_index.is_fullfilled_by(index) and name in self._indexes:
                replaced_implicit_indexes.append(name)

        already_exists = (
            index_name in self._indexes
            and index_name not in replaced_implicit_indexes
            or self._primary_key_name is not False
            and index.is_primary()
        )
        if already_exists:
            raise IndexAlreadyExists(index_name, self._name)

        for name in replaced_implicit_indexes:
            del self._indexes[name]
            del self._implicit_indexes[name]

        if index.is_primary():
            self._primary_key_name = index_name

        self._indexes[index_name] = index

        return self
736992
def reindex_axis(self, new_index, axis, method=None, limit=None,
                     fill_value=None, copy=True):
        
        new_index = ensure_index(new_index)
        new_index, indexer = self.axes[axis].reindex(new_index, method=method,
                                                     limit=limit)

        return self.reindex_indexer(new_index, indexer, axis=axis,
                                    fill_value=fill_value, copy=copy)
628051
def reindex(self, ind):
        

        if isinstance(ind, pd.MultiIndex):
            try:
                return self.new(self.data.reindex(ind))
            except:
                raise RuntimeError('QADATASTRUCT ERROR: CANNOT REINDEX')
        else:
            raise RuntimeError(
                'QADATASTRUCT ERROR: ONLY ACCEPT MULTI-INDEX FORMAT'
            )
604532
def index_to_coordinates(self, index):
        
        self.validate_index(index)
        x = int(index % self.length)
        y = int((index - x) / self.length)
        return x, y
482228
def _update_index_on_df(df, index_names):
    """"""
    if index_names:
        df = df.set_index(index_names)
        # Remove names from unnamed indexes
        index_names = _denormalize_index_names(index_names)
        df.index.names = index_names
    return df
173806
def set_meta(self, selected_meta):
        
        meta_names = list(selected_meta)
        meta_names.append('sample')
        meta_index = []
        # To set the index for existing samples in the region dataframe.
        # The index size of the region dataframe does not necessarily be equal to that of metadata df.
        warnings.warn("\n\nThis method assumes that the last level of the index is the sample_id.\n"
                      "In case of single index, the index itself should be the sample_id")
        for x in meta_names:
            meta_index.append(self.meta.ix[self.data.index.get_level_values(-1)][x].values)
        meta_index = np.asarray(meta_index)
        multi_meta_index = pd.MultiIndex.from_arrays(meta_index, names=meta_names)
        self.data.index = multi_meta_index
1064302
def _get_indexes_in_altered_table(self, diff):
        
        indexes = diff.from_table.get_indexes()
        column_names = self._get_column_names_in_altered_table(diff)

        for key, index in OrderedDict([(k, v) for k, v in indexes.items()]).items():
            for old_index_name, renamed_index in diff.renamed_indexes.items():
                if key.lower() == old_index_name.lower():
                    del indexes[key]

            changed = False
            index_columns = []
            for column_name in index.get_columns():
                normalized_column_name = column_name.lower()
                if normalized_column_name not in column_names:
                    del indexes[key]
                    break
                else:
                    index_columns.append(column_names[normalized_column_name])
                    if column_name != column_names[normalized_column_name]:
                        changed = True

            if changed:
                indexes[key] = Index(
                    index.get_name(),
                    index_columns,
                    index.is_unique(),
                    index.is_primary(),
                    index.get_flags(),
                )

            for index in diff.removed_indexes.values():
                index_name = index.get_name().lower()
                if index_name and index_name in indexes:
                    del indexes[index_name]

            changed_indexes = (
                list(diff.changed_indexes.values())
                + list(diff.added_indexes.values())
                + list(diff.renamed_indexes.values())
            )
            for index in changed_indexes:
                index_name = index.get_name().lower()
                if index_name:
                    indexes[index_name] = index
                else:
                    indexes[len(indexes)] = index

        return indexes
1370452
public void updateAxis(Integer index, Matrix4d newAxis){
		axes.get(index).setOperator(newAxis);
	}
416170
def _reload_columns(self, table_desc):
        
        # FIND ALL INDEXES OF ALIAS
        es_last_updated = self.es_cluster.metatdata_last_updated

        alias = table_desc.name
        canonical_index = self.es_cluster.get_best_matching_index(alias).index
        es_metadata_update_required = not (table_desc.timestamp < es_last_updated)
        metadata = self.es_cluster.get_metadata(force=es_metadata_update_required)

        props = [
            (self.es_cluster.get_index(index=i, type=t, debug=DEBUG), t, m.properties)
            for i, d in metadata.indices.items()
            if alias in d.aliases
            for t, m in [_get_best_type_from_mapping(d.mappings)]
        ]

        # CONFIRM ALL COLUMNS ARE SAME, FIX IF NOT
        dirty = False
        all_comparisions = list(jx.pairwise(props)) + list(jx.pairwise(jx.reverse(props)))
        # NOTICE THE SAME (index, type, properties) TRIPLE FROM ABOVE
        for (i1, t1, p1), (i2, t2, p2) in all_comparisions:
            diff = elasticsearch.diff_schema(p2, p1)
            if not self.settings.read_only:
                for d in diff:
                    dirty = True
                    i1.add_property(*d)
        meta = self.es_cluster.get_metadata(force=dirty).indices[canonical_index]

        data_type, mapping = _get_best_type_from_mapping(meta.mappings)
        mapping.properties["_id"] = {"type": "string", "index": "not_analyzed"}
        columns = self._parse_properties(alias, mapping)
        table_desc.timestamp = es_last_updated
        return columns
1318197
def set_index(self, index):
        
        for df in self.get_DataFrame(data=True, with_population=False):
            df.index = index
1269848
def reset_index(self):
        
        new_columns = OrderedDict()

        new_index = default_index(_obtain_length(self._length, self._data))

        new_columns.update((name, Series(data.values, new_index, data.dtype, name))
                           for name, data in self.index._gather_data().items())

        # the data/columns
        new_columns.update((sr.name, Series(sr.values, new_index, sr.dtype, sr.name))
                           for sr in self._iter())

        return DataFrame(new_columns, new_index)
606637
def apply_projection(projection, value):
    """"""
    if isinstance(value, Sequence):
        # Apply projection to each item in the list.
        return [
            apply_projection(projection, item)
            for item in value
        ]
    elif not isinstance(value, Mapping):
        # Non-dictionary values are simply ignored.
        return value

    # Extract projection for current level.
    try:
        current_projection = [p[0] for p in projection]
    except IndexError:
        return value

    # 
    for name in list(value.keys()):
        if name not in current_projection:
            value.pop(name)
        elif isinstance(value[name], dict):
            # Apply projection recursively.
            value[name] = apply_projection(
                [p[1:] for p in projection if p[0] == name],
                value[name]
            )

    return value
685390
def algolia_reindex(batch_size = AlgoliaSearch::IndexSettings::DEFAULT_BATCH_SIZE, synchronous = false)
      return if algolia_without_auto_index_scope
      algolia_configurations.each do |options, settings|
        next if algolia_indexing_disabled?(options)
        next if options[:slave] || options[:replica]

        # fetch the master settings
        master_index = algolia_ensure_init(options, settings)
        master_settings = master_index.get_settings rescue {} # if master doesn't exist yet
        master_settings.merge!(JSON.parse(settings.to_settings.to_json)) # convert symbols to strings

        # remove the replicas of the temporary index
        master_settings.delete :slaves
        master_settings.delete 'slaves'
        master_settings.delete :replicas
        master_settings.delete 'replicas'

        # init temporary index
        index_name = algolia_index_name(options)
        tmp_options = options.merge({ :index_name => "#{index_name}.tmp" })
        tmp_options.delete(:per_environment) # already included in the temporary index_name
        tmp_settings = settings.dup
        tmp_index = algolia_ensure_init(tmp_options, tmp_settings, master_settings)

        algolia_find_in_batches(batch_size) do |group|
          if algolia_conditional_index?(tmp_options)
            # select only indexable objects
            group = group.select { |o| algolia_indexable?(o, tmp_options) }
          end
          objects = group.map { |o| tmp_settings.get_attributes(o).merge 'objectID' => algolia_object_id_of(o, tmp_options) }
          tmp_index.save_objects(objects)
        end

        move_task = SafeIndex.move_index(tmp_index.name, index_name)
        master_index.wait_task(move_task["taskID"]) if synchronous || options[:synchronous]
      end
      nil
    end
304735
def reset_index(self, **kwargs):
        
        drop = kwargs.get("drop", False)
        new_index = pandas.RangeIndex(len(self.index))
        if not drop:
            if isinstance(self.index, pandas.MultiIndex):
                # TODO (devin-petersohn) ensure partitioning is properly aligned
                new_column_names = pandas.Index(self.index.names)
                new_columns = new_column_names.append(self.columns)
                index_data = pandas.DataFrame(list(zip(*self.index))).T
                result = self.data.from_pandas(index_data).concat(1, self.data)
                return self.__constructor__(result, new_index, new_columns)
            else:
                new_column_name = (
                    self.index.name
                    if self.index.name is not None
                    else "index"
                    if "index" not in self.columns
                    else "level_0"
                )
                new_columns = self.columns.insert(0, new_column_name)
                result = self.insert(0, new_column_name, self.index)
                return self.__constructor__(result.data, new_index, new_columns)
        else:
            # The copies here are to ensure that we do not give references to
            # this object for the purposes of updates.
            return self.__constructor__(
                self.data.copy(), new_index, self.columns.copy(), self._dtype_cache
            )
1065805
def reindex_indexer(self, new_axis, indexer, axis, fill_value=None,
                        allow_dups=False, copy=True):
        
        if indexer is None:
            if new_axis is self.axes[axis] and not copy:
                return self

            result = self.copy(deep=copy)
            result.axes = list(self.axes)
            result.axes[axis] = new_axis
            return result

        self._consolidate_inplace()

        # some axes don't allow reindexing with dups
        if not allow_dups:
            self.axes[axis]._can_reindex(indexer)

        if axis >= self.ndim:
            raise IndexError("Requested axis not found in manager")

        if axis == 0:
            new_blocks = self._slice_take_blocks_ax0(indexer,
                                                     fill_tuple=(fill_value,))
        else:
            new_blocks = [blk.take_nd(indexer, axis=axis, fill_tuple=(
                fill_value if fill_value is not None else blk.fill_value,))
                for blk in self.blocks]

        new_axes = list(self.axes)
        new_axes[axis] = new_axis
        return self.__class__(new_blocks, new_axes)