Compares two documents and returns the difference
341780
public Difference<BaseType> compareNodes(BaseType node1, BaseType node2)
            throws InvalidArrayIdentity, DuplicateArrayIdentity {
        return compareNodes(new ArrayList<String>(), node1, new ArrayList<String>(), node2);
    }
1146128
def compare_disks(disk0, disk1, configuration):
    """"""
    with DiskComparator(disk0, disk1) as comparator:
        results = comparator.compare(
            size=configuration.get('get_file_size', False),
            identify=configuration.get('identify_files', False),
            concurrent=configuration.get('use_concurrency', False))

        if configuration.get('extract_files', False):
            extract = results['created_files'] + results['modified_files']
            files = comparator.extract(1, extract,
                                       path=configuration['results_folder'])

            results.update(files)

        if configuration.get('compare_registries', False):
            results['registry'] = comparator.compare_registry(
                concurrent=configuration.get('use_concurrency', False))

    return results
1013364
def differences(scansion: str, candidate: str) -> List[int]:
    
    before = scansion.replace(" ", "")
    after = candidate.replace(" ", "")
    diffs = []
    for idx, tmp in enumerate(before):
        if before[idx] != after[idx]:
            diffs.append(idx)
    return diffs
1323302
def _compare_by_version(path1, path2):
    
    if path1.source == path2.source:
        if path1.source_version_num > path2.source_version_num:
            return path1
        else:
            return path2
    return None
37306
function diff( a, b ) {
	var result = a.slice();
	for ( var i = 0; i < result.length; i++ ) {
		for ( var j = 0; j < b.length; j++ ) {
			if ( result[i] === b[j] ) {
				result.splice(i, 1);
				i--;
				break;
			}
		}
	}
	return result;
}
1007721
def compare_content(self, other):
        '''
        
        '''
        if type(self) is not type(other):
            return False
        s1 = self.snapshot()
        s2 = other.snapshot()
        for snapshot in (s1, s2):
            for key in snapshot.keys():
                if key[0] in ('_', '.'):
                    del snapshot[key]
        return s1 == s2
590291
def compare_dicts(d1, d2):
    
    a = json.dumps(d1, indent=4, sort_keys=True)
    b = json.dumps(d2, indent=4, sort_keys=True)
    # stolen from cpython
    # https://github.com/python/cpython/blob/01fd68752e2d2d0a5f90ae8944ca35df0a5ddeaa/Lib/unittest/case.py#L1091
    diff = ('\n' + '\n'.join(difflib.ndiff(
                   a.splitlines(),
                   b.splitlines())))
    return diff
782619
function compareObjects(schema, version1, version2) {

      var changes = [];

      _.each(version1, function(val, key) {
        var change;
        var field = getField(schema, key, val);
        if (!field) {
          // Current schema can't describe this field
          return;
        }
        if (!_.has(version2, key)) {
          change = { action: 'remove', key: key, field: field, old: version1[key] };
        } else if (!_.isEqual(version2[key], version1[key])) {
          change = { action: 'change', key: key, field: field, old: version1[key], current: version2[key] };
        }
        if (change) {
          change.changes = compareField(field, change.old, change.current);
          changes.push(change);
        }
      });

      _.each(version2, function(val, key) {
        var change;
        var field = getField(schema, key, val);
        if (!field) {
          // Current schema can't describe this field
          return;
        }
        if (!_.has(version1, key)) {
          change = { action: 'add', key: key, field: field, current: val };
          change.changes = compareField(field, change.old, change.current);
          changes.push(change);
        }
      });

      return changes;

      function compareField(field, old, current) {

        if (current && (!old)) {
          old = synth(field.type, current);
        } else if (old && (!current)) {
          current = synth(field.type, old);
        }

        if (field.type === 'array') {

          return compareArrays(schemaIdentifier, schemaDecoratorGenerator(field.schema), old, current);

        } else if ((field.type === 'area') || (field.type === 'singleton')) {

          return compareAreas(old, current);

        } else if (field.type === 'joinByArray') {

          return compareArrays(joinByArrayIdentifier, joinByArrayDecoratorGenerator(field.withType), old, current);

        } else if (field.type === 'joinByOne') {

          return compareArrays(joinByArrayIdentifier, joinByArrayDecoratorGenerator(field.withType), old ? [ old ] : [], current ? [ current ] : []);

        } else {

          // Take advantage of Apostrophe's support for boiling fields
          // down to search text to generate a basis for a text diff.
          // If a special "diffable" function is available use it;
          // that allows us to compare things that don't make
          // good search text but are human readable, like URLs. -Tom

          var oldLines = [];
          var oldText = '';
          var currentLines = [];
          var currentText = '';
          var fieldType = self.apos.schemas.getFieldType(field.type);
          var diffable = fieldType.diffable;
          if (diffable) {
            oldText = diffable(old);
            currentText = diffable(current);
          } else {
            var indexer = fieldType.index;
            if (indexer) {
              indexer(old, field, oldLines);
              indexer(current, field, currentLines);
              oldText = _.filter(_.pluck(oldLines, 'text'), function(line) {
                return line !== undefined;
              }).join("\n");
              currentText = _.filter(_.pluck(currentLines, 'text'), function(line) {
                return line !== undefined;
              }).join("\n");
            }
          }

          var diff = [];
          if (oldText !== undefined && currentText !== undefined) {
            diff = jsDiff.diffSentences(oldText, currentText, { ignoreWhitespace: true });
          }

          var changes = _.map(_.filter(diff, function(diffChange) {
            return diffChange.added || diffChange.removed;
          }), function(diffChange) {
            // Convert a jsDiff change object to an
            // apos versions change object
            if (diffChange.removed) {
              return {
                action: 'remove',
                text: diffChange.value,
                field: {
                  type: 'string',
                  label: 'Content'
                }
              };
            } else {
              return {
                action: 'add',
                text: diffChange.value,
                field: {
                  type: 'string',
                  label: 'Content'
                }
              };
            }
          });
          return changes;
        }

        // If "old" or "current" doesn't exist, make sure
        // we compare the other one to a reasonable value.
        // This is currently only an issue for areas, arrays and objects.
        // TODO: should probably be something we ask schemas to
        // generate for us so it's extensible. -Tom

        function synth(type, existing) {
          var value;
          if (existing && (existing.type === 'area')) {
            value = { type: 'area', items: [] };
          } else if (Array.isArray(existing)) {
            value = [];
          } else if (typeof (existing) === 'object') {
            value = {};
          }
          return value;
        }

      }
    }
