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

Function variable_model_params

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

Source from the content-addressed store, hash-verified

686 assert np.all(coder.decode(model, 4) == symbols)
687
688 def variable_model_params():
689 # The optional argument `params` will receive a 1-d python array when
690 # the model is used for encoding or decoding.
691 model = constriction.stream.model.CustomModel(
692 lambda x, loc, scale: scipy.stats.cauchy.cdf(x, loc, scale),
693 lambda x, loc, scale: scipy.stats.cauchy.ppf(x, loc, scale),
694 -100, 100)
695
696 model_parameters = np.array([
697 (7.3, 3.9), # Location and scale of entropy model for 1st symbol.
698 (11.5, 5.2), # Location and scale of entropy model for 2nd symbol.
699 (-3.2, 4.9), # and so on ...
700 (25.9, 7.1),
701 ])
702
703 symbols = np.array([5, 14, -1, 21], dtype=np.int32)
704 coder = constriction.stream.stack.AnsCoder()
705 coder.encode_reverse(
706 symbols, model, model_parameters[:, 0].copy(), model_parameters[:, 1].copy())
707 assert np.all(
708 coder.decode(model, model_parameters[:, 0].copy(), model_parameters[:, 1].copy()) == symbols)
709
710 def discrete_distribution():
711 model = constriction.stream.model.CustomModel(

Callers 3

test_custom_model_ansFunction · 0.70
test_custom_model_rangeFunction · 0.70

Calls 8

encode_reverseMethod · 0.95
decodeMethod · 0.95
encodeMethod · 0.95
get_compressedMethod · 0.95
decodeMethod · 0.95
decodeMethod · 0.95
encode_reverseMethod · 0.95
get_dataMethod · 0.95

Tested by

no test coverage detected