How to correct errors with `creedsolo` (`2.1.2b1`)?
vytas7 opened this issue · 3 comments
Hello!
I'm having issues with using the cythonized creedsolo
, encoding and checking seems to work great, but my attempt to correct errors results in a ReedSolomonError
:
FAILED test.py::test_reed_solomon - creedsolo.creedsolo.ReedSolomonError: Too many (or few) errors found by Chien Search for the errata locator polynomial!
(It works as expected with the pure Python version.)
My test case used:
# Pure Python works as expected
# import reedsolo as rs
import creedsolo as rs
DATA = b'123456789abcdef\n' * 64
def test_reed_solomon():
prim = rs.find_prime_polys(c_exp=11, fast_primes=True, single=True)[0]
rs.init_tables(c_exp=11, prim=prim)
gen = rs.rs_generator_poly_all(1024+16)
encoded = rs.rs_encode_msg(DATA, 16, gen=gen[16])
encoded[3] = ord('7')
encoded[100] = ord('!')
assert not rs.rs_check(encoded, 16)
_, _, errata_pos = rs.rs_correct_msg(encoded, 16)
assert set(errata_pos) == {3, 100}
FWIW, I used the current Git master
@ 23b8eab
pip install . --config-setting="--build-option=--cythonize"
Thanks @lrq3000!
No worries, I was just looking for some Reed-Solomon library for a hobby project 🙂 Not urgent at all.
I did use the latest Git master
to start with.
Not sure if it is me misunderstanding something, or it is a real bug (related to the recent Cython 3.0.0 release?).
No I meant your issue here was incomplete when I first saw it, only the first sentence appeared ;-)
Ok so creedsolo is more optimized for GF(2⁸). For other fields, it may work, but it may also fail. I’ll have to have a second look, here you are using GF(2^11) so that’s likely why it’s failing.
Please try using the RSCodec class instead of using the low level functions, as this class tries to handles the tricky technicals, and especially with creedsolo, there are more hoops to go through to be compatible with all fields since creedsolo tries to be as optimized as possible, which is at the expense of flexibility and less generalizability.