Calculates the real differences between the two models of the given ModelDiff and saves them to the differences
field of the ModelDiff class.
10483
private static void calculateDifferences(ModelDiff diff) {
        Class<?> modelClass = diff.getBefore().getClass();
        for (Field field : modelClass.getDeclaredFields()) {
            if (field.getName().equals(ModelUtils.MODEL_TAIL_FIELD_NAME)) {
                continue;
            }
            try {
                Object before = FieldUtils.readField(field, diff.getBefore(), true);
                Object after = FieldUtils.readField(field, diff.getAfter(), true);
                if (!Objects.equal(before, after)) {
                    diff.addDifference(field, before, after);
                }
            } catch (IllegalAccessException e) {
                LOGGER.warn("Skipped field '{}' because of illegal access to it", field.getName(), e);
            }
        }
    }
571240
public static IntSet differenceView (IntSet set1, IntSet set2)
    {
        return andView(set1, notView(set2));
    }
1084751
def _create_diff_action(diff, diff_key, key, value):

    '''
    
    '''

    if diff_key not in diff.keys():
        diff[diff_key] = {}
    diff[diff_key][key] = value
328061
@Override
    public void add(Difference difference) {
        if(ignorePaths == null) {
            list.add(difference);
        } else {
            String pathA = trimNonXmlElements(difference.getPathA());
            String pathB = trimNonXmlElements(difference.getPathB());
            if (ignorePaths.contains(pathA) || ignorePaths.contains(pathB)) {
                // ignorable matched
                if(ignorePaths.contains(pathA) && ignorePaths.contains(pathB)) {
                    // both sides contains an ignorable difference
                    return;
                } else if(pathA.length() > 0 && ignorePaths.contains(pathB)) {
                    // B contains ignorable
                    difference = new Difference(difference.getPathA(), null, "Only in: " + getNameA());
                    list.add(difference);
                } else if(ignorePaths.contains(pathA) && pathB.length() > 0) {
                    // A contains ignorable
                    difference = new Difference(null, difference.getPathB(), "Only in: " + getNameB());
                    list.add(difference);
                }
            } else {
                // no ignorable matched
                list.add(difference);
            }
        }
    }
1357161
private static Collection difference(Collection first, Collection second){
        if (first == null) {
            return EMPTY_LIST;
        }

        if (second == null) {
            return first;
        }

        Collection difference = new ArrayList<>(first);
        for (Object current : second){
            difference.remove(current);
        }
        return difference;
    }
419449
def save(self):
        

        # handle polymorphic models
        if self._is_polymorphic:
            if self._is_polymorphic_base:
                raise PolymorphicModelException('cannot save polymorphic base model')
            else:
                setattr(self, self._discriminator_column_name, self.__discriminator_value__)

        self.validate()
        self.__dmlquery__(self.__class__, self,
                          batch=self._batch,
                          ttl=self._ttl,
                          timestamp=self._timestamp,
                          consistency=self.__consistency__,
                          if_not_exists=self._if_not_exists,
                          conditional=self._conditional,
                          timeout=self._timeout,
                          if_exists=self._if_exists).save()

        self._set_persisted()

        self._timestamp = None

        return self
511086
function DeepDiff () {
  var self = this

  self.klass = DeepDiff;
  self.klass.super_.apply(self, arguments);

  self.engine = require('deep-diff');
}
79907
def _diff(d1,d2):
    '''
        
    '''
    d = {}
    ds = _diff_internal(d1,d2)
    for key in ds['vdiff']:
        d[key] = d1[key]
    for key in ds['kdiff']:
        d[key] = d1[key]
    return(d)
1298318
public function saveModelInternal()
    {
        // Purge the field values from the attributes
        $this->model->attributes = array_diff_key($this->model->attributes, $this->fieldValues);
    }
974427
def get_diff(self, new_mapping):
        
        import copy
        result = copy.deepcopy(new_mapping)
        result.clear_properties()

        no_check_types = (BooleanField, IntegerField, FloatField, DateField, LongField, BinaryField,
                          GeoPointField, IpField)

        old_fields = set(self.properties.keys())
        new_fields = set(new_mapping.properties.keys())
        #we propagate new fields
        added = new_fields - old_fields
        if added:
            for add in added:
                result.add_property(new_mapping.properties[add])

        #we check common fields
        common_fields = new_fields & old_fields

        #removing standard data
        common_fields = [c for c in common_fields if not isinstance(new_mapping.properties[c], no_check_types)]

        for field in common_fields:
            prop = new_mapping.properties[field]
            if isinstance(prop, StringField):
                continue
            if isinstance(prop, MultiField):
                diff = prop.get_diff(self.properties[field])
                if diff:
                    result.add_property(diff)
            elif isinstance(prop, ObjectField):
                diff = self.properties[field].get_diff(prop)
                if diff:
                    result.add_property(diff)

        if len(result.properties) > 0:
            return result
        return None
