Пример #1
0
	def test_jaccard_dist(self, pair):
		for name, data1, data2 in pair:
			ref, ref2 = set(data1), set(data2)
			rb, rb2 = RoaringBitmap(data1), RoaringBitmap(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
Пример #2
0
 def test_jaccard_dist(self, pair):
     for name, data1, data2 in pair:
         ref, ref2 = set(data1), set(data2)
         rb, rb2 = RoaringBitmap(data1), RoaringBitmap(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
Пример #3
0
 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, rb2 = RoaringBitmap(data1), RoaringBitmap(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