'Agreement between two coders on a given item'

def agr(self, cA, cB, i, data=None):

    data = (data or self.data)
    k1 = next((x for x in data if ((x[u'coder'] in (cA, cB)) and (x[u'item'] == i))))
    if (k1[u'coder'] == cA):
        k2 = next((x for x in data if ((x[u'coder'] == cB) and (x[u'item'] == i))))
    else:
        k2 = next((x for x in data if ((x[u'coder'] == cA) and (x[u'item'] == i))))
    ret = (1.0 - float(self.distance(k1[u'labels'], k2[u'labels'])))
    log.debug(u'Observed    agreement    between    %s    and    %s    on    %s:    %f', cA, cB, i, ret)
    log.debug(u'Distance    between    "%r"    and    "%r":    %f', k1[u'labels'], k2[u'labels'], (1.0 - ret))
    return ret
