()
| 617 | |
| 618 | |
| 619 | def test_range_coding_seek(): |
| 620 | probabilities = np.array([0.2, 0.4, 0.1, 0.3], dtype=np.float64) |
| 621 | model = constriction.stream.model.Categorical(probabilities, perfect=False) |
| 622 | message_part1 = np.array([1, 2, 0, 3, 2, 3, 0], dtype=np.int32) |
| 623 | message_part2 = np.array([2, 2, 0, 1, 3], dtype=np.int32) |
| 624 | |
| 625 | # Encode both parts of the message and record a checkpoint in-between: |
| 626 | encoder = constriction.stream.queue.RangeEncoder() |
| 627 | encoder.encode(message_part1, model) |
| 628 | (position, state) = encoder.pos() # Records a checkpoint. |
| 629 | encoder.encode(message_part2, model) |
| 630 | |
| 631 | compressed = encoder.get_compressed() |
| 632 | decoder = constriction.stream.queue.RangeDecoder(compressed) |
| 633 | |
| 634 | # Decode first symbol: |
| 635 | assert decoder.decode(model) == 1 |
| 636 | |
| 637 | # Jump to part 2 and decode it: |
| 638 | decoder.seek(position, state) |
| 639 | decoded_part2 = decoder.decode(model, 5) |
| 640 | assert np.all(decoded_part2 == message_part2) |
| 641 | |
| 642 | |
| 643 | def test_range_coding_decode3(): |
nothing calls this directly
no test coverage detected