-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AssertionError: Low or high out of range #1
Comments
Oh, sorry i am just seeing this. I have no idea why i wasn't notified 🤔 About the issue, this usually happens when theres a symbol in the data that is not present in your frequency map, this is most likely a unicode symbol. So setting Something like this: data = read_bytes(fn)
freq_map = {}
for c in data:
freq_map[c] = freq_map.get(c, 0) + 1 Again, sorry for the late reply |
Hmm. I checked the maximum symbol value in From Python 3.11 docs:
|
I just tested this code and it works fine for me? 🤔 fn = 'enwik5.zip'
print(fn)
def read_bytes(path):
with open(path, 'rb') as f:
return list(f.read())
data = read_bytes(fn)
nsyms = 256
stats = [0] * nsyms
for c in data:
stats[c] += 1
from arithmetic_compressor import AECompressor
from arithmetic_compressor.models.base_adaptive_model import BaseFrequencyTable
from arithmetic_compressor.models import StaticModel
from arithmetic_compressor.util import *
SCALE_FACTOR = 4096
freq_map = {
sym: freq for sym, freq in enumerate(stats)
if freq > 0
}
model = StaticModel(freq_map)
coder = AECompressor(model)
N = len(data)
compressed = coder.compress(data)
print(len(data))
print(len(compressed) // 8) Output:
|
I am also on version 3.11 |
I'm trying to use this module on enwik5 data (10 000 bytes). But I encounter this error:
Are there any additional limitations in the implementation? Or do I do something wrong?
The script below works ok with enwik4 data (1 000 bytes).
I count statistics myself and then use
StaticModel
, but I encounter either thisLow or high out of range
error, orValueError: Symbol has zero frequency
error.enwik5.zip
The text was updated successfully, but these errors were encountered: