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

Function test_range_coder_encode3

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

Source from the content-addressed store, hash-verified

556
557
558def test_range_coder_encode3():
559 # Define a generic quantized Gaussian distribution for all integers
560 # in the range from -100 to 100 (both ends inclusive):
561 model_family = constriction.stream.model.QuantizedGaussian(-100, 100)
562
563 # Specify the model parameters for each symbol:
564 means = np.array([10.3, -4.7, 20.5], dtype=np.float64)
565 stds = np.array([5.2, 24.2, 3.1], dtype=np.float64)
566
567 # Encode an example message:
568 # (needs `len(symbols) == len(means) == len(stds)`)
569 symbols = np.array([12, -13, 25], dtype=np.int32)
570 encoder = constriction.stream.queue.RangeEncoder()
571 encoder.encode(symbols, model_family, means, stds)
572 assert np.all(encoder.get_compressed() ==
573 np.array([2655472005], dtype=np.uint32))
574
575
576def test_range_coder_encode4():

Callers

nothing calls this directly

Calls 2

encodeMethod · 0.95
get_compressedMethod · 0.95

Tested by

no test coverage detected