def test_orlen(self, pair): for name, data1, data2 in pair: ref, ref2 = set(data1), set(data2) rb = ImmutableRoaringBitmap(data1) rb2 = ImmutableRoaringBitmap(data2) assert len(ref | ref2) == rb.union_len(rb2), name assert len(rb | rb2) == rb.union_len(rb2), name
def test_orlen(self, pair): for name, data1, data2 in pair: ref, ref2 = set(data1), set(data2) rb = ImmutableRoaringBitmap(data1) rb2 = ImmutableRoaringBitmap(data2) assert len(ref | ref2) == rb.union_len(rb2), name assert len(rb | rb2) == rb.union_len(rb2), name
def test_jaccard_dist(self, pair): for name, data1, data2 in pair: ref, ref2 = set(data1), set(data2) rb = ImmutableRoaringBitmap(data1) rb2 = ImmutableRoaringBitmap(data2) assert abs((len(ref & ref2) / float(len(ref | ref2))) - rb.intersection_len(rb2) / float(rb.union_len(rb2))) < 0.001, name assert abs((1 - (len(ref & ref2) / float(len(ref | ref2)))) - rb.jaccard_dist(rb2)) < 0.001, name
def test_jaccard_dist(self, pair): for name, data1, data2 in pair: ref, ref2 = set(data1), set(data2) rb = ImmutableRoaringBitmap(data1) rb2 = ImmutableRoaringBitmap(data2) assert abs((len(ref & ref2) / float(len(ref | ref2))) - rb.intersection_len(rb2) / float(rb.union_len(rb2))) < 0.001, name assert abs((1 - (len(ref & ref2) / float(len(ref | ref2)))) - rb.jaccard_dist(rb2)) < 0.001, name
def test_jaccard_dist(self, pair): for name, data1, data2 in pair: if len(data1) == 0 and len(data2) == 0: continue ref, ref2 = set(data1), set(data2) rb = ImmutableRoaringBitmap(data1) rb2 = ImmutableRoaringBitmap(data2) assert len(ref & ref2) / float(len(ref | ref2)) == pytest.approx( rb.intersection_len(rb2) / float(rb.union_len(rb2))), name assert ( 1 - (len(ref & ref2) / float(len(ref | ref2))) == pytest.approx( rb.jaccard_dist(rb2))), name