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

Function test_model_mod1

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

Source from the content-addressed store, hash-verified

728
729
730def test_model_mod1():
731 model = constriction.stream.model.QuantizedGaussian(-100, 100, 12.6, 7.3)
732
733 # Encode and decode an example message:
734 symbols = np.array([12, 15, 4, -2, 18, 5], dtype=np.int32)
735 coder = constriction.stream.stack.AnsCoder() # (RangeEncoder also works)
736 coder.encode_reverse(symbols, model)
737 assert np.all(coder.get_compressed() == np.array(
738 [745994372, 25704], dtype=np.uint32))
739
740 reconstructed = coder.decode(model, 6) # (decodes 6 i.i.d. symbols)
741 assert np.all(reconstructed == symbols) # (verify correctness)
742
743
744def test_model_mod2():

Callers

nothing calls this directly

Calls 3

encode_reverseMethod · 0.95
get_compressedMethod · 0.95
decodeMethod · 0.95

Tested by

no test coverage detected