()
| 25 | |
| 26 | |
| 27 | def test_module_example2(): |
| 28 | # Same representation of message and entropy model as in the previous example: |
| 29 | message = np.array([6, 10, -4, 2, 5, 2, 1, 0, 2], dtype=np.int32) |
| 30 | entropy_model = constriction.stream.model.QuantizedGaussian( |
| 31 | -50, 50, 3.2, 9.6) |
| 32 | |
| 33 | # Let's use a Range coder now: |
| 34 | encoder = constriction.stream.queue.RangeEncoder() # <-- CHANGED LINE |
| 35 | # <-- (slightly) CHANGED LINE |
| 36 | encoder.encode(message, entropy_model) |
| 37 | |
| 38 | compressed = encoder.get_compressed() |
| 39 | print(f"compressed representation: {compressed}") |
| 40 | print(f"(in binary: {[bin(word) for word in compressed]})") |
| 41 | |
| 42 | decoder = constriction.stream.queue.RangeDecoder( |
| 43 | compressed) # <--CHANGED LINE |
| 44 | decoded = decoder.decode(entropy_model, 9) # (decodes 9 symbols) |
| 45 | assert np.all(decoded == message) |
| 46 | |
| 47 | |
| 48 | def test_old_module_example1(): |
nothing calls this directly
no test coverage detected