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

Function test_ans_encode_reverse2

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

Source from the content-addressed store, hash-verified

354
355
356def test_ans_encode_reverse2():
357 # Use the same concrete entropy model as in the previous example:
358 probabilities = np.array([0.1, 0.6, 0.3], dtype=np.float64)
359 model = constriction.stream.model.Categorical(probabilities, perfect=False)
360
361 # Encode an example message using the above `model` for all symbols:
362 symbols = np.array([0, 2, 1, 2, 0, 2, 0, 2, 1], dtype=np.int32)
363 coder = constriction.stream.stack.AnsCoder()
364 coder.encode_reverse(symbols, model)
365 assert np.all(coder.get_compressed() == np.array(
366 [1276728145, 172], dtype=np.uint32))
367
368
369def test_ans_encode_reverse3():

Callers

nothing calls this directly

Calls 2

encode_reverseMethod · 0.95
get_compressedMethod · 0.95

Tested by

no test coverage detected