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

Function test_ans_encode_reverse3

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

Source from the content-addressed store, hash-verified

367
368
369def test_ans_encode_reverse3():
370 # Define a generic quantized Gaussian distribution for all integers
371 # in the range from -100 to 100 (both ends inclusive):
372 model_family = constriction.stream.model.QuantizedGaussian(-100, 100)
373
374 # Specify the model parameters for each symbol:
375 means = np.array([10.3, -4.7, 20.5], dtype=np.float64)
376 stds = np.array([5.2, 24.2, 3.1], dtype=np.float64)
377
378 # Encode an example message:
379 # (needs `len(symbols) == len(means) == len(stds)`)
380 symbols = np.array([12, -13, 25], dtype=np.int32)
381 coder = constriction.stream.stack.AnsCoder()
382 coder.encode_reverse(symbols, model_family, means, stds)
383 assert np.all(coder.get_compressed() == np.array(
384 [597775281, 3], dtype=np.uint32))
385
386
387def test_ans_encode_reverse4():

Callers

nothing calls this directly

Calls 2

encode_reverseMethod · 0.95
get_compressedMethod · 0.95

Tested by

no test coverage detected