Enter diff mode.

        Args:
            context_model (`ContextModel`): Context to diff against. If None, a
            copy of the current context is used.
199075
def enter_diff_mode(self, context_model=None):
        
        assert not self.diff_mode
        self.diff_mode = True

        if context_model is None:
            self.diff_from_source = True
            self.diff_context_model = self.context_model.copy()
        else:
            self.diff_from_source = False
            self.diff_context_model = context_model

        self.clear()
        self.setColumnCount(5)
        self.refresh()
1134341
private void setModelContext(InstancesHeader ih){
		//TODO possibly refactored
        if ((ih != null) && (ih.classIndex() < 0)) {
            throw new IllegalArgumentException(
                    "Context for a classifier must include a class to learn");
        }
        //TODO: check flag for checking whether training has started or not
        
        //model context is used to describe the model
		logger.trace("Model context: {}", ih.toString());
	}
18587
def register_model(self, model):
        

        assert isinstance(model, str)
        if model not in self.all_models:
            self.all_models.append(model)
291513
def patch_context(self, context):
        
        context.__class__ = PatchedContext
        # Simply setting __class__ directly doesn't work
        # because behave.runner.Context.__setattr__ is implemented wrongly.
        object.__setattr__(context, '__class__', PatchedContext)
1004099
def setcontext(context, _local=local):
    
    oldcontext = getcontext()
    _local.__bigfloat_context__ = oldcontext + context
197065
def remove_context(self, name):
        
        self._context(name)
        del self.contexts[name]
        self._flush_tools()
1195043
def diff(context, file_name):
    """"""
    context.obj.find_repo_type()
    if context.obj.vc_name == 'git':
        context.obj.call(['git', 'diff', '--color-words',
                          '--ignore-space-change', file_name])
    elif context.obj.vc_name == 'hg':
        context.obj.call(['hg', 'diff', file_name])
930118
def setModel(self, model):
        
        self.paramList.setModel(model)
        model.hintRequested.connect(self.hintRequested)
        model.rowsInserted.connect(self.updateTitle)
        model.rowsRemoved.connect(self.updateTitle)
        self.updateTitle()
1111804
def current_changed(self, i):
        
        m = self.model()
        ri = self.rootModelIndex()
        index = m.index(i, 0, ri)
        self.new_root.emit(index)
538352
def _copy_context_into_mutable(context):
    
    def make_mutable(val):
        if isinstance(val, Mapping):
            return dict(val)
        else:
            return val

    if not isinstance(context, (str, Mapping)):
        try:
            return [make_mutable(val) for val in context]
        except TypeError:
            pass
    return make_mutable(context)
644346
def diff_one(model1, model2, **kwargs):
    """"""
    changes = []

    fields1 = model1._meta.fields
    fields2 = model2._meta.fields

    # Add fields
    names1 = set(fields1) - set(fields2)
    if names1:
        fields = [fields1[name] for name in names1]
        changes.append(create_fields(model1, *fields, **kwargs))

    # Drop fields
    names2 = set(fields2) - set(fields1)
    if names2:
        changes.append(drop_fields(model1, *names2))

    # Change fields
    fields_ = []
    nulls_ = []
    indexes_ = []
    for name in set(fields1) - names1 - names2:
        field1, field2 = fields1[name], fields2[name]
        diff = compare_fields(field1, field2)
        null = diff.pop('null', None)
        index = diff.pop('index', None)

        if diff:
            fields_.append(field1)

        if null is not None:
            nulls_.append((name, null))

        if index is not None:
            indexes_.append((name, index[0], index[1]))

    if fields_:
        changes.append(change_fields(model1, *fields_, **kwargs))

    for name, null in nulls_:
        changes.append(change_not_null(model1, name, null))

    for name, index, unique in indexes_:
        if index is True or unique is True:
            if fields2[name].unique or fields2[name].index:
                changes.append(drop_index(model1, name))
            changes.append(add_index(model1, name, unique))
        else:
            changes.append(drop_index(model1, name))

    return changes
173080
def use_model(self, model_name):
        
        # Check against exclude list.
        if self.exclude_models:
            for model_pattern in self.exclude_models:
                model_pattern = '^%s$' % model_pattern.replace('*', '.*')
                if re.search(model_pattern, model_name):
                    return False
        # Check against exclude list.
        elif self.include_models:
            for model_pattern in self.include_models:
                model_pattern = '^%s$' % model_pattern.replace('*', '.*')
                if re.search(model_pattern, model_name):
                    return True
        # Return `True` if `include_models` is falsey, otherwise return `False`.
        return not self.include_models
1077351
def model_changed(self, model, prop_name, info):
        
        if self.parent is not None:
            self.parent.model_changed(model, prop_name, info)
1058503
def update_context(self, ctx):
        
        assert isinstance(ctx, dict)
        ctx[str(self.context_id)] = self.value
605870
def set_context(self, serializer_field):
        
        # Determine the underlying model field name. This may not be the
        # same as the serializer field name if `source=<>` is set.
        self.field_name = serializer_field.source_attrs[0]
        # Determine the existing instance, if this is an update operation.
        self.instance = getattr(serializer_field.parent, 'instance', None)
1170951
def set_context(self, serializer):
        
        # Determine the underlying model field names. These may not be the
        # same as the serializer field names if `source=<>` is set.
        self.field_name = serializer.fields[self.field].source_attrs[0]
        self.date_field_name = serializer.fields[self.date_field].source_attrs[0]
        # Determine the existing instance, if this is an update operation.
        self.instance = getattr(serializer, 'instance', None)
97972
def remove_context(self, name):
        
        context = self.get_context(name)
        contexts = self.get_contexts()
        contexts.remove(context)