MCPcopy Create free account
hub / github.com/bamler-lab/constriction / test_range_coding_decode4

Function test_range_coding_decode4

tests/python/test_docexamples.py:659–671  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

657
658
659def test_range_coding_decode4():
660 # Define 2 categorical models over the alphabet {0, 1, 2, 3, 4}:
661 probabilities = np.array(
662 [[0.1, 0.2, 0.3, 0.1, 0.3], # (for first decoded symbol)
663 [0.3, 0.2, 0.2, 0.2, 0.1]], # (for second decoded symbol)
664 dtype=np.float64)
665 model_family = constriction.stream.model.Categorical(perfect=False)
666
667 # Decode 2 symbols:
668 compressed = np.array([2705829535], dtype=np.uint32)
669 decoder = constriction.stream.queue.RangeDecoder(compressed)
670 symbols = decoder.decode(model_family, probabilities)
671 assert np.all(symbols == np.array([3, 1], dtype=np.int32))
672
673
674def test_custom_model_ans():

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.95

Tested by

no test coverage detected