978806
def compare(ver1, ver2):
    ''''''
    if ver1 == ver2:
        return 0
    ver1 = _cut(ver1)
    ver2 = _cut(ver2)
    # magic multiplier
    m = 1
    # if the first one is shorter, replace them
    if len(ver1) < len(ver2):
        ver1, ver2 = ver2, ver1
        # and reverse magic multiplier
        m = -1
    # compare all items that both have
    for i, part in enumerate(ver2):
        if ver1[i] > ver2[i]:
            return m * 1
        if ver1[i] < ver2[i]:
            return m * -1
    # if the first "extra" item is not negative, it's bigger
    if ver1[len(ver2)] >= 0:
        return m * 1
    else:
        return m * -1
583492
def diff_archives(archive1, archive2, verbosity=0, interactive=True):
    """"""
    util.check_existing_filename(archive1)
    util.check_existing_filename(archive2)
    if verbosity >= 0:
        util.log_info("Comparing %s with %s ..." % (archive1, archive2))
    res = _diff_archives(archive1, archive2, verbosity=verbosity, interactive=interactive)
    if res == 0 and verbosity >= 0:
        util.log_info("... no differences found.")
1357960
def difference(a: Iterable[Any], b: Container[Any]) -> List[Any]:
    
    d = []
    for item in a:
        if item not in b:
            d.append(item)
    return d
1137224
function compareFixesByRange(a, b) {
    return a.range[0] - b.range[0] || a.range[1] - b.range[1];
}
406172
def checkdiff(a,b,sp=True):
  ''
  if sp: a=splitpreserve(a); b=splitpreserve(b)
  res=applydiff(a,rediff(a,b))
  if sp: res=''.join(res)
  return res
642388
def difference(other)
      require 'pact/matchers' # avoid recursive loop between this file, pact/reification and pact/matchers
      Pact::Matchers.diff(query, symbolize_keys(CGI::parse(other.query)), allow_unexpected_keys: false)
    end
1130975
function difference(object, base) {
  return transform(object, (result, value, key) => {
    if (!isEqual(value, base[key])) {
      result[key] = isObject(value) && isObject(base[key]) ? difference(value, base[key]) : value;
    }
  });
}
568488
function compare(a, b) {
  if (isNaN(a.short_version)) return 1;
  if (isNaN(b.short_version)) return -1;
  return Number(a.short_version) - Number(b.short_version);
}
1114819
def _get_diff_dict(dict1, dict2):
    '''
    
    '''
    ret_dict = {}
    for p in dict2.keys():
        if p not in dict1:
            ret_dict.update({p: {'val1': None, 'val2': dict2[p]}})
        elif dict1[p] != dict2[p]:
            if isinstance(dict1[p], dict) and isinstance(dict2[p], dict):
                sub_diff_dict = _get_diff_dict(dict1[p], dict2[p])
                if sub_diff_dict:
                    ret_dict.update({p: sub_diff_dict})
            else:
                ret_dict.update({p: {'val1': dict1[p], 'val2': dict2[p]}})
    return ret_dict