return the diffs between the two idfs
763118
def idfdiffs(idf1, idf2):
    """"""
    # for any object type, it is sorted by name
    thediffs = {}
    keys = idf1.model.dtls # undocumented variable

    for akey in keys:
        idfobjs1 = idf1.idfobjects[akey]
        idfobjs2 = idf2.idfobjects[akey]
        names = set([getobjname(i) for i in idfobjs1] +
                    [getobjname(i) for i in idfobjs2])
        names = sorted(names)
        idfobjs1 = sorted(idfobjs1, key=lambda idfobj: idfobj['obj'])
        idfobjs2 = sorted(idfobjs2, key=lambda idfobj: idfobj['obj'])
        for name in names:
            n_idfobjs1 = [item for item in idfobjs1
                          if getobjname(item) == name]
            n_idfobjs2 = [item for item in idfobjs2
                          if getobjname(item) == name]
            for idfobj1, idfobj2 in zip_longest(n_idfobjs1,
                                                           n_idfobjs2):
                if idfobj1 == None:
                    thediffs[(idfobj2.key.upper(), 
                                getobjname(idfobj2))] = (None, idf2.idfname) #(idf1.idfname, None) -> old
                    break
                if idfobj2 == None:
                    thediffs[(idfobj1.key.upper(), 
                                getobjname(idfobj1))] = (idf1.idfname, None) # (None, idf2.idfname) -> old
                    break
                for i, (f1, f2) in enumerate(zip(idfobj1.obj, idfobj2.obj)):
                    if i == 0:
                        f1, f2 = f1.upper(), f2.upper()
                    if f1 != f2:
                        thediffs[(
                            akey,
                            getobjname(idfobj1),
                            idfobj1.objidd[i]['field'][0])] = (f1, f2)
    return thediffs
66901
def similarity(self, d, d_):
        
        es = set([e.name for e in d.entities])
        es_ = set([e.name for e in d_.entities])
        e_weight = (len(es) + len(es_) - abs(len(es) - len(es_)))/2
        e_score = sum(self.idf_entity[t] for t in es & es_)

        toks = set(d.tokens)
        toks_ = set(d_.tokens)
        t_weight = (len(toks) + len(toks_) - abs(len(toks) - len(toks_)))/2

        # If no term similarity reference is passed,
        # look only at surface form overlap (i.e. exact overlap)
        shared_toks = toks & toks_
        overlap = [(t, t, self.idf[t]) for t in shared_toks]
        t_score = sum(self.idf[t] for t in shared_toks)
        if self.term_sim_ref is not None:
            # Double-count exact overlaps b/c we are
            # comparing bidirectional term pairs here
            t_score *= 2
            for toks1, toks2 in [(toks, toks_), (toks_, toks)]:
                for t in toks1 - shared_toks:
                    best_match = max(toks2, key=lambda t_: self.term_sim_ref[t, t_])
                    sim = self.term_sim_ref[t, best_match]
                    t_score += sim * ((self.idf[t] + self.idf[best_match])/2)
                    if sim > 0:
                        overlap.append((t, best_match, sim * ((self.idf[t] + self.idf[best_match])/2)))

            # Adjust term weight
            #t_weight /= 2

        t_weight = 1/t_weight if t_weight != 0 else 0
        e_weight = 1/e_weight if e_weight != 0 else 0
        t_score *= t_weight
        e_score *= e_weight

        if self.debug:
            print('\n-------------------------')
            print((d.id, d_.id))
            print('DOC:', d.id)
            print('DOC:', d_.id)
            print('\tEntities:')
            print('\t', es)
            print('\t', es_)
            print('\t\tEntity overlap:', es & es_)
            print('\t\tEntity weight:', e_weight)
            print('\t\tEntity score:', e_score)

            print('\tTokens:')
            print('\t\t', toks)
            print('\t\t', toks_)
            print('\t\tToken overlap:', overlap)
            print('\t\tToken weight:', t_weight)
            print('\t\tToken score:', t_score)

            print('\tTotal score:', t_score + e_score)

        return t_score + e_score
1129117
def get_diff(left, right):
    
    res = {'+': [], '-': []}

    def partition(objects):
        """Partition the passed object list."""
        res = {}
        for o in objects:
            t = type(o)
            if type(o) not in res:
                res[t] = []
            res[t].append(o)
        return res

    def get_not_included(foo, bar):
        """Compare objects from foo with objects defined in the values of
        bar (set of partitions).
        Returns a list of all objects included in list, but not dict values.
        """
        res = []
        for o in foo:
            if not compat.object_in_list(type(o), bar):
                res.append(o)
            elif not compat.object_in_list(o, bar[type(o)]):
                res.append(o)
        return res

    # Create partitions of both lists. This will reduce the time required for
    # the comparison
    left_objects = partition(left)
    right_objects = partition(right)
    # and then do the diff
    res['+'] = get_not_included(right, left_objects)
    res['-'] = get_not_included(left, right_objects)
    return res
