17 lines
612 B
Python
17 lines
612 B
Python
from composer_ans.analysis import analyze_composition
|
|
|
|
|
|
def test_entropy_distinguishes_constant_and_varied_sequences() -> None:
|
|
constant = analyze_composition((1, 1, 1, 1))
|
|
varied = analyze_composition((1, 2, 3, 4))
|
|
|
|
assert constant.unigram_entropy_bits == 0.0
|
|
assert varied.unigram_entropy_bits > constant.unigram_entropy_bits
|
|
|
|
|
|
def test_analysis_reports_predictability_for_repeating_pattern() -> None:
|
|
repeating = analyze_composition((1, 2, 1, 2, 1, 2, 1, 2))
|
|
|
|
assert repeating.conditional_entropy_bits < repeating.unigram_entropy_bits
|
|
assert 0.0 <= repeating.predictability <= 1.0
|