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

Function variable_model_params

tests/python/test_docexamples_f32.py:690–710  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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