483259
def diff(models, filename, pytest_args, exclusive, skip, solver,
         experimental, custom_tests, custom_config):
    
    if not any(a.startswith("--tb") for a in pytest_args):
        pytest_args = ["--tb", "no"] + pytest_args
    # Add further directories to search for tests.
    pytest_args.extend(custom_tests)
    config = ReportConfiguration.load()
    # Update the default test configuration with custom ones (if any).
    for custom in custom_config:
        config.merge(ReportConfiguration.load(custom))
    # Build the diff report specific data structure
    diff_results = dict()
    model_and_model_ver_tuple = list()
    for model_path in models:
        try:
            model_filename = os.path.basename(model_path)
            diff_results.setdefault(model_filename, dict())
            model, model_ver, notifications = api.validate_model(model_path)
            if model is None:
                head, tail = os.path.split(filename)
                report_path = os.path.join(
                    head, '{}_structural_report.html'.format(model_filename))
                api.validation_report(
                    model_path, notifications, report_path)
                LOGGER.critical(
                    "The model {} could not be loaded due to SBML errors "
                    "reported in {}.".format(model_filename, report_path))
                continue
            model.solver = solver
            model_and_model_ver_tuple.append((model, model_ver))
        except (IOError, SBMLError):
            LOGGER.debug(exc_info=True)
            LOGGER.warning("An error occurred while loading the model '%s'. "
                           "Skipping.", model_filename)
    # Abort the diff report unless at least two models can be loaded
    # successfully.
    if len(model_and_model_ver_tuple) < 2:
        LOGGER.critical(
            "Out of the %d provided models only %d could be loaded. Please, "
            "check if the models that could not be loaded are valid SBML. "
            "Aborting.",
            len(models), len(model_and_model_ver_tuple))
        sys.exit(1)
    # Running pytest in individual processes to avoid interference
    partial_test_diff = partial(_test_diff, pytest_args=pytest_args,
                                skip=skip, exclusive=exclusive,
                                experimental=experimental)
    pool = Pool(min(len(models), cpu_count()))
    results = pool.map(partial_test_diff, model_and_model_ver_tuple)

    for model_path, result in zip(models, results):
        model_filename = os.path.basename(model_path)
        diff_results[model_filename] = result

    with open(filename, "w", encoding="utf-8") as file_handle:
        LOGGER.info("Writing diff report to '%s'.", filename)
        file_handle.write(api.diff_report(diff_results, config))
597356
def _tracked_model_diff(self):
        
        initial_state = self._tracked_model_initial_state
        current_state = serializer.dump_model(self)
        if current_state == initial_state:
            return None

        change_log = {}
        for field in initial_state:
            old_value = initial_state[field][Field.VALUE]
            new_value = current_state[field][Field.VALUE]
            if old_value == new_value:
                continue
            field_data = initial_state.copy()[field]
            del field_data[Field.VALUE]
            field_data[Field.OLD] = old_value
            field_data[Field.NEW] = new_value
            change_log[field] = field_data

        return change_log or None
512525
def diff(self, other, **kwargs):
        
        from normalize.diff import diff
        return diff(self, other, **kwargs)
762391
def diff_many(models1, models2, migrator=None, reverse=False):
    """"""
    models1 = pw.sort_models(models1)
    models2 = pw.sort_models(models2)

    if reverse:
        models1 = reversed(models1)
        models2 = reversed(models2)

    models1 = OrderedDict([(m._meta.name, m) for m in models1])
    models2 = OrderedDict([(m._meta.name, m) for m in models2])

    changes = []

    for name, model1 in models1.items():
        if name not in models2:
            continue
        changes += diff_one(model1, models2[name], migrator=migrator)

    # Add models
    for name in [m for m in models1 if m not in models2]:
        changes.append(create_model(models1[name], migrator=migrator))

    # Remove models
    for name in [m for m in models2 if m not in models1]:
        changes.append(remove_model(models2[name]))

    return changes
426978
private DifferenceEngineContract getDifferenceEngine() {
        if (differenceEngine == null) {
            if (
                XMLUnit.getIgnoreAttributeOrder()
                &&
                (!usesUnknownElementQualifier()
                 || XMLUnit.getCompareUnmatched())
                ) {
                return new NewDifferenceEngine(this, matchTrackerDelegate);
            }
            return new DifferenceEngine(this, matchTrackerDelegate);
        }
        return differenceEngine;
    }
636098
public static <T> void dumpUnchanged(Iterable<Difference<T>> diffs) {
		for(Difference<T> diff: diffs) {
			if(Difference.Type.UNCHANGED.equals(diff.getType())) {
				System.out.println(diff);
			}
		}
	}
367429
private void reloadReferencesAndUpdateEO(ModelDiff diff, EngineeringObjectModelWrapper model) {
        for (ModelDiffEntry entry : diff.getDifferences().values()) {
            mergeEngineeringObjectWithReferencedModel(entry.getField(), model);
        }
    }