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

Function test_queue_gaussian

tests/python/test_constriction.py:6–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5
6def test_queue_gaussian():
7 encoder = constriction.stream.queue.RangeEncoder()
8
9 model = constriction.stream.model.QuantizedGaussian(-100, 100)
10 symbols = np.array([23, -15, 78, 43, -69], dtype=np.int32)
11 means = np.array([35.2, -1.7, 30.1, 71.2, -75.1], dtype=np.float64)
12 stds = np.array([10.1, 25.3, 23.8, 35.4, 3.9], dtype=np.float64)
13
14 encoder.encode(symbols, model, means, stds)
15 assert encoder.num_bits() == 64
16 compressed = encoder.get_compressed()
17 print(compressed)
18 assert np.all(compressed == np.array(
19 [473034731, 2276733146], dtype=np.uint32))
20
21 decoder1 = constriction.stream.queue.RangeDecoder(compressed)
22 reconstructed1 = decoder1.decode(model, means, stds)
23 assert decoder1.maybe_exhausted()
24 assert np.all(reconstructed1 == symbols)
25
26 decoder2 = encoder.get_decoder()
27 reconstructed2 = decoder2.decode(model, means, stds)
28 assert decoder2.maybe_exhausted()
29 assert np.all(reconstructed2 == symbols)
30
31
32def test_stack_gaussian():

Callers

nothing calls this directly

Calls 8

encodeMethod · 0.95
num_bitsMethod · 0.95
get_compressedMethod · 0.95
decodeMethod · 0.95
maybe_exhaustedMethod · 0.95
get_decoderMethod · 0.95
decodeMethod · 0.45
maybe_exhaustedMethod · 0.45

Tested by

no test coverage detected