Exemplo n.º 1
0
 def test_rank2(self):
     rb = ImmutableRoaringBitmap(range(0, 100000, 7))
     rb = rb.union(range(100000, 200000, 1000))
     for k in range(100000):
         assert rb.rank(k) == 1 + k // 7
     for k in range(100000, 200000):
         assert rb.rank(k) == 1 + 100000 // 7 + 1 + (k - 100000) // 1000
Exemplo n.º 2
0
	def test_rank2(self):
		rb = ImmutableRoaringBitmap(range(0, 100000, 7))
		rb = rb.union(range(100000, 200000, 1000))
		for k in range(100000):
			assert rb.rank(k) == 1 + k // 7
		for k in range(100000, 200000):
			assert rb.rank(k) == 1 + 100000 // 7 + 1 + (k - 100000) // 1000
Exemplo n.º 3
0
	def test_select(self, single):
		for name, data in single:
			ref = sorted(set(data))
			rb = ImmutableRoaringBitmap(data)
			lrb = list(rb)
			idx = [random.randint(0, len(ref) - 1) for _ in range(10)]
			for i in idx:
				assert lrb[i] == ref[i], name
				assert rb.select(i) in rb, name
				assert rb.select(i) == ref[i], name
				assert rb.rank(rb.select(i)) - 1 == i, name
				if rb.select(i) + 1 in rb:
					assert rb.rank(rb.select(i) + 1) - 1 == i + 1, name
				else:
					assert rb.rank(rb.select(i) + 1) - 1 == i, name
Exemplo n.º 4
0
 def test_select(self, single):
     for name, data in single:
         ref = sorted(set(data))
         rb = ImmutableRoaringBitmap(data)
         lrb = list(rb)
         idx = [random.randint(0, len(ref) - 1) for _ in range(10)]
         for i in idx:
             assert lrb[i] == ref[i], name
             assert rb.select(i) in rb, name
             assert rb.select(i) == ref[i], name
             assert rb.rank(rb.select(i)) - 1 == i, name
             if rb.select(i) + 1 in rb:
                 assert rb.rank(rb.select(i) + 1) - 1 == i + 1, name
             else:
                 assert rb.rank(rb.select(i) + 1) - 1 == i, name
Exemplo n.º 5
0
	def test_rank(self, single):
		for name, data in single:
			ref = sorted(set(data))
			rb = ImmutableRoaringBitmap(data)
			for _ in range(10):
				x = random.choice(ref)
				assert x in rb, name
				assert rb.rank(x) == ref.index(x) + 1, name
Exemplo n.º 6
0
 def test_rank(self, single):
     for name, data in single:
         ref = sorted(set(data))
         rb = ImmutableRoaringBitmap(data)
         for _ in range(10):
             x = random.choice(ref)
             assert x in rb, name
             assert rb.rank(x) == ref.index(x) + 1, name