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

Function test_range_coder_encode2

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

Source from the content-addressed store, hash-verified

543
544
545def test_range_coder_encode2():
546 # Use the same concrete entropy model as in the previous example:
547 probabilities = np.array([0.1, 0.6, 0.3], dtype=np.float64)
548 model = constriction.stream.model.Categorical(probabilities, perfect=False)
549
550 # Encode an example message using the above `model` for all symbols:
551 symbols = np.array([0, 2, 1, 2, 0, 2, 0, 2, 1], dtype=np.int32)
552 encoder = constriction.stream.queue.RangeEncoder()
553 encoder.encode(symbols, model)
554 assert np.all(encoder.get_compressed() ==
555 np.array([369323576], dtype=np.uint32))
556
557
558def test_range_coder_encode3():

Callers

nothing calls this directly

Calls 2

encodeMethod · 0.95
get_compressedMethod · 0.95

Tested by

no test coverage detected