| 603 | |
| 604 | |
| 605 | def test_range_coding_decode2(): |
| 606 | # Use the same concrete entropy model as in the previous example: |
| 607 | probabilities = np.array([0.1, 0.6, 0.3], dtype=np.float64) |
| 608 | model = constriction.stream.model.Categorical(probabilities, perfect=False) |
| 609 | |
| 610 | # Decode 9 symbols from some example compressed data, using the |
| 611 | # same (fixed) entropy model defined above for all symbols: |
| 612 | compressed = np.array([369323576], dtype=np.uint32) |
| 613 | decoder = constriction.stream.queue.RangeDecoder(compressed) |
| 614 | symbols = decoder.decode(model, 9) |
| 615 | assert np.all(symbols == np.array( |
| 616 | [0, 2, 1, 2, 0, 2, 0, 2, 1], dtype=np.int32)) |
| 617 | |
| 618 | |
| 619 | def test_range_coding_seek(): |