def _expected(observed):
    o = observed
    if len(o) == 0:
        return []
    if len(o) == 1:
        return [[sum(o[0]) / float(len(o[0]))] * len(o[0])]
    n = [sum(o[i]) for i in xrange(len(o))]
    m = [sum(o[i][j] for i in xrange(len(o))) for j in xrange(len(o[0]))]
    s = float(sum(n))
    # Each cell = row sum * column sum / total.
    return [[n[i] * m[j] / s for j in xrange(len(o[i]))] for i in xrange(len(o))]
Test if required item exists in the cache.
dataset/ETHPy150Open clips/pattern/pattern/metrics.py/_expected--crossover with--dataset/ETHPy150Open lorien/grab/grab/spider/cache_backend/mongo.py/CacheBackend.has_item