()
| 742 | |
| 743 | |
| 744 | def test_model_mod2(): |
| 745 | model_family = constriction.stream.model.QuantizedGaussian(-100, 100) |
| 746 | # Note: we omitted the mean and standard deviation, but the quantization range |
| 747 | # {-100, ..., 100} must always be specified when constructing the model. |
| 748 | |
| 749 | # Define arrays of model parameters (means and standard deviations): |
| 750 | symbols = np.array([12, 15, 4, -2, 18, 5], dtype=np.int32) |
| 751 | means = np.array([13.2, 17.9, 7.3, -4.2, 25.1, 3.2], dtype=np.float64) |
| 752 | stds = np.array([3.2, 4.7, 5.2, 3.1, 6.3, 2.9], dtype=np.float64) |
| 753 | |
| 754 | # Encode and decode an example message: |
| 755 | coder = constriction.stream.stack.AnsCoder() # (RangeEncoder also works) |
| 756 | coder.encode_reverse(symbols, model_family, means, stds) |
| 757 | assert np.all(coder.get_compressed() == np.array( |
| 758 | [2051958011, 1549], dtype=np.uint32)) |
| 759 | |
| 760 | reconstructed = coder.decode(model_family, means, stds) |
| 761 | assert np.all(reconstructed == symbols) # (verify correctness) |
| 762 | |
| 763 | |
| 764 | def test_categorical1(): |
nothing calls this directly
no test coverage detected