Example #1
0
 def test_clamp_issue12(self):
     b = RoaringBitmap([1, 2, 3])
     assert b.clamp(0, 65536) == b
     assert b.clamp(0, 65537) == b
     assert b.clamp(0, 65538) == b
     assert b.clamp(0, 65539) == b
Example #2
0
 def test_issue28(self):
     rbm = RoaringBitmap()
     rbm.add(3995084765)
     r = rbm.clamp(0, 8388607)
     assert len(r) == 0
 chunksb = RoaringBitmap()
 if args.chunk_size == 1:
     # special case for speed
     chunkmap = bytemap
 else:
     for c in range(0, max_possible_chunk + 1):
         chunk_start = c * args.chunk_size
         chunk_stop = (c + 1) * args.chunk_size
         #chunkrange = range(chunk_start, chunk_stop)
         #z1 = len(bytemap.clamp(chunk_start, chunk_stop)) == 0 #fastest
         #z2 = bytemap.intersection_len(chunkrange) == 0
         #z3 = bytemap.isdisjoint(chunkrange)
         #assert(z1 == z2 and z2 == z3)
         #chunkificator = chunkificators[c]
         #if not bytemap.isdisjoint(chunkificator):
         overlap = bytemap.clamp(chunk_start, chunk_stop)
         if len(overlap) != 0:
             chunksb.add(c)
     chunkmap = chunksb.freeze()
 chunked_bytes = len(chunkmap) * args.chunk_size
 chunked_executed_ratio = chunked_bytes // executed_bytes
 highlighter: str = ""
 if chunked_executed_ratio > 1:
     highlighter = "\t\t" + "!" * (chunked_executed_ratio - 1)
     #represent_contract(bytemap, chunkmap)
 if chunked_bytes < executed_bytes:  # sanity check
     logging.info(
         f"Contract {codehash} in block {block} executes {executed_bytes} but merklizes to {chunked_bytes}"
     )
     highlighter = "\t\t" + "??????"
     represent_contract(bytemap, chunkmap)