()
| 4 | |
| 5 | |
| 6 | def 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 | |
| 32 | def test_stack_gaussian(): |
nothing calls this directly
no test coverage detected