| 590 | |
| 591 | |
| 592 | def test_range_coding_decode1(): |
| 593 | # Define a concrete categorical entropy model over the (implied) |
| 594 | # alphabet {0, 1, 2}: |
| 595 | probabilities = np.array([0.1, 0.6, 0.3], dtype=np.float64) |
| 596 | model = constriction.stream.model.Categorical(probabilities, perfect=False) |
| 597 | |
| 598 | # Decode a single symbol from some example compressed data: |
| 599 | compressed = np.array([3089773345, 1894195597], dtype=np.uint32) |
| 600 | decoder = constriction.stream.queue.RangeDecoder(compressed) |
| 601 | symbol = decoder.decode(model) |
| 602 | assert symbol == 2 |
| 603 | |
| 604 | |
| 605 | def test_range_coding_decode2(): |