Skip to content

Commit

Permalink
test: add rate test to Tunstall code
Browse files Browse the repository at this point in the history
  • Loading branch information
rwnobrega committed Jan 4, 2025
1 parent 6aaf122 commit 75e5e2f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/lossless_coding/test_tunstall_code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from math import floor, log2

import numpy as np
import pytest

Expand Down Expand Up @@ -40,6 +42,7 @@ def test_tunstall_code_random_pmf(source_cardinality, target_block_size):
assert code.is_fully_covering()
assert code.is_uniquely_encodable()
assert code.is_prefix_free()
assert code.rate(pmf) >= komm.entropy(pmf)
# Permute pmf and check if the rate is the same.
pmf1 = pmf[np.random.permutation(source_cardinality)]
code1 = komm.TunstallCode(pmf1, target_block_size)
Expand Down

0 comments on commit 75e5e2f

Please sign in to comment.