1316764
def join(cls, diffs: Iterable['DBDiff']) -> 'DBDiff':
        
        tracker = DBDiffTracker()
        for diff in diffs:
            diff.apply_to(tracker)
        return tracker.diff()
294833
function equalDiff(a, b, diff) {
  diff.a = {
    line: a.line,
    column: a.column
  };
  diff.b = {
    line: b.line,
    column: b.column
  };
  return false;
}
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
638826
def __diff_obj(self, level, parents_ids=frozenset({}),
                   is_namedtuple=False):
        """"""
        try:
            if is_namedtuple:
                t1 = level.t1._asdict()
                t2 = level.t2._asdict()
            else:
                t1 = level.t1.__dict__
                t2 = level.t2.__dict__
        except AttributeError:
            try:
                t1 = self.__dict_from_slots(level.t1)
                t2 = self.__dict_from_slots(level.t2)
            except AttributeError:
                self.__report_result('unprocessed', level)
                return

        self.__diff_dict(
            level,
            parents_ids,
            print_as_attribute=True,
            override=True,
            override_t1=t1,
            override_t2=t2)
1217275
def pprint_diff(first, second, first_name='first', second_name='second'):
  """"""
  return difflib.unified_diff(
      pprint.pformat(first).splitlines(),
      pprint.pformat(second).splitlines(),
      fromfile=first_name, tofile=second_name, lineterm='')
539178
def dif(a, b):
    
    return [i for i in range(len(a)) if a[i] != b[i]]
17943
def dicom_diff(file1, file2):
    

    datasets = compressed_dicom.read_file(file1), compressed_dicom.read_file(file2)

    rep = []

    for dataset in datasets:
        lines = (str(dataset.file_meta)+"\n"+str(dataset)).split('\n')
        lines = [line + '\n' for line in lines]  # add the newline to the end
        rep.append(lines)

    diff = difflib.Differ()
    for line in diff.compare(rep[0], rep[1]):
        if (line[0] == '+') or (line[0] == '-'):
            sys.stdout.write(line)
606459
function diff( a, b ) {
  let i, j, found = false, result = [];

  for ( i = 0; i < a.length; i++ ) {
    found = false;
    for ( j = 0; j < b.length; j++ ) {
      if ( a[ i ] === b[ j ] ) {
        found = true;
        break;
      }
    }
    if ( !found ) {
      result.push( a[ i ] );
    }
  }

  return result;
}
715070
def diff(self, items):
        
        return self.__class__([i for i in self.items if i not in items])
174649
def _diff(self, x, th, eps):
        
        foo = lambda y: self.igen(numpy.sum(self.gen(y, th), 0), th)

        out1 = out2 = 0.
        sign = 1 - 2*(x > .5).T
        for I in numpy.ndindex(*((2,)*(len(x)-1)+(1,))):

            eps_ = numpy.array(I)*eps
            x_ = (x.T + sign*eps_).T
            out1 += (-1)**sum(I)*foo(x_)

            x_[-1] = 1
            out2 += (-1)**sum(I)*foo(x_)

        out = out1/out2
        return out
820047
def dmp_to_mdiff(diffs):
    
    def yield_buffer(lineno_left, lineno_right):
        while left_buffer or right_buffer:
            if left_buffer:
                left = lineno_left, '\0-{0}\1'.format(left_buffer.pop(0))
                lineno_left += 1
            else:
                left = '', '\n'
            if right_buffer:
                right = lineno_right, '\0+{0}\1'.format(right_buffer.pop(0))
                lineno_right += 1
            else:
                right = '', '\n'
            yield (left, right, True), lineno_left, lineno_right

    lineno_left = lineno_right = 1
    left_buffer = []
    right_buffer = []

    for op, data in diffs:
        for line in data.splitlines(True):
            if op == DMP.DIFF_EQUAL:
                for item, lleft, llright in yield_buffer(lineno_left,
                                                         lineno_right):
                    lineno_left = lleft
                    lineno_right = llright
                    yield item
                yield (lineno_left, line), (lineno_right, line), False
                lineno_left += 1
                lineno_right += 1
            elif op == DMP.DIFF_DELETE:
                left_buffer.append(line)
            elif op == DMP.DIFF_INSERT:
                right_buffer.append(line)

    for item, _, _ in yield_buffer(lineno_left, lineno_right):
        yield item
1202313
def diff(actual, expected):
    
    return '\n'.join(list(
        difflib.unified_diff(actual.splitlines(), expected.splitlines())
    ))
796721
def diff(self):
        """"""
        done = set(self.done)
        return [name for name in self.todo if name not in done]
1087588
def diff_table(rawinfo, newinfo):
    '''
    
    '''
    return HtmlDiff.make_table(HtmlDiff(), rawinfo.split('\n'), newinfo.split('\n'),
                               context=True,
                               numlines=1)